register method

Future<ModelInfo> register(
  1. ModelRegistration model
)

Add model to the registry and return its entry.

Throws SDKException when registration fails.

Implementation

Future<ModelInfo> register(ModelRegistration model) {
  _registryDirty = true;
  switch (model.kind) {
    case ModelArtifactKind.singleFile:
      return RunAnywhereStorage.registerModel(
        id: model.id,
        name: model.name,
        url: model.url!,
        framework: model.framework,
        modality: model.category,
        artifactType: model.artifactType,
        memoryRequirement: model.memoryRequirementBytes,
        supportsThinking: model.supportsThinking,
        supportsLora: model.supportsLora,
        cuaProfile: model.cuaProfile,
      );
    case ModelArtifactKind.archive:
      return RunAnywhereStorage.registerArchiveModel(
        archiveUrl: model.url!,
        structure: model.archiveStructure!,
        id: model.id,
        name: model.name,
        framework: model.framework,
        modality: model.category,
        archiveType: model.archiveType,
        memoryRequirement: model.memoryRequirementBytes,
        supportsThinking: model.supportsThinking,
        supportsLora: model.supportsLora,
        cuaProfile: model.cuaProfile,
      );
    case ModelArtifactKind.multiFile:
      return RunAnywhereStorage.registerMultiFileModel(
        files: _withInferredRoles(model.files, model.category),
        id: model.id!,
        name: model.name,
        framework: model.framework,
        modality: model.category,
        memoryRequirement: model.memoryRequirementBytes,
        contextLength: model.contextLength,
        supportsThinking: model.supportsThinking,
        source: model.source,
        cuaProfile: model.cuaProfile,
      );
  }
}