knowledge

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 5 Imported by: 0

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

func (*VectorKnowledge) Load

func (v *VectorKnowledge) Load(ctx context.Context) error

Load creates the collection and indexes all queued documents.

func (*VectorKnowledge) Search

func (v *VectorKnowledge) Search(ctx context.Context, query string, topK int) ([]Document, error)

Search embeds the query and performs similarity search.

Directories

Path Synopsis
Package loaders provides document loaders for different file formats.
Package loaders provides document loaders for different file formats.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL