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