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