Skip to main content

Module knowledge

Module knowledge 

Source
Expand description

Ingest a folder into a named vector index in the store file. Unchanged files are skipped by content hash, changed files are replaced whole, a file that fails is recorded and the walk goes on, and the sources of files gone from the folder are removed.

Structs§

ChunkConfig
Size limits for chunk, in estimated tokens of four chars each. max_tokens bounds every chunk; overlap_tokens is how much of a chunk’s end is repeated at the start of the next one, and must be below max_tokens.
IngestReport
What one ingest_dir call did: files added, replaced and skipped as unchanged, sources removed because their file is gone, files the walk passed over (unsupported, symlinks), failed files with their error, and the chunks written.
IngestSettings
Settings for ingest_dir. Defaults: scope docs, chunks of 200 tokens with 20 of overlap, the safe folder walk of LoadSettings and Origin::External, so folder text is fenced as untrusted in prompts. A run never removes more than half the scope, or all of it from an empty folder, unless allowed. Changed origin or chunk config re-ingests.
Knowledge
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.
LoadSettings
Bounds and filters of a folder walk. Every field has a safe default: the five text extensions, 10 000 files, 8 MiB per file, depth 16, 100 000 directory entries, symlinks not followed, hidden entries skipped. Built with Default and the with_* setters.

Traits§

Embedder
Turns texts into fixed-length vectors for a VectorStore. Object safe, so the model can be chosen at runtime as Arc<dyn Embedder>. embed returns one vector of dims() floats per input text, in order.

Functions§

ingest_dir
Ingests every loadable file under dir into vectors: unchanged files are skipped, others swapped in with replace_source, and after a complete walk a source is removed only when its file is gone from disk, checked again just before removal; filtered-out files stay. Output: the report, or an error for a walk cap, a blank scope or a store write that fails.