|
1
|
//! # Onde |
|
2
|
//! |
|
3
|
//! **On-device chat inference for cross-platform apps.** |
|
4
|
//! |
|
5
|
//! Run LLM chat locally — no cloud, no latency, no data leaving the device. |
|
6
|
//! |
|
7
|
//! Onde wraps [mistral.rs](https://github.com/EricLBuehler/mistral.rs) with a |
|
8
|
//! unified API for model discovery, HuggingFace Hub downloads, cache |
|
9
|
//! management, and GPU acceleration across every platform. |
|
10
|
//! |
|
11
|
//! Built by [Onde Inference](https://ondeinference.com) |
|
12
|
//! |
|
13
|
//! ## Modules |
|
14
|
//! |
|
15
|
//! - [`hf_cache`] — HuggingFace Hub cache inspection, repair, and model |
|
16
|
//! download with a framework-agnostic progress-callback API. |
|
17
|
//! - [`inference`] — Chat inference engine, UniFFI FFI wrapper, model metadata, |
|
18
|
//! and HuggingFace token resolution. |
|
19
|
//! |
|
20
|
//! ## Re-exports |
|
21
|
//! |
|
22
|
//! `mistralrs`, `hf_hub`, and `mistralrs_core` are re-exported so that apps |
|
23
|
//! depending on `onde` do not need their own direct dependency on those crates. |
|
24
|
//! Access them as `onde::mistralrs`, `onde::hf_hub`, and `onde::mistralrs_core`. |
|
25
|
//! |
|
26
|
//! ## Example |
|
27
|
//! |
|
28
|
//! ```rust,ignore |
|
29
|
//! use onde::inference::ChatEngine; |
|
30
|
//! use onde::inference::GgufModelConfig; |
|
31
|
//! |
|
32
|
//! let engine = ChatEngine::new(); |
|
33
|
//! engine |
|
34
|
//! .load_gguf_model( |
|
35
|
//! GgufModelConfig::platform_default(), |
|
36
|
//! Some("You are a helpful assistant.".into()), |
|
37
|
//! None, |
|
38
|
//! ) |
|
39
|
//! .await?; |
|
40
|
//! |
|
41
|
//! let result = engine.send_message("Hello!").await?; |
|
42
|
//! println!("{}", result.text); |
|
43
|
//! ``` |
|
44
|
|
|
45
|
pub mod hf_cache; |
|
46
|
|
|
47
|
pub mod inference; |
|
48
|
pub mod pulse; |
|
49
|
|
|
50
|
uniffi::setup_scaffolding!(); |
|
51
|
|
|
52
|
// Re-export mistralrs for every platform that onde supports. |
|
53
|
// Apps use `onde::mistralrs::Model` etc. instead of declaring a direct dep. |
|
54
|
#[cfg(any( |
|
55
|
target_os = "macos", |
|
56
|
target_os = "ios", |
|
57
|
target_os = "tvos", |
|
58
|
target_os = "visionos", |
|
59
|
target_os = "watchos", |
|
60
|
target_os = "windows", |
|
61
|
target_os = "linux", |
|
62
|
target_os = "android" |
|
63
|
))] |
|
64
|
pub use mistralrs; |
|
65
|
|
|
66
|
// Re-exports needed for the GLOBAL_HF_CACHE workaround on sandboxed platforms. |
|
67
|
// On iOS/tvOS `~/.cache` is outside the container; on Android `dirs::home_dir()` |
|
68
|
// panics. All three need `hf_hub::Cache` + `mistralrs_core::GLOBAL_HF_CACHE`. |
|
69
|
#[cfg(any(target_os = "android", target_os = "ios", target_os = "tvos"))] |
|
70
|
pub use hf_hub; |
|
71
|
#[cfg(any(target_os = "android", target_os = "ios", target_os = "tvos"))] |
|
72
|
pub use mistralrs_core; |