pub struct Knowledge { /* private fields */ }Expand description
A folder an agent can search: Knowledge::dir("docs") plus settings.
At build the folder is ingested into index index of the store file
(unchanged files skipped) and the agent gets the search_knowledge
tool. The embedder defaults to the catalog’s for the agent’s vendor.
Implementations§
Source§impl Knowledge
impl Knowledge
Sourcepub fn dir(dir: impl AsRef<Path>) -> Self
pub fn dir(dir: impl AsRef<Path>) -> Self
Starts settings for folder dir, read at build.
Index docs, the agent’s SQLite checkpoint file or
./troupekit.db, and the ingest_dir walk and chunk defaults.
Sourcepub fn index(self, index: impl Into<String>) -> Self
pub fn index(self, index: impl Into<String>) -> Self
Sets the vector index and scope the folder is stored under.
1 to 64 of [a-z0-9_], checked at build.
Default docs.
Sourcepub fn store(self, path: impl AsRef<Path>) -> Self
pub fn store(self, path: impl AsRef<Path>) -> Self
Sets the SQLite file the index lives in.
Default: the agent’s Storage::sqlite file, else ./troupekit.db.
Returns the settings.
Sourcepub fn embedder(self, embedder: Arc<dyn Embedder>) -> Self
pub fn embedder(self, embedder: Arc<dyn Embedder>) -> Self
Sets the embedder for the folder and for searches, overriding the catalog embedder of the agent’s vendor; dimensions must match an existing index of the same name. Returns the settings.
Sourcepub fn on_device_embedder(self, embedder: Arc<dyn Embedder>) -> Self
pub fn on_device_embedder(self, embedder: Arc<dyn Embedder>) -> Self
Sets an embedder that runs on the device, with no network, and
marks it so: a private agent accepts only such an embedder.
Otherwise the same as embedder.
Sourcepub fn local_embedder(self, choice: impl Into<LocalChoice>) -> Self
pub fn local_embedder(self, choice: impl Into<LocalChoice>) -> Self
Embeds on the device with a local model: a catalog id, a GGUF
file or a loaded Arc<dyn LocalModel>, loaded at build like
Agent::local. Marks the embedder on-device for private agents.
Sourcepub fn load(self, load: LoadSettings) -> Self
pub fn load(self, load: LoadSettings) -> Self
Sets the folder walk bounds and filters.
Default LoadSettings::default().
Returns the settings.
Sourcepub fn chunk(self, chunk: ChunkConfig) -> Self
pub fn chunk(self, chunk: ChunkConfig) -> Self
Sets the chunk size and overlap, in estimated tokens. Default 200 tokens with 20 of overlap. Returns the settings.