knowledge

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultChunkMaxRunes     = 1200
	DefaultChunkOverlapRunes = 120
)
View Source
const DefaultIndexBatchSize = 32

Variables

This section is empty.

Functions

This section is empty.

Types

type Chunker

type Chunker interface {
	Split(document Document) ([]Document, error)
}

type Citation

type Citation struct {
	ID         string `json:"id"`
	ParentID   string `json:"parent_id,omitempty"`
	Source     string `json:"source,omitempty"`
	Title      string `json:"title,omitempty"`
	URL        string `json:"url,omitempty"`
	ChunkIndex string `json:"chunk_index,omitempty"`
	ChunkStart string `json:"chunk_start,omitempty"`
	ChunkEnd   string `json:"chunk_end,omitempty"`
}

func CitationFromDocument

func CitationFromDocument(document Document) Citation

type DeleteRequest

type DeleteRequest struct {
	Namespace string `json:"namespace,omitempty"`
	ID        string `json:"id"`
}

type Document

type Document struct {
	ID        string            `json:"id"`
	Content   string            `json:"content"`
	Metadata  map[string]string `json:"metadata,omitempty"`
	Namespace string            `json:"namespace,omitempty"`
}

type DocumentEmbedding

type DocumentEmbedding struct {
	Document Document  `json:"document"`
	Vector   []float32 `json:"vector"`
}

type HybridSearcher

type HybridSearcher interface {
	HybridQuery(ctx context.Context, query Query) ([]SearchResult, error)
}

type IndexResult

type IndexResult struct {
	Documents int `json:"documents"`
	Chunks    int `json:"chunks"`
}

type Indexer

type Indexer struct {
	// contains filtered or unexported fields
}

func NewIndexer

func NewIndexer(config IndexerConfig) (*Indexer, error)

func (*Indexer) Index

func (i *Indexer) Index(ctx context.Context, documents []Document) (IndexResult, error)

type IndexerConfig

type IndexerConfig struct {
	Embedder  llm.Embedder
	Store     VectorStore
	Profile   string
	Namespace string
	BatchSize int
	Chunker   Chunker
}

type Loader

type Loader interface {
	Load(ctx context.Context) ([]Document, error)
}

type Query

type Query struct {
	Namespace    string            `json:"namespace,omitempty"`
	Text         string            `json:"text,omitempty"`
	Mode         SearchMode        `json:"mode,omitempty"`
	Vector       []float32         `json:"vector"`
	Limit        int               `json:"limit,omitempty"`
	Filter       map[string]string `json:"filter,omitempty"`
	VectorWeight float64           `json:"vector_weight,omitempty"`
	TextWeight   float64           `json:"text_weight,omitempty"`
}

type Reranker

type Reranker interface {
	Rerank(ctx context.Context, query string, results []SearchResult) ([]SearchResult, error)
}

type SearchMode

type SearchMode string
const (
	SearchModeVector SearchMode = "vector"
	SearchModeHybrid SearchMode = "hybrid"
)

type SearchResult

type SearchResult struct {
	Document Document `json:"document"`
	Score    float64  `json:"score"`
}

type TextSplitter

type TextSplitter struct {
	// contains filtered or unexported fields
}

func NewTextSplitter

func NewTextSplitter(config TextSplitterConfig) (*TextSplitter, error)

func (*TextSplitter) Split

func (s *TextSplitter) Split(document Document) ([]Document, error)

type TextSplitterConfig

type TextSplitterConfig struct {
	MaxRunes     int
	OverlapRunes int
}

type VectorStore

type VectorStore interface {
	Upsert(ctx context.Context, documents []DocumentEmbedding) error
	Query(ctx context.Context, query Query) ([]SearchResult, error)
	Delete(ctx context.Context, req DeleteRequest) error
}

Jump to

Keyboard shortcuts

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