Personal AI, On Personal Devices
Python
Revert "feat: auto-pull all Qwen3.5 models that fit on user's hardware"
Jon Saad-Falcon549a81f67994
diff --git a/desktop/src-tauri/Cargo.lock b/desktop/src-tauri/Cargo.lockindex 55112ab4..ba5f0965 100644--- a/desktop/src-tauri/Cargo.lock+++ b/desktop/src-tauri/Cargo.lock@@ -2573,7 +2573,7 @@ dependencies = [[[package]]name = "openjarvis-desktop"-version = "0.1.0"+version = "1.0.0"dependencies = ["reqwest 0.12.28","serde",diff --git a/desktop/src-tauri/src/lib.rs b/desktop/src-tauri/src/lib.rsindex 4ea87c43..d1f26918 100644--- a/desktop/src-tauri/src/lib.rs+++ b/desktop/src-tauri/src/lib.rs@@ -8,75 +8,7 @@ use tokio::sync::Mutex;const OLLAMA_PORT: u16 = 11434;const JARVIS_PORT: u16 = 8222;--/// Qwen3.5 model variants, ordered smallest to largest.-/// Each entry is (ollama_tag, approximate_download_size_gb, min_ram_gb).-/// min_ram_gb includes ~2GB headroom above model size for OS/runtime.-const QWEN35_MODELS: &[(&str, f64, f64)] = &[- ("qwen3.5:0.8b", 1.0, 4.0),- ("qwen3.5:2b", 2.7, 6.0),- ("qwen3.5:4b", 3.4, 8.0),- ("qwen3.5:9b", 6.6, 12.0),- ("qwen3.5:27b", 17.0, 24.0),- ("qwen3.5:35b", 24.0, 32.0),- // 122b needs ~81GB, only for 96GB+ machines- ("qwen3.5:122b", 81.0, 96.0),-];--/// Fallback model if we cannot determine RAM or no Qwen3.5 fits.-const FALLBACK_MODEL: &str = "qwen3:0.6b";--/// Get total system RAM in GB.-fn total_ram_gb() -> f64 {- #[cfg(target_os = "macos")]- {- use std::process::Command;- if let Ok(output) = Command::new("sysctl").args(["-n", "hw.memsize"]).output() {- if let Ok(s) = String::from_utf8(output.stdout) {- if let Ok(bytes) = s.trim().parse::<u64>() {- return bytes as f64 / (1024.0 * 1024.0 * 1024.0);- }- }- }- }- #[cfg(target_os = "linux")]- {- if let Ok(contents) = std::fs::read_to_string("/proc/meminfo") {- for line in contents.lines() {- if line.starts_with("MemTotal:") {- if let Some(kb_str) = line.split_whitespace().nth(1) {- if let Ok(kb) = kb_str.parse::<u64>() {- return kb as f64 / (1024.0 * 1024.0);- }- }- }- }- }- }- // Fallback: assume 8GB (conservative)- 8.0-}--/// Return the list of Qwen3.5 models that fit on this machine, smallest first.-fn models_that_fit() -> Vec<&'static str> {- let ram = total_ram_gb();- QWEN35_MODELS- .iter()- .filter(|(_, _, min_ram)| ram >= *min_ram)- .map(|(tag, _, _)| *tag)- .collect()-}--/// Return the largest Qwen3.5 model that fits, or the fallback.-fn best_default_model() -> &'static str {- let ram = total_ram_gb();- QWEN35_MODELS- .iter()- .rev()- .find(|(_, _, min_ram)| ram >= *min_ram)- .map(|(tag, _, _)| *tag)- .unwrap_or(&FALLBACK_MODEL)-}+const DEFAULT_MODEL: &str = "qwen3:0.6b";/// Resolve full path to a binary by checking common locations./// macOS .app bundles don't inherit the shell PATH, so we probe manually.@@ -280,13 +212,7 @@ async fn ollama_has_model(model: &str) -> bool {return models.iter().any(|m| {m.get("name").and_then(|n| n.as_str())- .map(|n| {- // Exact match on full tag, or match without- // Ollama's ":latest" suffix- n == model- || n.strip_suffix(":latest") == Some(model)- || model.strip_suffix(":latest") == Some(n)- })+ .map(|n| n.starts_with(model.split(':').next().unwrap_or(model))).unwrap_or(false)});}@@ -359,26 +285,19 @@ async fn boot_backend(backend: SharedBackend, status: SharedStatus) {s.detail = "Inference engine ready.".into();}- // Phase 2: Ensure models are available- let fitting = models_that_fit();- let default_model = best_default_model();-- // Pull the smallest model first so the app becomes usable quickly.- // Then the server starts while remaining models download in the background.- let first_model = fitting.first().copied().unwrap_or(FALLBACK_MODEL);-+ // Phase 2: Ensure a default model exists{let mut s = status.lock().await;s.phase = "model".into();- s.detail = format!("Checking for model {}...", first_model);+ s.detail = format!("Checking for model {}...", DEFAULT_MODEL);}- if !ollama_has_model(first_model).await {+ if !ollama_has_model(DEFAULT_MODEL).await {{let mut s = status.lock().await;- s.detail = format!("Downloading {}... (this may take a minute)", first_model);+ s.detail = format!("Downloading {}... (this may take a minute)", DEFAULT_MODEL);}- if let Err(e) = pull_model(first_model).await {+ if let Err(e) = pull_model(DEFAULT_MODEL).await {let mut s = status.lock().await;s.error = Some(format!("Failed to download model: {}", e));return;@@ -391,13 +310,6 @@ async fn boot_backend(backend: SharedBackend, status: SharedStatus) {s.detail = "Model ready.".into();}- // Collect remaining models to pull in the background after the server starts.- let remaining_models: Vec<&str> = fitting- .iter()- .filter(|m| **m != first_model)- .copied()- .collect();-// Phase 3: Start jarvis serve{let mut s = status.lock().await;@@ -420,12 +332,7 @@ async fn boot_backend(backend: SharedBackend, status: SharedStatus) {}let mut cmd = tokio::process::Command::new(&uv_bin);- cmd.args([- "run", "jarvis", "serve",- "--port", &JARVIS_PORT.to_string(),- "--model", default_model,- "--agent", "simple",- ])+ cmd.args(["run", "jarvis", "serve", "--port", &JARVIS_PORT.to_string(), "--agent", "simple"]).stdout(std::process::Stdio::null()).stderr(std::process::Stdio::null()).current_dir(project_root.as_ref().unwrap());@@ -461,19 +368,6 @@ async fn boot_backend(backend: SharedBackend, status: SharedStatus) {s.phase = "ready".into();s.detail = "All systems ready.".into();}-- // Phase 4: Pull remaining Qwen3.5 models in the background.- // The server is already running with the first model, so the user- // can start chatting immediately while larger models download.- if !remaining_models.is_empty() {- tokio::spawn(async move {- for model in remaining_models {- if !ollama_has_model(model).await {- let _ = pull_model(model).await;- }- }- });- }}// ---------------------------------------------------------------------------diff --git a/frontend/package-lock.json b/frontend/package-lock.jsonindex 697dcc97..fb450ed7 100644--- a/frontend/package-lock.json+++ b/frontend/package-lock.json@@ -1,12 +1,12 @@{"name": "openjarvis-chat",- "version": "0.1.0",+ "version": "1.0.0","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "openjarvis-chat",- "version": "0.1.0",+ "version": "1.0.0","dependencies": {"@tailwindcss/vite": "^4.2.1","@tauri-apps/api": "^2",