@ondeinference / onde / commits / 7e6b463

Fix clippy and fmt

keypair34 committed Apr 18, 2026 at 21:45 UTC 7e6b46360b8e4ad0252d219e3d5f6e614df95dab
5 files changed +67 -72
Cargo.toml
+37 -38
@@ -20,33 +20,6 @@ name = "onde"
20 # linking is not allowed.
21 crate-type = ["lib", "cdylib", "staticlib"]
22
23 -[dependencies]
24 -anyhow = "1"
25 -home = "0.5.4"
26 -log = "^0.4"
27 -serde = { version = "1.0", features = ["derive"] }
28 -reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] }
29 -tokio = { version = "1", features = ["macros", "rt", "sync"] }
30 -tsync = "2"
31 -
32 -thiserror = "2"
33 -serde_json = "1"
34 -
35 -# Pinned to =0.31.0 — the versions MUST be identical across the crate and
36 -# the uniffi-bindgen binary crate.
37 -uniffi = { version = "=0.31.0", features = ["tokio"] }
38 -
39 -[dependencies.smbcloud-gresiq-sdk]
40 -version = "0.3"
41 -# path = "../smbcloud-cli/crates/smbcloud-gresiq-sdk"
42 -
43 -[build-dependencies]
44 -# Required for UniFFI scaffolding code generation at build time.
45 -uniffi = { version = "=0.31.0", features = ["build"] }
46 -# Used by build.rs to compile the tvOS ___chkstk_darwin assembly stub.
47 -cc = "1"
48 -dotenvy = "0.15"
49 -
23 # Android: CPU-only GGUF inference via candle; also needs hf-hub and
24 # mistralrs-core for explicit cache path seeding (dirs::home_dir() panics
25 # in the Android sandbox).
@@ -66,6 +39,17 @@ mistralrs = { git = "https://github.com/setoelkahfi/mistral.rs", branch = "fix/a
39 # mistralrs-core = { version = "0.8.1", features = ["metal"] }
40 mistralrs-core = { git = "https://github.com/setoelkahfi/mistral.rs", branch = "fix/all-platform-fixes", features = ["metal"] }
41
42 +# Linux: CPU-only baseline (no GPU features).
43 +# For NVIDIA GPU builds, patch this to features = ["cuda"] in CI before building.
44 +[target.'cfg(target_os = "linux")'.dependencies]
45 +# mistralrs = { version = "0.8.1" }
46 +mistralrs = { git = "https://github.com/setoelkahfi/mistral.rs", branch = "fix/all-platform-fixes" }
47 +
48 +# macOS: Metal-accelerated inference.
49 +[target.'cfg(target_os = "macos")'.dependencies]
50 +# mistralrs = { version = "0.8.1", features = ["metal"] }
51 +mistralrs = { git = "https://github.com/setoelkahfi/mistral.rs", branch = "fix/all-platform-fixes", features = ["metal"] }
52 +
53 # tvOS: Metal-accelerated inference (Apple TV has Apple GPU); hf-hub +
54 # mistralrs-core needed for GLOBAL_HF_CACHE sandbox workaround.
55 [target.'cfg(target_os = "tvos")'.dependencies]
@@ -94,25 +78,40 @@ mistralrs = { git = "https://github.com/setoelkahfi/mistral.rs", branch = "fix/a
78 # mistralrs-core = { version = "0.8.1", features = ["metal"] }
79 mistralrs-core = { git = "https://github.com/setoelkahfi/mistral.rs", branch = "fix/all-platform-fixes", features = ["metal"] }
80
97 -# macOS: Metal-accelerated inference.
98 -[target.'cfg(target_os = "macos")'.dependencies]
99 -# mistralrs = { version = "0.8.1", features = ["metal"] }
100 -mistralrs = { git = "https://github.com/setoelkahfi/mistral.rs", branch = "fix/all-platform-fixes", features = ["metal"] }
101 -
81 # Windows: CPU-only baseline (no GPU features).
82 # For NVIDIA GPU builds, patch this to features = ["cuda"] in CI before building.
83 [target.'cfg(target_os = "windows")'.dependencies]
84 # mistralrs = { version = "0.8.1" }
85 mistralrs = { git = "https://github.com/setoelkahfi/mistral.rs", branch = "fix/all-platform-fixes" }
86
108 -# Linux: CPU-only baseline (no GPU features).
109 -# For NVIDIA GPU builds, patch this to features = ["cuda"] in CI before building.
110 -[target.'cfg(target_os = "linux")'.dependencies]
111 -# mistralrs = { version = "0.8.1" }
112 -mistralrs = { git = "https://github.com/setoelkahfi/mistral.rs", branch = "fix/all-platform-fixes" }
87 +[dependencies]
88 +anyhow = "1"
89 +home = "0.5.4"
90 +log = "^0.4"
91 +reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] }
92 +serde = { version = "1.0", features = ["derive"] }
93 +serde_json = "1"
94
114 -# Patch sysctl with watchOS (target_os = "watchos") support until upstream merges it.
95 +thiserror = "2"
96 +tokio = { version = "1", features = ["macros", "rt", "sync"] }
97 +tsync = "2"
98 +
99 +# Pinned to =0.31.0 — the versions MUST be identical across the crate and
100 +# the uniffi-bindgen binary crate.
101 +uniffi = { version = "=0.31.0", features = ["tokio"] }
102 +
103 +[dependencies.smbcloud-gresiq-sdk]
104 +version = "0.3"
105 +# path = "../smbcloud-cli/crates/smbcloud-gresiq-sdk"
106
107 +[build-dependencies]
108 +# Used by build.rs to compile the tvOS ___chkstk_darwin assembly stub.
109 +cc = "1"
110 +dotenvy = "0.15"
111 +# Required for UniFFI scaffolding code generation at build time.
112 +uniffi = { version = "=0.31.0", features = ["build"] }
113 +
114 +# Patch sysctl with watchOS (target_os = "watchos") support until upstream merges it.
115
116 # Patch sysctl with watchOS support until upstream merges it.
117 # PR: https://github.com/johalun/sysctl-rs/pull/74
src/inference/engine.rs
+20 -24
@@ -211,22 +211,19 @@ pub struct ChatEngine {
211 target_os = "linux",
212 target_os = "android"
213 ))]
214 -
215 -
214 impl ChatEngine {
215 // ── Construction ─────────────────────────────────────────────────────
216
217 /// Create a new engine with no model loaded.
218 pub fn new() -> Self {
219 let environment = Self::pulse_environment();
222 - let edge_id = std::env::var("ONDE_EDGE_ID")
223 - .unwrap_or_else(|_| "onde-unknown".to_string());
220 + let edge_id = std::env::var("ONDE_EDGE_ID").unwrap_or_else(|_| "onde-unknown".to_string());
221 let pulse = crate::pulse::PulseClient::new(environment, edge_id);
222
223 match &pulse {
227 - Some(_) => log::info!(
228 - "ChatEngine: pulse telemetry enabled (environment={environment})"
229 - ),
224 + Some(_) => {
225 + log::info!("ChatEngine: pulse telemetry enabled (environment={environment})")
226 + }
227 None => log::info!(
228 "ChatEngine: pulse telemetry disabled \
229 (GRESIQ_API_KEY / GRESIQ_API_SECRET not embedded at SDK build time)"
@@ -244,7 +241,7 @@ impl ChatEngine {
241 fn pulse_environment() -> smbcloud_gresiq_sdk::Environment {
242 match std::env::var("GRESIQ_ENVIRONMENT").as_deref() {
243 Ok("dev") => smbcloud_gresiq_sdk::Environment::Dev,
247 - _ => smbcloud_gresiq_sdk::Environment::Production,
244 + _ => smbcloud_gresiq_sdk::Environment::Production,
245 }
246 }
247
@@ -375,7 +372,7 @@ impl ChatEngine {
372 );
373
374 // Capture before config is moved into LoadedModel.
378 - let pulse_model_id = config.model_id.clone();
375 + let pulse_model_id = config.model_id.clone();
376 let pulse_model_name = config.display_name.clone();
377
378 let mut guard = self.inner.lock().await;
@@ -419,9 +416,9 @@ impl ChatEngine {
416
417 #[derive(serde::Deserialize)]
418 struct ModelConfigResponse {
422 - hf_repo_id: Option<String>,
423 - gguf_file: Option<String>,
424 - name: Option<String>,
419 + hf_repo_id: Option<String>,
420 + gguf_file: Option<String>,
421 + name: Option<String>,
422 approx_size_bytes: Option<i64>,
423 }
424
@@ -460,15 +457,16 @@ impl ChatEngine {
457 });
458 }
459
463 - let resp: ModelConfigResponse = response
464 - .json()
465 - .await
466 - .map_err(|e| InferenceError::ModelBuild {
467 - reason: format!("Failed to parse model_config response: {e}"),
468 - })?;
460 + let resp: ModelConfigResponse =
461 + response
462 + .json()
463 + .await
464 + .map_err(|e| InferenceError::ModelBuild {
465 + reason: format!("Failed to parse model_config response: {e}"),
466 + })?;
467
468 let hf_repo_id = resp.hf_repo_id.as_deref().unwrap_or_default();
471 - let gguf_file = resp.gguf_file.as_deref().unwrap_or_default();
469 + let gguf_file = resp.gguf_file.as_deref().unwrap_or_default();
470
471 if hf_repo_id.is_empty() || gguf_file.is_empty() {
472 warn!(
@@ -480,8 +478,7 @@ impl ChatEngine {
478 }
479
480 #[cfg(target_os = "android")]
483 - let tok_model_id = super::models::tok_model_id_for_repo(hf_repo_id)
484 - .map(|s| s.to_string());
481 + let tok_model_id = super::models::tok_model_id_for_repo(hf_repo_id).map(|s| s.to_string());
482 #[cfg(not(target_os = "android"))]
483 let tok_model_id: Option<String> = None;
484
@@ -503,8 +500,8 @@ impl ChatEngine {
500 );
501
502 let config = GgufModelConfig {
506 - model_id: hf_repo_id.to_string(),
507 - files: vec![gguf_file.to_string()],
503 + model_id: hf_repo_id.to_string(),
504 + files: vec![gguf_file.to_string()],
505 tok_model_id,
506 display_name: resp.name.unwrap_or_else(|| hf_repo_id.to_string()),
507 approx_memory,
@@ -513,7 +510,6 @@ impl ChatEngine {
510 self.load_gguf_model(config, system_prompt, sampling).await
511 }
512
516 -
513 /// Load an ISQ (in-situ quantised) model into the engine.
514 ///
515 /// Unlike [`load_gguf_model`], this downloads the full-precision safetensors
src/inference/models.rs
+4 -4
@@ -148,10 +148,10 @@ pub const SUPPORTED_MODEL_INFO: &[SupportedModelInfo] = &[
148 /// embedded tokenizer is used automatically.
149 pub fn tok_model_id_for_repo(hf_repo_id: &str) -> Option<&'static str> {
150 match hf_repo_id {
151 - BARTOWSKI_QWEN25_1_5B_INSTRUCT_GGUF => Some(QWEN25_1_5B_TOK_MODEL_ID),
152 - BARTOWSKI_QWEN25_3B_INSTRUCT_GGUF => Some(QWEN25_3B_TOK_MODEL_ID),
151 + BARTOWSKI_QWEN25_1_5B_INSTRUCT_GGUF => Some(QWEN25_1_5B_TOK_MODEL_ID),
152 + BARTOWSKI_QWEN25_3B_INSTRUCT_GGUF => Some(QWEN25_3B_TOK_MODEL_ID),
153 BARTOWSKI_QWEN25_CODER_1_5B_INSTRUCT_GGUF => Some(QWEN25_CODER_1_5B_TOK_MODEL_ID),
154 - BARTOWSKI_QWEN25_CODER_3B_INSTRUCT_GGUF => Some(QWEN25_CODER_3B_TOK_MODEL_ID),
155 - _ => None,
154 + BARTOWSKI_QWEN25_CODER_3B_INSTRUCT_GGUF => Some(QWEN25_CODER_3B_TOK_MODEL_ID),
155 + _ => None,
156 }
157 }
src/lib.rs
+1 -1
@@ -44,8 +44,8 @@
44
45 pub mod hf_cache;
46
47 -pub mod pulse;
47 pub mod inference;
48 +pub mod pulse;
49
50 uniffi::setup_scaffolding!();
51
src/pulse/client.rs
+5 -5
@@ -20,7 +20,7 @@ const EMBEDDED_API_SECRET: Option<&str> = option_env!("GRESIQ_API_SECRET");
20 /// so cloning is a pointer bump, not a new TCP connection.
21 #[derive(Debug, Clone)]
22 pub struct PulseClient {
23 - inner: GresiqClient,
23 + inner: GresiqClient,
24 edge_id: String,
25 }
26
@@ -34,7 +34,7 @@ impl PulseClient {
34 /// `edge_id` is a stable device identifier (installation UUID).
35 /// Pass an empty string to default to `"onde-unknown"`.
36 pub fn new(environment: Environment, edge_id: String) -> Option<Self> {
37 - let api_key = EMBEDDED_API_KEY?;
37 + let api_key = EMBEDDED_API_KEY?;
38 let api_secret = EMBEDDED_API_SECRET?;
39
40 let edge_id = if edge_id.is_empty() {
@@ -78,10 +78,10 @@ impl PulseClient {
78 /// completions. Writes to pulse/inference_event. Logs on failure, no retry.
79 pub fn record_inference(
80 &self,
81 - model_id: String,
82 - request_id: String,
81 + model_id: String,
82 + request_id: String,
83 duration_ms: u64,
84 - status: String,
84 + status: String,
85 ) {
86 let client = self.clone();
87 tokio::spawn(async move {