registerMultiFileModel static method
Future<ModelInfo>
registerMultiFileModel({
- required List<
ModelFileDescriptor> files, - required String id,
- required String name,
- required InferenceFramework framework,
- ModelCategory modality = ModelCategory.MODEL_CATEGORY_LANGUAGE,
- int? memoryRequirement,
- int? contextLength,
- bool supportsThinking = false,
- ModelSource source = ModelSource.MODEL_SOURCE_REMOTE,
Register a multi-file model (e.g., VLMs with a separate mmproj,
MiniLM embedding with vocab.txt) through the canonical commons
factory (rac_register_multi_file_model_proto) — no URL is involved at
the model level because each ModelFileDescriptor carries its own URL.
Mirrors Swift RunAnywhere.registerModel(multiFile:id:name:framework: modality:memoryRequirement:contextLength:supportsThinking:source:).
Implementation
static Future<ModelInfo> registerMultiFileModel({
required List<ModelFileDescriptor> files,
required String id,
required String name,
required InferenceFramework framework,
ModelCategory modality = ModelCategory.MODEL_CATEGORY_LANGUAGE,
int? memoryRequirement,
int? contextLength,
bool supportsThinking = false,
ModelSource source = ModelSource.MODEL_SOURCE_REMOTE,
}) async {
if (!DartBridge.isInitialized) {
throw SDKException.notInitialized();
}
// Canonical commons factory: rac_register_multi_file_model_proto builds
// the MultiFileArtifact ModelInfo (descriptors carry url/filename/size/
// checksum/role) and persists it with merge-on-reseed semantics.
final request = RegisterMultiFileModelRequest(
id: id,
name: name,
framework: framework,
category: modality,
supportsThinking: supportsThinking,
source: source,
files: files,
);
if (memoryRequirement != null) {
request.memoryRequiredBytes = Int64(memoryRequirement);
}
// See registerModel: downloadSizeBytes is intentionally left unset so the
// post-finalize size guard validates against the actual transfer rather
// than the RAM-estimate placeholder.
final resolvedContextLength =
contextLength ?? (modality.requiresContextLength ? 2048 : null);
if (resolvedContextLength != null) {
request.contextLength = resolvedContextLength;
}
final model =
await DartBridgeModelRegistry.instance.registerMultiFileModel(request);
if (model == null) {
throw SDKException.internalError(
'rac_register_multi_file_model_proto failed for model "$name"',
);
}
return model;
}