initLegacy static method

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

Implementation

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

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

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

  lm._initParams = initParams;

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

  return lm;
}