Ship floating launcher, automatic discovery and bounded media search improvements
This commit is contained in:
1 parent
01279a6b25
commit
521966a2ac
43 files changed
+3165
-267
No files matched your search
@@ -3,6 +3,69 @@ 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_media_requests_do_not_fall_back_to_unrelated_channels() -> 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/media/assets/image01.jpg");
|
||||
let temp = tempfile::tempdir()?;
|
||||
let corpus = temp.path().join("corpus");
|
||||
fs::create_dir(&corpus)?;
|
||||
fs::copy(fixture, corpus.join("cat.jpg"))?;
|
||||
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 options = SearchOptions::default();
|
||||
// The unfiltered real model does return the nearest photo for these requests.
|
||||
// The correction rejects its wrong channel, not its similarity score.
|
||||
for query in [
|
||||
"music with violin",
|
||||
"audio of thunder",
|
||||
"someone mentions a contract",
|
||||
"video of a boat",
|
||||
"Musik mit Klavier",
|
||||
"Film mit einem Wasserfall",
|
||||
] {
|
||||
assert!(
|
||||
!search
|
||||
.search_semantic_with_origin(query, 10, &options, SemanticOrigin::All)?
|
||||
.is_empty(),
|
||||
"{query}"
|
||||
);
|
||||
assert!(
|
||||
search.search_semantic(query, 10, &options)?.is_empty(),
|
||||
"{query}"
|
||||
);
|
||||
}
|
||||
for query in ["photo of a cat indoors", "Bild einer Katze", "cat indoors"] {
|
||||
let hits = search.search_semantic(query, 10, &options)?;
|
||||
assert_eq!(hits[0].filename, "cat.jpg", "{query}");
|
||||
assert_eq!(hits[0].match_kind, "semantic_image", "{query}");
|
||||
}
|
||||
assert_eq!(
|
||||
search.search("cat.jpg", 1, &options)?[0].match_kind,
|
||||
"exact_filename"
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "Requires verified Google CPU worker/model and FFmpeg fixtures"]
|
||||
fn explicit_code_intent_preserves_code_among_real_audio_candidates() -> Result<()> {
|
||||
|
||||
Reference in new issue
Block a user