Documentation
¶
Overview ¶
Package corpus provides a reference memory.Retriever over a fixed set of documents — a knowledge base the host supplies, deliberately separate from the memory.Store the memory tools read and write.
That separation is the point. The two retrieval paths in PromptKit answer different questions:
- The memory tools (memory__remember / memory__recall) let the model manage facts about the *subject* — what the user told it to remember. The model decides when to look, and the store is scoped per subject.
- Ambient injection asks a corpus what is relevant to *this turn* and puts the answer in the system prompt before the model runs. The model never decides; it simply sees grounding it did not have to ask for.
Pointing ambient injection at the memory store would collapse the two into one confusing path — the model would find the same rows twice, once by asking and once without. Retrieval for grounding belongs over the host's own content: documentation, a product catalog, a support knowledge base.
This implementation scores documents by term overlap with the latest user turn. That is enough to develop and test against, and deliberately not a search engine: production hosts implement memory.Retriever against a vector index or a real search backend.
Index ¶
Constants ¶
const ( // MemoryType is the [memory.Memory] Type given to every retrieved // document, so a context formatter (or a host reading the injected set) // can tell grounding documents apart from remembered facts. MemoryType = "document" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Document ¶
type Document struct {
// ID identifies the document; it is carried onto the retrieved
// memory so a prompt can cite it.
ID string
// Title is a human-readable label, surfaced in metadata.
Title string
// Text is the content injected into the prompt.
Text string
}
Document is one unit of retrievable host content.
type Retriever ¶
type Retriever struct {
// contains filtered or unexported fields
}
Retriever answers ambient-injection queries from a fixed document set.
func (*Retriever) RetrieveContext ¶
func (r *Retriever) RetrieveContext( _ context.Context, _ map[string]string, messages []types.Message, ) ([]*memory.Memory, error)
RetrieveContext implements memory.Retriever. The query is the latest user turn — what the assistant is about to answer.
A turn with no user text, or one sharing no term with any document, returns nothing rather than everything: injecting an unrelated document is worse than injecting none, because the model cannot tell that it was not chosen.