1 // Copyright 2026 Splitfire AB (Onde Inference). All rights reserved.
2 // SPDX-License-Identifier: MIT OR Apache-2.0
3
4 /// On-device LLM inference SDK for Flutter & Dart.
5 ///
6 /// Runs Qwen models locally with Metal on Apple platforms and CPU inference on
7 /// Android, Linux, and Windows. No cloud hop and no user data leaving the
8 /// device. Powered by the Onde Rust engine and
9 /// [mistral.rs](https://github.com/EricLBuehler/mistral.rs).
10 ///
11 /// ## Quick start
12 ///
13 /// ```dart
14 /// import 'package:flutter/widgets.dart';
15 /// import 'package:onde_inference/onde_inference.dart';
16 ///
17 /// Future<void> main() async {
18 /// WidgetsFlutterBinding.ensureInitialized();
19 /// await OndeInference.init();
20 ///
21 /// final engine = OndeChatEngine();
22 /// await engine.loadDefaultModel(
23 /// systemPrompt: 'You are a helpful assistant.',
24 /// );
25 ///
26 /// final result = await engine.sendMessage(message: 'Hello!');
27 /// print(result.text);
28 ///
29 /// final buffer = StringBuffer();
30 /// await for (final chunk in engine.streamMessage(message: 'Tell me a short story.')) {
31 /// buffer.write(chunk.delta);
32 /// if (chunk.done) break;
33 /// }
34 /// print(buffer.toString());
35 ///
36 /// await engine.unloadModel();
37 /// }
38 /// ```
39 ///
40 /// ## Selecting a model
41 ///
42 /// ```dart
43 /// final config = OndeInference.defaultModelConfig();
44 /// final coderConfig = OndeInference.qwen25Coder3bConfig();
45 ///
46 /// await engine.loadGgufModel(config: coderConfig);
47 /// ```
48 ///
49 /// ## Customising sampling
50 ///
51 /// ```dart
52 /// await engine.setSampling(
53 /// sampling: OndeInference.deterministicSamplingConfig(),
54 /// );
55 ///
56 /// await engine.loadDefaultModel(
57 /// sampling: SamplingConfig(
58 /// temperature: 0.5,
59 /// maxTokens: BigInt.from(256),
60 /// ),
61 /// );
62 /// ```
63 ///
64 /// ## Error handling
65 ///
66 /// The generated bridge throws [OndeError] values directly:
67 ///
68 /// ```dart
69 /// try {
70 /// await engine.sendMessage(message: '...');
71 /// } on OndeError catch (e) {
72 /// debugPrint('Inference error: $e');
73 /// }
74 /// ```
75 ///
76 /// See the package README and the example app for platform-specific setup,
77 /// cache configuration, and end-to-end Flutter integration.
78 library;
79
80 // Re-export the core data types (ChatMessage, SamplingConfig,
81 // GgufModelConfig, and friends) from the FRB-generated api.dart via types.dart.
82 export 'src/types.dart';
83
84 // Engine API: OndeChatEngineX helpers, OndeInference static helpers,
85 // the OndeChatEngine opaque type, the OndeError sealed class, and RustLib.
86 export 'src/engine.dart';