Skip to main content

innate_core/
lib.rs

1pub mod cli;
2pub mod daemon;
3pub mod embedding;
4pub mod errors;
5pub mod install;
6pub mod kb;
7pub mod llm;
8pub mod mcp;
9pub mod migrate;
10pub mod refine;
11pub mod settings;
12pub mod storage;
13pub mod upgrade;
14pub mod utils;
15
16#[cfg(test)]
17mod tests;
18
19pub use errors::{InnateError, Result};
20pub use kb::{CurateReport, KnowledgeBase, RecallResult};
21
22/// Open a KnowledgeBase at `db_path`, injecting LLM providers from `~/.innate/settings.json`
23/// if configured. Falls back to DummyEmbeddingProvider + HeuristicDistiller when no LLM
24/// settings are present.
25pub fn open_kb(db_path: impl AsRef<std::path::Path>) -> Result<KnowledgeBase> {
26    use std::sync::Arc;
27    let s = settings::load();
28
29    let embedding: Option<Arc<dyn embedding::EmbeddingProvider>> = s
30        .embedding
31        .as_ref()
32        .map(|c| Arc::new(llm::LlmEmbeddingProvider::new(c.clone())) as Arc<dyn embedding::EmbeddingProvider>);
33
34    let distiller: Option<Arc<dyn refine::Distiller>> = s
35        .llm
36        .as_ref()
37        .map(|c| llm::build_distiller(c) as Arc<dyn refine::Distiller>);
38
39    KnowledgeBase::open_with(db_path, embedding, None, distiller, None, None)
40}