zetic_mlange 1.8.0
zetic_mlange: ^1.8.0 copied to clipboard
Flutter FFI SDK for running ZeticMLange on-device AI models on Android and iOS.
ZeticMLange Flutter #
Flutter SDK for running ZeticMLange on-device AI models on Android and iOS.
ZeticMLange loads models deployed from the ZETIC dashboard and runs inference through the native Android and iOS runtimes. The Flutter package exposes Dart APIs for general model inference, supported Hugging Face models, and LLM token generation.
Features #
- Run ZeticMLange models on-device from Flutter.
- Load models by personal key, model name, and optional version.
- Run tensor-based inference with Dart
Tensorvalues. - Stream generated tokens from on-device LLM models.
- Select model mode, quantization, target, accelerator type, and cache policy.
- Use the same Dart API surface on Android and iOS.
Platform support #
| Platform | Minimum |
|---|---|
| Android | API 24+ |
| iOS | iOS 16.6+ |
| Dart | 3.11.5+ |
| Flutter | 3.35.0+ |
Installation #
Add the package to your Flutter app:
dependencies:
zetic_mlange: ^1.8.0
Then install dependencies:
flutter pub get
This package requires the ZeticMLange native runtime to be available in the host app. Follow the Flutter setup guide for Android and iOS integration:
Basic inference #
import 'dart:typed_data';
import 'package:zetic_mlange/zetic_mlange.dart';
Future<Float32List> runModel({
required String personalKey,
required String modelName,
required Float32List inputValues,
}) async {
final model = await ZeticMLangeModel.create(
personalKey: personalKey,
name: modelName,
);
try {
final input = Tensor.float32List(
inputValues,
shape: const [1, 3, 224, 224],
);
final outputs = model.run([input]);
return outputs.first.asFloat32List();
} finally {
model.close();
}
}
LLM generation #
import 'package:zetic_mlange/zetic_mlange.dart';
Future<void> generateText({
required String personalKey,
required String modelName,
}) async {
final llm = await ZeticMLangeLLMModel.create(
personalKey: personalKey,
name: modelName,
initOption: const LLMInitOption(nCtx: 4096),
);
try {
llm.run('Explain on-device AI in one paragraph.');
while (true) {
final next = llm.waitForNextToken();
if (next.isFinished) {
break;
}
print(next.token);
}
llm.cleanUp();
} finally {
llm.close();
}
}
Hugging Face models #
Supported Hugging Face models can be loaded with ZeticMLangeHFModel:
final model = await ZeticMLangeHFModel.create(
'owner/repository',
userAccessToken: userAccessToken,
);
try {
final outputs = model.run(inputs);
} finally {
model.close();
}
See the Hugging Face model guide for supported formats and deployment requirements.
Public API #
The package exports:
ZeticMLangeModelZeticMLangeHFModelZeticMLangeLLMModelTensorDataType,Target,APType,ModelMode,QuantTypeLLMModelMode,LLMTarget,LLMQuantType,LLMInitOptionLLMKVCacheCleanupPolicy,CacheHandlingPolicyMlangeException
Documentation #
Full documentation is available at docs.zetic.ai.
Useful starting points:
License #
Apache-2.0. See LICENSE.