Documentation
¶
Overview ¶
Package rag provides lexical retrieval over the bundled PromptZero documentation corpus. The agent uses it to ground tool arguments in authoritative reference material (cheat sheets, scenario recipes, tool documentation) without shipping an embedding provider or a separate retrieval service.
This is the lexical half of a future hybrid retrieval stack. BM25 covers rare-term queries where a dense embedding model would over-generalise — "OOK650Async", "ATQA", "T5577", "NTAG215" are all exact terms the operator will use verbatim, and BM25 rewards that. A dense-embedding layer and a cross-encoder reranker can be added later without changing this package's public surface; the hybrid merger simply interleaves results from both retrievers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Snippet ¶
Snippet renders a short excerpt of the document body around the first matching query term, up to maxLen characters. Falls back to the opening of the body when no query term is present (e.g. when the caller scored on title-only matches). Intended for shaping the search result payload the model sees.
Types ¶
type Document ¶
Document is one indexed unit. A document can be a full markdown file or a paragraph-sized chunk; the indexer doesn't care. Title is shown in result snippets; Source is the original path so the agent can read the full file if it wants more context.
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
Index is the immutable BM25 retriever. Build once at startup; Search is read-only and safe for concurrent use.
func BuildIndex ¶
BuildIndex tokenises each document and precomputes term-frequency statistics. Runs in one pass over the corpus.
func DefaultIndex ¶
func DefaultIndex() *Index
DefaultIndex builds an index over the bundled documentation corpus. Returns an empty index if the embed FS is unexpectedly missing files (keeps the tool path fail-closed — no panics at startup).