Preserve explicit code candidates and expose verified model asset milestones
This commit is contained in:
1 parent
6e05227f53
commit
e28e20af38
9 files changed
+475
-16
No files matched your search
@@ -22,7 +22,7 @@ impl SemanticOrigin {
|
||||
}
|
||||
|
||||
/// A conservative intent hint, not a language understanding model. Explicit
|
||||
/// document/visual cues veto it; ordinary topic and instrument queries do not
|
||||
/// document/visual/code cues veto it; ordinary topic and instrument queries do not
|
||||
/// silently restrict modality. Word boundaries avoid filename substrings.
|
||||
fn preferred_origin(query: &str) -> Option<SemanticOrigin> {
|
||||
if query.split_whitespace().count() == 1 && Path::new(query).extension().is_some() {
|
||||
@@ -49,6 +49,12 @@ fn preferred_origin(query: &str) -> Option<SemanticOrigin> {
|
||||
"screenshot",
|
||||
"dokument",
|
||||
"textdatei",
|
||||
"code",
|
||||
"function",
|
||||
"implementation",
|
||||
"quellcode",
|
||||
"funktion",
|
||||
"implementierung",
|
||||
]) {
|
||||
return None;
|
||||
}
|
||||
@@ -211,6 +217,12 @@ mod tests {
|
||||
"a document that someone mentioned",
|
||||
"speech.png",
|
||||
"a screenshot of an audio waveform",
|
||||
"code that chooses audio search when a query mentions speech",
|
||||
"an implementation for identifying music",
|
||||
"a function that decodes audio samples",
|
||||
"Quellcode für die Suche nach gesprochenen Themen",
|
||||
"eine Funktion für die Verarbeitung von Musik",
|
||||
"Implementierung für die Erkennung von Geräuschen",
|
||||
] {
|
||||
assert_eq!(preferred_origin(query), None, "{query}");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
use anyhow::Result;
|
||||
use searchi_core::SearchIndex;
|
||||
use searchi_service::{FfmpegTools, HybridSearch, MediaLimits, SearchOptions, SemanticOrigin};
|
||||
use std::{fs, path::PathBuf};
|
||||
|
||||
#[test]
|
||||
#[ignore = "Requires verified Google CPU worker/model and FFmpeg fixtures"]
|
||||
fn explicit_code_intent_preserves_code_among_real_audio_candidates() -> Result<()> {
|
||||
assert_eq!(std::env::var("SEARCHI_FORCE_CPU")?, "1");
|
||||
let model = std::env::var_os("SEARCHI_GEMMA_MODEL_DIR").expect("Set model directory");
|
||||
let worker = std::env::var_os("SEARCHI_GEMMA_WORKER").expect("Set worker path");
|
||||
let tools = FfmpegTools {
|
||||
ffmpeg: std::env::var_os("SEARCHI_TEST_FFMPEG")
|
||||
.expect("Set FFmpeg")
|
||||
.into(),
|
||||
ffprobe: std::env::var_os("SEARCHI_TEST_FFPROBE")
|
||||
.expect("Set FFprobe")
|
||||
.into(),
|
||||
};
|
||||
let fixture = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../fixtures");
|
||||
let temp = tempfile::tempdir()?;
|
||||
let corpus = temp.path().join("corpus");
|
||||
fs::create_dir(&corpus)?;
|
||||
// Preserve the unchanged diagnostic implementation and actual licensed sound.
|
||||
fs::copy(
|
||||
fixture.join("mixed/sources/crates__searchi-service__src__routing.rs"),
|
||||
corpus.join("routing.rs"),
|
||||
)?;
|
||||
fs::copy(
|
||||
fixture.join("media/assets/sound02.mp3"),
|
||||
corpus.join("sound.mp3"),
|
||||
)?;
|
||||
let database = temp.path().join("index.db");
|
||||
let mut lexical = SearchIndex::open(&database)?;
|
||||
lexical.index_folder(&corpus)?;
|
||||
let mut indexer = HybridSearch::open(&database, &model, &worker, 1)?;
|
||||
let report = indexer.index_embeddings_with_media(&tools, &MediaLimits::default())?;
|
||||
assert!(report.failures.is_empty(), "{report:?}");
|
||||
assert_eq!(report.media_files, 1);
|
||||
drop(indexer);
|
||||
let mut search = HybridSearch::open_query(&database, &model, &worker, 1)?;
|
||||
let query = "code that chooses audio search when a query mentions speech";
|
||||
let options = SearchOptions::default();
|
||||
let audio = search.search_semantic_with_origin(query, 20, &options, SemanticOrigin::Audio)?;
|
||||
assert!(
|
||||
!audio.is_empty(),
|
||||
"The old exclusive audio lane must qualify"
|
||||
);
|
||||
assert!(audio.iter().all(|hit| hit.filename == "sound.mp3"));
|
||||
let hits = search.search_semantic(query, 20, &options)?;
|
||||
assert!(
|
||||
hits.iter().any(|hit| hit.filename == "routing.rs"),
|
||||
"Explicit code intent lost its semantic implementation: {hits:?}"
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
Reference in new issue
Block a user