Replace llamadart, flutter_onnxruntime and flutter_langdetect with API-compatible stubs via dependency_overrides, so llama.cpp, LiteRT-LM and ONNX Runtime are not packaged. Translation and the neural image codec become unavailable; both are off by default upstream. Also drop non-arm64 prebuilt plugin libraries at packaging time. APK: 340 MB -> 39.5 MB, flutter test 909/909 passing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
59 lines
1.2 KiB
Dart
59 lines
1.2 KiB
Dart
Never _unsupported() => throw UnsupportedError('llama.cpp is not built in.');
|
|
|
|
enum GpuBackend { auto, cpu }
|
|
|
|
enum LlamaChatRole { system, user, assistant }
|
|
|
|
class ModelParams {
|
|
final int gpuLayers;
|
|
final GpuBackend preferredBackend;
|
|
|
|
const ModelParams({this.gpuLayers = 0, this.preferredBackend = GpuBackend.cpu});
|
|
}
|
|
|
|
class GenerationParams {
|
|
const GenerationParams({
|
|
int? maxTokens,
|
|
double? temp,
|
|
int? topK,
|
|
double? topP,
|
|
double? penalty,
|
|
bool? reusePromptPrefix,
|
|
});
|
|
}
|
|
|
|
class LlamaChatMessage {
|
|
LlamaChatMessage.fromText({required LlamaChatRole role, required String text});
|
|
}
|
|
|
|
class LlamaDelta {
|
|
String? get content => null;
|
|
}
|
|
|
|
class LlamaChoice {
|
|
LlamaDelta get delta => LlamaDelta();
|
|
}
|
|
|
|
class LlamaCompletionChunk {
|
|
List<LlamaChoice> get choices => const <LlamaChoice>[];
|
|
}
|
|
|
|
class LlamaBackend {}
|
|
|
|
class LlamaEngine {
|
|
LlamaEngine(LlamaBackend backend);
|
|
|
|
Future<void> loadModel(String path, {ModelParams? modelParams}) async =>
|
|
_unsupported();
|
|
|
|
Stream<LlamaCompletionChunk> create(
|
|
List<LlamaChatMessage> messages, {
|
|
GenerationParams? params,
|
|
bool? enableThinking,
|
|
String? sourceLangCode,
|
|
String? targetLangCode,
|
|
}) => _unsupported();
|
|
|
|
Future<void> dispose() async {}
|
|
}
|