Skip to main content

innate_core/
lib.rs

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