initLegacy static method

  1. @Deprecated('Use download() and init() separately instead')
Future<CactusVLM> initLegacy({
  1. required String modelUrl,
  2. required String mmprojUrl,
  3. String? modelFilename,
  4. String? mmprojFilename,
  5. String? chatTemplate,
  6. int contextSize = 2048,
  7. int gpuLayers = 0,
  8. int threads = 4,
  9. CactusProgressCallback? onProgress,
  10. String? cactusToken,
})

Implementation

@Deprecated('Use download() and init() separately instead')
static Future<CactusVLM> initLegacy({
  required String modelUrl,
  required String mmprojUrl,
  String? modelFilename,
  String? mmprojFilename,
  String? chatTemplate,
  int contextSize = 2048,
  int gpuLayers = 0,
  int threads = 4,
  CactusProgressCallback? onProgress,
  String? cactusToken,
}) async {
  final vlm = CactusVLM._();

  if (cactusToken != null) {
    setCactusToken(cactusToken);
  }

  final initParams = CactusInitParams(
    modelUrl: modelUrl,
    modelFilename: modelFilename,
    mmprojUrl: mmprojUrl,
    mmprojFilename: mmprojFilename,
    chatTemplate: chatTemplate,
    contextSize: contextSize,
    gpuLayers: gpuLayers,
    threads: threads,
    onInitProgress: onProgress,
  );

  try {
    vlm._context = await CactusContext.init(initParams);
  } catch (e) {
    CactusTelemetry.error(e, initParams);
    rethrow;
  }

  return vlm;
}