Skip to content

Commit 55f67ad

Browse files
committed
feat(search): wire intelligence models into CLI search path
run_search now loads orchestrator + reranker when intelligence is enabled and calls search_with_intelligence instead of search_internal.
1 parent f55dd85 commit 55f67ad

1 file changed

Lines changed: 38 additions & 1 deletion

File tree

src/search.rs

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,44 @@ pub fn run_search(
322322
let db_path = data_dir.join("engraph.db");
323323
let store = Store::open(&db_path).context("opening store")?;
324324

325-
let output = search_internal(query, top_n, &store, &mut embedder)?;
325+
// Load intelligence models if enabled.
326+
let mut orchestrator_model: Option<Box<dyn llm::OrchestratorModel>> =
327+
if config.intelligence_enabled() {
328+
match crate::llm::LlamaOrchestrator::new(&models_dir, config) {
329+
Ok(o) => Some(Box::new(o)),
330+
Err(e) => {
331+
tracing::warn!("failed to load orchestrator: {e}");
332+
None
333+
}
334+
}
335+
} else {
336+
None
337+
};
338+
let mut reranker_model: Option<Box<dyn llm::RerankModel>> = if config.intelligence_enabled() {
339+
match crate::llm::LlamaRerank::new(&models_dir, config) {
340+
Ok(r) => Some(Box::new(r)),
341+
Err(e) => {
342+
tracing::warn!("failed to load reranker: {e}");
343+
None
344+
}
345+
}
346+
} else {
347+
None
348+
};
349+
350+
let output = {
351+
let mut search_config = SearchConfig {
352+
orchestrator: orchestrator_model
353+
.as_mut()
354+
.map(|o| o.as_mut() as &mut dyn llm::OrchestratorModel),
355+
reranker: reranker_model
356+
.as_mut()
357+
.map(|r| r.as_mut() as &mut dyn llm::RerankModel),
358+
store: &store,
359+
rerank_candidates: 30,
360+
};
361+
search_with_intelligence(query, top_n, &mut embedder, &mut search_config)?
362+
};
326363

327364
let results: Vec<SearchResult> = output
328365
.results

0 commit comments

Comments
 (0)