alith_core/
knowledge.rs

1use crate::chunking::Chunker;
2use std::path::PathBuf;
3
4pub trait Knowledge: Chunker {
5    /// Load the content into the memory.
6    fn load(&self) -> Result<String, KnowledgeError>;
7    /// Enrich the knowledge with the input string.
8    fn enrich(&self, input: &str) -> Result<String, KnowledgeError>;
9}
10
11pub trait FileKnowledge: Knowledge {
12    fn load_with_path(&self) -> Result<(PathBuf, String), KnowledgeError>;
13}
14
15#[derive(Debug, thiserror::Error)]
16#[error("Knowledge error")]
17pub enum KnowledgeError {
18    #[error("Failed to load the knowledge source: {0}")]
19    LoadError(String),
20    #[error("An unknown error occurred: {0}")]
21    Unknown(String),
22    #[error("IO error: {0}")]
23    IoError(#[from] std::io::Error),
24}