Documentation
¶
Overview ¶
Package knowledge provides a RAG knowledge base abstraction inspired by Agno's Knowledge protocol.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Document ¶
type Document struct {
ID string `json:"id"`
Content string `json:"content"`
Metadata map[string]any `json:"metadata,omitempty"`
Score float32 `json:"score,omitempty"`
}
Document represents a retrieved knowledge document.
type Knowledge ¶
type Knowledge interface {
// Load indexes all documents into the underlying store. Idempotent.
Load(ctx context.Context) error
// Search returns the top-k most relevant documents for the query.
Search(ctx context.Context, query string, topK int) ([]Document, error)
// Close releases resources.
Close() error
}
Knowledge is the interface for pluggable knowledge sources. Implementations load documents, index them, and serve similarity searches.
type VectorKnowledge ¶
type VectorKnowledge struct {
Collection string
Dimension int
Store storage.VectorStore
Embedder model.EmbeddingsProvider
EmbedModel string
// contains filtered or unexported fields
}
VectorKnowledge implements Knowledge backed by a VectorStore and EmbeddingsProvider.
func NewVectorKnowledge ¶
func NewVectorKnowledge(collection string, dimension int, store storage.VectorStore, embedder model.EmbeddingsProvider, embedModel string) *VectorKnowledge
NewVectorKnowledge creates a vector-backed knowledge base.
func (*VectorKnowledge) AddDocuments ¶
func (v *VectorKnowledge) AddDocuments(docs ...Document)
AddDocuments queues documents for indexing on next Load() call.
func (*VectorKnowledge) Close ¶
func (v *VectorKnowledge) Close() error
Click to show internal directories.
Click to hide internal directories.