Skip to content

Local, full Windows search replacement, clipboard manager, and launcher: files, apps, settings and semantic media search with Google's EmbeddingGemma 2.

Fix dictation startup, source layouts and multimodal embedding requests

ampersandru6328a8361dec
diff --git a/Build-Rust.ps1 b/Build-Rust.ps1
index 7daaade..26bbc6a 100644
--- a/Build-Rust.ps1
+++ b/Build-Rust.ps1
@@ -82,8 +82,8 @@ if (Test-Path $taskPortable) { throw 'Portable staging directory already exists.
New-Item -ItemType Directory -Force $taskPortable | Out-Null
Get-ChildItem -LiteralPath $taskBundle | Copy-Item -Destination $taskPortable -Recurse -Force
Set-Content -LiteralPath (Join-Path $taskPortable 'portable.flag') -Value '' -Encoding ascii
-Compress-Archive -Path (Join-Path $taskPortable '*') -DestinationPath 'dist/installer/VectorDash-Rust-0.3.22-x64.zip' -Force
-$taskInstaller='dist/installer/VectorDash-Rust-Setup-0.3.22-x64.exe'
-$taskZip='dist/installer/VectorDash-Rust-0.3.22-x64.zip'
+Compress-Archive -Path (Join-Path $taskPortable '*') -DestinationPath 'dist/installer/VectorDash-Rust-0.3.23-x64.zip' -Force
+$taskInstaller='dist/installer/VectorDash-Rust-Setup-0.3.23-x64.exe'
+$taskZip='dist/installer/VectorDash-Rust-0.3.23-x64.zip'
@($taskInstaller,$taskZip) | ForEach-Object {((Get-FileHash -LiteralPath $_ -Algorithm SHA256).Hash.ToLowerInvariant()+' '+(Split-Path $_ -Leaf))} | Set-Content 'dist/installer/RUST-SHA256SUMS.txt' -Encoding ascii
Write-Output "Native installer and portable ZIP ready."
diff --git a/native/Cargo.lock b/native/Cargo.lock
index 75ff813..2d41d83 100644
--- a/native/Cargo.lock
+++ b/native/Cargo.lock
@@ -5716,7 +5716,7 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]]
name = "vectordash"
-version = "0.3.22"
+version = "0.3.23"
dependencies = [
"anyhow",
"arboard",
diff --git a/native/Cargo.toml b/native/Cargo.toml
index 141c85e..a532543 100644
--- a/native/Cargo.toml
+++ b/native/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "vectordash"
-version = "0.3.22"
+version = "0.3.23"
edition = "2024"
license = "MIT"
[dependencies]
diff --git a/native/src/app.rs b/native/src/app.rs
index 3f80bca..597c141 100644
--- a/native/src/app.rs
+++ b/native/src/app.rs
@@ -575,6 +575,14 @@ impl App {
app.mode = "Names".into();
app.dirty = true;
}
+ if args.iter().any(|a| a == "--smoke-indexing") {
+ app.indexing = true;
+ }
+ if args.iter().any(|a| a == "--smoke-transcribing") {
+ app.dictation_busy = true;
+ app.dictation_status = "Transcribing...".into();
+ app.query.clear();
+ }
if let Some(status) = get("--smoke-status") {
app.status = status;
}
@@ -1986,7 +1994,7 @@ impl App {
..egui::Margin::symmetric(8, 8)
})
.lock_focus(true)
- .interactive(!recording)
+ .interactive(!self.dictation_busy && !recording)
.text_color(if recording {
Color32::TRANSPARENT
} else {
@@ -1994,6 +2002,8 @@ impl App {
})
.hint_text(if recording {
""
+ } else if self.dictation_busy {
+ "Transcribing..."
} else {
match self.tool.as_str() {
"AI" => "Ask AI",
@@ -2993,11 +3003,11 @@ impl App {
});
self.source_selected.resize(self.s.roots.len(), false);
let mut remove = None;
- egui::ScrollArea::vertical()
+ let inclusion_list = egui::ScrollArea::vertical()
.id_salt("inclusion-list")
.max_width(ui.available_width() * 0.88)
.max_height(220.0)
- .min_scrolled_height(0.0)
+ .min_scrolled_height(220.0)
.auto_shrink([false, false])
.show(ui, |ui| {
for (i, root) in self.s.roots.clone().iter().enumerate() {
@@ -3023,6 +3033,17 @@ impl App {
});
}
});
+ if self.smoke.is_some() {
+ ui.ctx().data_mut(|data| {
+ data.insert_temp(
+ egui::Id::new("qa-inclusion"),
+ [
+ inclusion_list.inner_rect.height(),
+ inclusion_list.content_size.y,
+ ],
+ )
+ });
+ }
if let Some(i) = remove {
self.s.roots.remove(i);
self.source_selected.remove(i);
@@ -3071,11 +3092,18 @@ impl App {
}
});
let mut remove = None;
- egui::ScrollArea::vertical()
+ let exclusion_list = egui::ScrollArea::vertical()
.id_salt("exclusion-list")
.max_width(ui.available_width() * 0.88)
.max_height(220.0)
- .min_scrolled_height(0.0)
+ .min_scrolled_height(if self.s.exclusions.is_empty() {
+ 0.0
+ } else {
+ (self.s.exclusions.len() as f32
+ * (ui.spacing().interact_size.y + ui.spacing().item_spacing.y)
+ - ui.spacing().item_spacing.y)
+ .clamp(0.0, 220.0)
+ })
.auto_shrink([false, true])
.show(ui, |ui| {
for (i, p) in self.s.exclusions.iter().enumerate() {
@@ -3092,6 +3120,17 @@ impl App {
});
}
});
+ if self.smoke.is_some() {
+ ui.ctx().data_mut(|data| {
+ data.insert_temp(
+ egui::Id::new("qa-exclusion"),
+ [
+ exclusion_list.inner_rect.height(),
+ exclusion_list.content_size.y,
+ ],
+ )
+ });
+ }
if let Some(i) = remove {
self.exclusion_selected.remove(i);
self.s.exclusions.remove(i);
@@ -3197,7 +3236,13 @@ impl App {
return;
}
self.devices_loading = true;
- self.devices_server = self.s.server.clone();
+ self.devices_server = format!("{}|{}", self.s.server, self.s.backend());
+ if !self.s.runtime_compatible() {
+ self.devices_loading = false;
+ self.devices.clear();
+ self.status = "Download the selected backend runtime before detecting devices".into();
+ return;
+ }
self.devices.clear();
let server = self.s.server.clone();
let tx = self.engine.tx.clone();
@@ -3249,9 +3294,15 @@ impl App {
],
egui::Stroke::new(1.0, self.accent().gamma_multiply(0.3)),
);
- for (i, v) in wave.iter().enumerate() {
- let x = rect.left() + i as f32 / (wave.len() - 1) as f32 * rect.width();
- let h = (v.sqrt() * 22.0).clamp(0.5, 12.0);
+ let bars = (rect.width() / 4.0).floor().max(2.0) as usize;
+ for i in 0..bars {
+ let position = i as f32 / (bars - 1) as f32 * (wave.len() - 1) as f32;
+ let index = position.floor() as usize;
+ let fraction = position.fract();
+ let value =
+ wave[index] * (1.0 - fraction) + wave[(index + 1).min(wave.len() - 1)] * fraction;
+ let x = rect.left() + i as f32 / (bars - 1) as f32 * rect.width();
+ let h = (value.sqrt() * 22.0).clamp(0.5, 12.0);
ui.painter().line_segment(
[egui::pos2(x, center - h), egui::pos2(x, center + h)],
egui::Stroke::new(1.5, self.accent()),
@@ -3579,15 +3630,39 @@ impl App {
&mut self.s.hardware,
&["CPU / system RAM", "Dedicated GPU", "Integrated GPU"],
);
+ if self.s.hardware == "Integrated GPU"
+ && (self.s.runtime_backend == "CUDA"
+ || self.s.device.to_ascii_uppercase().starts_with("CUDA"))
+ {
+ self.s.runtime_backend = "Vulkan".into();
+ self.s.device.clear();
+ }
if self.s.hardware != "CPU / system RAM" {
- combo(
- ui,
- "backend",
- &mut self.s.runtime_backend,
- &["Auto", "CUDA", "Vulkan"],
- );
+ let backends: &[&str] = if self.s.hardware == "Integrated GPU" {
+ &["Auto", "Vulkan"]
+ } else {
+ &["Auto", "CUDA", "Vulkan"]
+ };
+ combo(ui, "backend", &mut self.s.runtime_backend, backends);
+ if !self.s.runtime_compatible() {
+ ui.label(RichText::new("The selected runtime does not support this backend. Download its runtime to detect devices.").color(self.accent()));
+ if ui
+ .add_enabled(
+ !self.setup_busy,
+ egui::Button::new("Download selected backend runtime"),
+ )
+ .clicked()
+ {
+ self.install_component("runtime");
+ }
+ }
+ if self.s.hardware == "Integrated GPU" {
+ ui.weak("Intel iGPUs require Vulkan and an enabled graphics device with a compatible Intel driver. A CUDA runtime cannot detect Intel GPUs.");
+ }
ui.label(format!("Setup backend: {}. CUDA is recommended for NVIDIA; Vulkan supports Intel/AMD and compatible NVIDIA builds.",if self.s.backend()=="cuda-"{"CUDA"}else{"Vulkan"}));
- if self.devices_server != self.s.server && !self.devices_loading {
+ if self.devices_server != format!("{}|{}", self.s.server, self.s.backend())
+ && !self.devices_loading
+ {
self.refresh_devices();
}
let text = self
@@ -3754,6 +3829,16 @@ impl App {
} else {
self.remote_server_ui(ui, 1);
}
+ ui.checkbox(
+ &mut self.s.dictation_auto_finish,
+ "Transcribe automatically after I stop speaking",
+ );
+ if self.s.dictation_auto_finish {
+ ui.add(
+ egui::Slider::new(&mut self.s.dictation_silence_seconds, 0.6..=5.0)
+ .text("Silence delay (seconds)"),
+ );
+ }
}
fn uninstall_button(&mut self, ui: &mut egui::Ui, label: &str, key: &str) {
if ui
@@ -3878,7 +3963,7 @@ impl App {
self.s.tts_enabled,
egui::Checkbox::new(
&mut self.s.voice_read_aloud,
- "Read aloud AI answers started with the voice shortcut",
+ "Read answers aloud automatically",
),
)
.on_hover_text("Enable text to speech in Models and AI first");
@@ -3890,16 +3975,6 @@ impl App {
&["Brief", "Medium", "Full"],
);
}
- ui.checkbox(
- &mut self.s.dictation_auto_finish,
- "Transcribe automatically after I stop speaking",
- );
- if self.s.dictation_auto_finish {
- ui.add(
- egui::Slider::new(&mut self.s.dictation_silence_seconds, 0.6..=5.0)
- .text("Silence delay (seconds)"),
- );
- }
if self.llm_hotkey_capture || self.voice_hotkey_capture || self.global_voice_capture {
for event in ctx.input(|i| i.events.clone()) {
if let egui::Event::Key {
@@ -4268,6 +4343,8 @@ impl App {
self.dictation_stop = Arc::new(AtomicBool::new(false));
self.dictation_cancel = Arc::new(AtomicBool::new(false));
self.dictation_busy = true;
+ self.query.clear();
+ self.changed();
self.dictation_submit_ai = self.tool == "AI";
if self.smoke.is_some() {
let args = std::env::args().collect::<Vec<_>>();
@@ -6000,7 +6077,11 @@ impl eframe::App for App {
)));
ctx.send_viewport_cmd(egui::ViewportCommand::InnerSize(egui::vec2(
940.0,
- 180.0 + 460.0 * expansion + if panel { 75.0 } else { 0.0 },
+ if self.tool == "AI" {
+ 240.0 + 400.0 * expansion
+ } else {
+ 180.0 + 460.0 * expansion
+ } + if panel { 75.0 } else { 0.0 },
)));
}
} else {
@@ -6469,6 +6550,14 @@ impl eframe::App for App {
&& (self.qa_screenshot.is_none() || self.qa_captured)
{
let mut data = serde_json::json!({"ok":true,"native_rust":true,"tool":self.tool,"tools":self.saved_settings.search_tools(),"footer":self.footer_text(),"dictation_status":self.dictation_status,"query":self.query,"ai_busy":self.ai_busy,"ai_answer":self.ai_answer,"model_loaded":self.engine.models.loaded.load(Ordering::Relaxed),"frames":self.frames,"max_frame_interval_ms":self.max_frame_ms,"dark_mode":ctx.style().visuals.dark_mode,"hidden_reopened":self.qa_hidden_reopened,"ocr_enabled":self.s.ocr_enabled,"ocr_setup_selected":self.ocr_setup,"results":self.hits.len(),"selected":self.selected,"result_scroll_offset":self.result_scroll_offset,"scope":self.scope,"quick_look":self.large_preview,"quick_look_size":self.qa_child_size,"cpu":crate::scheduling::metrics().cpu,"gpu":crate::scheduling::metrics().gpu,"query_focus":ctx.memory(|m|m.has_focus(egui::Id::new("query"))),"ai_metrics":self.ai_metrics.label(),"tts_busy":self.tts_busy,"tts_paused":self.tts_paused.load(Ordering::Acquire),"connection_results":self.connections.iter().map(|s|s.result.as_ref().map(|r|r.is_ok())).collect::<Vec<_>>(),"ai_scroll_offset":self.ai_scroll_offset,"qa_ai_scroll_before":self.qa_ai_scroll_before,"qa_ai_followup_sent":self.qa_ai_followup_sent,"tts_status":self.tts_status,"tts_notice":self.tts_notice,"tts_voices":self.tts_voices,"response_length":self.response_length,"toolbar_top":self.qa_toolbar_top,"filters_top":self.qa_filter_top,"query_selected":egui::text_edit::TextEditState::load(ctx,egui::Id::new("query")).and_then(|s|s.cursor.char_range()).map(|r|r.as_sorted_char_range().len()).unwrap_or(0)});
+ data["source_list"] = serde_json::json!(
+ ctx.data(|d| d.get_temp::<[f32; 2]>(egui::Id::new("qa-inclusion")))
+ );
+ data["exclusion_list"] = serde_json::json!(
+ ctx.data(|d| d.get_temp::<[f32; 2]>(egui::Id::new("qa-exclusion")))
+ );
+ data["window_size"] =
+ serde_json::json!([ctx.content_rect().width(), ctx.content_rect().height()]);
data["category"] = serde_json::json!(self.category);
data["remote_context"] = serde_json::json!(self.s.remote_context);
data["llm_context"] = serde_json::json!(self.s.llm_context);
diff --git a/native/src/config.rs b/native/src/config.rs
index f7cefbc..3016fa8 100644
--- a/native/src/config.rs
+++ b/native/src/config.rs
@@ -602,6 +602,9 @@ impl Settings {
if self.hardware == "CPU / system RAM" {
return "cpu";
}
+ if self.hardware == "Integrated GPU" {
+ return "vulkan";
+ }
match self.runtime_backend.as_str() {
"CUDA" => "cuda-",
"Vulkan" => "vulkan",
@@ -811,6 +814,18 @@ mod migration_tests {
mod restored_settings_tests {
use super::*;
#[test]
+ fn integrated_gpu_does_not_reuse_cached_cuda_device_backend() {
+ let s = Settings {
+ hardware: "Integrated GPU".into(),
+ device: "CUDA0".into(),
+ runtime_backend: "Auto".into(),
+ server: "runtime-cuda/llama-server.exe".into(),
+ ..Default::default()
+ };
+ assert_eq!(s.backend(), "vulkan");
+ assert!(!s.runtime_compatible());
+ }
+ #[test]
fn nvidia_backend_not_vulkan_default() {
let mut s = Settings::default();
s.hardware = "Dedicated GPU".into();
diff --git a/native/src/dictation.rs b/native/src/dictation.rs
index 5973f82..1cb398a 100644
--- a/native/src/dictation.rs
+++ b/native/src/dictation.rs
@@ -432,8 +432,8 @@ pub fn run(
}))
},
};
- activation_sound();
stream.play()?;
+ activation_sound();
RECORDING.store(true, Ordering::Release);
let recording = Recording;
state("Recording");
@@ -746,11 +746,11 @@ fn activation_sound() {
use windows::{Win32::Media::Audio::*, core::PCWSTR};
static SOUND: std::sync::OnceLock<Vec<u8>> = std::sync::OnceLock::new();
let sound = SOUND.get_or_init(activation_wave);
- // Finish the two-note cue before capture so it cannot trigger speech endpointing.
+ // Static storage keeps the async cue alive without delaying microphone capture.
let _ = PlaySoundW(
PCWSTR(sound.as_ptr().cast()),
None,
- SND_MEMORY | SND_SYNC | SND_NODEFAULT | SND_NOSTOP,
+ SND_MEMORY | SND_ASYNC | SND_NODEFAULT | SND_NOSTOP,
);
}
}
diff --git a/native/src/launcher.rs b/native/src/launcher.rs
index d3dab80..6b49517 100644
--- a/native/src/launcher.rs
+++ b/native/src/launcher.rs
@@ -678,16 +678,13 @@ mod semantic_clipboard_tests {
..Default::default()
};
let thread = std::thread::spawn(move || {
- for _ in 0..3 {
+ for _ in 0..2 {
let request = server
.recv_timeout(std::time::Duration::from_secs(10))
.unwrap()
.expect("embedding request");
- let body = if request.url() == "/props" {
- r#"{"media_marker":"<__image__>"}"#
- } else {
- r#"{"data":[{"index":0,"embedding":[1,0]}]}"#
- };
+ assert_eq!(request.url(), "/v1/embeddings");
+ let body = r#"{"data":[{"index":0,"embedding":[1,0]}]}"#;
request
.respond(tiny_http::Response::from_string(body))
.unwrap();
diff --git a/native/src/models.rs b/native/src/models.rs
index b3b1799..a1b552b 100644
--- a/native/src/models.rs
+++ b/native/src/models.rs
@@ -1,6 +1,5 @@
use crate::{config::Settings, content::Segment};
use anyhow::{Context, Result};
-use base64::{Engine, engine::general_purpose::STANDARD};
use serde_json::{Value, json};
use std::{
process::{Child, Command, Stdio},
@@ -332,39 +331,6 @@ impl Models {
std::thread::sleep(Duration::from_millis(100));
}
}
- fn marker(&self, s: &Settings) -> Result<String> {
- let key = format!(
- "{}|{}|{}",
- Self::url(s),
- s.projector,
- if s.remote_embeddings() {
- s.remote_model.as_str()
- } else {
- ""
- }
- );
- if let Some((_, marker)) = self
- .inner
- .lock()
- .map_err(|_| anyhow::anyhow!("Model state unavailable"))?
- .marker
- .as_ref()
- .filter(|(k, _)| k == &key)
- {
- return Ok(marker.clone());
- }
- let mut req = self.agent.get(crate::ai::endpoint(&Self::url(s), "props")?);
- if s.remote_embeddings() && !s.remote_key.is_empty() {
- req = req.header("Authorization", format!("Bearer {}", s.remote_key));
- }
- let props: Value = req.call()?.body_mut().read_json()?;
- let marker=props["media_marker"].as_str().context("This server lacks multimodal embeddings; update llama-server and select its matching encoder")?.to_string();
- self.inner
- .lock()
- .map_err(|_| anyhow::anyhow!("Model state unavailable"))?
- .marker = Some((key, marker.clone()));
- Ok(marker)
- }
fn post(&self, s: &Settings, input: Value) -> Result<Vec<Vec<f32>>> {
let url = Self::url(s);
anyhow::ensure!(
@@ -503,8 +469,7 @@ impl Models {
let segment = &segments[index];
if !segment.media.is_empty() {
self.ensure(s, true)?;
- let marker = self.marker(s)?;
- let v=self.post(s,json!({"prompt_string":marker,"multimodal_data":[STANDARD.encode(&segment.media)]}))?;
+ let v = self.post(s, crate::remote::media_input(&segment.media))?;
out.push(v.into_iter().next().context("Missing media embedding")?);
index += 1;
} else {
@@ -755,3 +720,58 @@ mod search_session_tests {
models.stop().unwrap();
}
}
+
+#[cfg(test)]
+mod typed_media_tests {
+ use super::*;
+ #[test]
+ fn media_indexing_routes_model_and_auth_without_legacy_props() {
+ let server = tiny_http::Server::http("127.0.0.1:0").unwrap();
+ let settings = Settings {
+ embedding_server: "Remote".into(),
+ remote_url: format!("http://{}/v1", server.server_addr()),
+ remote_model: "embeddinggemma2".into(),
+ remote_key: "test-key".into(),
+ ..Default::default()
+ };
+ let task = std::thread::spawn(move || {
+ for media_type in ["image_url", "input_audio"] {
+ let mut req = server.recv().unwrap();
+ assert_eq!(req.url(), "/v1/embeddings");
+ assert!(req.headers().iter().any(
+ |h| h.field.equiv("Authorization") && h.value.as_str() == "Bearer test-key"
+ ));
+ let mut body = String::new();
+ req.as_reader().read_to_string(&mut body).unwrap();
+ let body: Value = serde_json::from_str(&body).unwrap();
+ assert_eq!(body["model"], "embeddinggemma2");
+ assert_eq!(body["input"][0]["content"][0]["type"], media_type);
+ req.respond(
+ tiny_http::Response::from_string(
+ json!({"data":[{"embedding":[0.1,0.2]}]}).to_string(),
+ )
+ .with_header(
+ tiny_http::Header::from_bytes("Content-Type", "application/json").unwrap(),
+ ),
+ )
+ .unwrap();
+ }
+ });
+ let segments = [b"\xff\xd8image".to_vec(), b"RIFFaudioWAVE".to_vec()]
+ .into_iter()
+ .map(|media| Segment {
+ media,
+ kind: "image".into(),
+ text: String::new(),
+ page: 0,
+ seconds: 0.0,
+ line: 0,
+ })
+ .collect::<Vec<_>>();
+ let vectors = Models::default()
+ .segments(&settings, &segments, &|| Ok(()))
+ .unwrap();
+ assert_eq!(vectors.len(), 2);
+ task.join().unwrap();
+ }
+}
diff --git a/native/src/remote.rs b/native/src/remote.rs
index c5fc759..5210abe 100644
--- a/native/src/remote.rs
+++ b/native/src/remote.rs
@@ -23,6 +23,73 @@ pub fn api(base: &str, path: &str) -> Result<String> {
path,
)
}
+/// llama.cpp's current multimodal embedding API nests typed parts in each input.
+/// Do not require /props.media_marker: model routers need not expose that legacy field.
+pub fn media_input(media: &[u8]) -> Value {
+ use base64::{Engine, engine::general_purpose::STANDARD};
+ let encoded = STANDARD.encode(media);
+ let part = if media.starts_with(b"RIFF") || media.starts_with(b"fLaC") {
+ json!({"type":"input_audio","input_audio":{"data":encoded}})
+ } else {
+ let mime = if media.starts_with(b"\x89PNG") {
+ "image/png"
+ } else {
+ "image/jpeg"
+ };
+ json!({"type":"image_url","image_url":{"url":format!("data:{mime};base64,{encoded}")}})
+ };
+ json!([{"content":[part]}])
+}
+fn probe_images() -> Result<Value> {
+ let mut inputs = vec![];
+ for color in [[220u8, 20, 20], [20u8, 20, 220]] {
+ let image = image::RgbImage::from_pixel(32, 32, image::Rgb(color));
+ let mut png = std::io::Cursor::new(Vec::new());
+ image.write_to(&mut png, image::ImageFormat::Png)?;
+ inputs.push(media_input(png.get_ref())[0].clone());
+ }
+ Ok(Value::Array(inputs))
+}
+fn validate_image_probe(value: &Value, dimensions: usize) -> Result<()> {
+ let vectors = value["data"]
+ .as_array()
+ .context("Image test returned no embeddings")?;
+ anyhow::ensure!(
+ vectors.len() == 2,
+ "Image test needs one embedding per image"
+ );
+ let mut parsed = Vec::new();
+ for vector in vectors {
+ let entries = vector["embedding"]
+ .as_array()
+ .context("Image test returned an invalid vector")?;
+ anyhow::ensure!(
+ entries.len() == dimensions,
+ "Image and text embedding dimensions differ"
+ );
+ let values = entries
+ .iter()
+ .map(|v| {
+ v.as_f64()
+ .filter(|v| v.is_finite())
+ .context("Invalid image embedding value")
+ })
+ .collect::<Result<Vec<_>>>()?;
+ let norm = values.iter().map(|v| v * v).sum::<f64>().sqrt();
+ anyhow::ensure!(norm > 0.0, "Image test returned an empty vector");
+ parsed.push(values.into_iter().map(|v| v / norm).collect::<Vec<_>>());
+ }
+ let difference = parsed[0]
+ .iter()
+ .zip(&parsed[1])
+ .map(|(a, b)| (a - b).powi(2))
+ .sum::<f64>();
+ anyhow::ensure!(
+ difference > 1e-10,
+ "Server ignored image content (different images produced identical embeddings)"
+ );
+ Ok(())
+}
fn client() -> Result<reqwest::Client> {
Ok(reqwest::Client::builder()
.connect_timeout(Duration::from_secs(5))
@@ -224,11 +291,31 @@ fn catalog_inner(
}
}
if check_embeddings {
- note.push_str(match vision {
- Some(true) => " · mmproj detected (vision ready)",
- Some(false) => " · mmproj not detected (vision unavailable)",
- None => " · mmproj not detected: server did not report vision support",
- });
+ let reported = vision;
+ if reported != Some(false) {
+ let probe = async {
+ let mut req = client.post(api(base, "embeddings")?)
+ .json(&json!({"model":model,"input":probe_images()?}));
+ if !key.trim().is_empty() { req = req.bearer_auth(key.trim()); }
+ let value = json_response(req.send().await?).await?;
+ validate_image_probe(&value, dimensions.unwrap_or(0))
+ }.await;
+ match probe {
+ Ok(()) => {
+ vision = Some(true);
+ note.push_str(" · image embeddings verified");
+ if reported == Some(true) { note.push_str(" · mmproj detected"); }
+ },
+ Err(error) => {
+ vision = Some(false);
+ if reported == Some(true) { note.push_str(" · mmproj reported, but image embeddings failed"); }
+ else { note.push_str(" · image embeddings unavailable"); }
+ note.push_str(&format!(": {}", error.to_string().chars().take(250).collect::<String>()));
+ }
+ }
+ } else {
+ note.push_str(" · mmproj not detected (vision unavailable)");
+ }
if dimensions.is_some_and(|d| d < 768) {
note.push_str(
" · Warning: fewer than 768 dimensions; retrieval quality may be reduced",
@@ -415,15 +502,22 @@ mod capability_tests {
let server = tiny_http::Server::http("127.0.0.1:0").unwrap();
let url = format!("http://{}/v1", server.server_addr());
let task = std::thread::spawn(move || {
- for n in 0..3 {
+ for n in 0..if vision { 4 } else { 3 } {
let mut req = server.recv().unwrap();
let value = match n {
0 => json!({"data":[{"id":"embedding","max_context_length":8192}]}),
1 => json!({"data":[{"embedding":[0.1,0.2]}]}),
- _ => {
+ 2 => {
assert_eq!(req.url(), "/props?model=embedding&autoload=false");
json!({"default_generation_settings":{"n_ctx":2048},"modalities":{"vision":vision}})
}
+ _ => {
+ let mut body = String::new();
+ req.as_reader().read_to_string(&mut body).unwrap();
+ let body: Value = serde_json::from_str(&body).unwrap();
+ assert_eq!(body["input"][0]["content"][0]["type"], "image_url");
+ json!({"data":[{"embedding":[1.0,0.0]},{"embedding":[0.0,1.0]}]})
+ }
};
req.respond(
tiny_http::Response::from_string(value.to_string()).with_header(
@@ -447,3 +541,32 @@ mod capability_tests {
}
}
}
+
+#[cfg(test)]
+mod media_tests {
+ use super::*;
+ #[test]
+ fn vision_probe_rejects_ignored_images_and_mismatched_dimensions() {
+ assert!(
+ validate_image_probe(
+ &json!({"data":[{"embedding":[1.0,0.0]},{"embedding":[1.0,0.0]}]}),
+ 2
+ )
+ .is_err()
+ );
+ assert!(
+ validate_image_probe(
+ &json!({"data":[{"embedding":[1.0]},{"embedding":[0.0,1.0]}]}),
+ 2
+ )
+ .is_err()
+ );
+ assert!(
+ validate_image_probe(
+ &json!({"data":[{"embedding":[1.0,0.0]},{"embedding":[0.0,1.0]}]}),
+ 2
+ )
+ .is_ok()
+ );
+ }
+}
diff --git a/packaging/VectorDash-Rust.iss b/packaging/VectorDash-Rust.iss
index 65ea040..caf385e 100644
--- a/packaging/VectorDash-Rust.iss
+++ b/packaging/VectorDash-Rust.iss
@@ -3,7 +3,7 @@ AppId={{C6AC1B4D-A119-4D73-B2C8-6C507DEFE923}
AppName=VectorDash
AppVerName=VectorDash
UninstallDisplayName=VectorDash
-AppVersion=0.3.22
+AppVersion=0.3.23
AppPublisher=VectorDash contributors
AppPublisherURL=https://github.com/ampersandru/VectorDash
DefaultDirName={localappdata}\Programs\VectorDash
@@ -13,7 +13,7 @@ ArchitecturesAllowed=x64compatible
ArchitecturesInstallIn64BitMode=x64compatible
MinVersion=10.0.22000
OutputDir=..\dist\installer
-OutputBaseFilename=VectorDash-Rust-Setup-0.3.22-x64
+OutputBaseFilename=VectorDash-Rust-Setup-0.3.23-x64
SetupIconFile=VectorDash.ico
UninstallDisplayIcon={app}\VectorDash.exe
LicenseFile=..\LICENSE