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
@@ -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