vectorstores

package
v0.22.1 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCollectionNotFound = errors.New("collection not found")
)

Functions

func ToRetriever

func ToRetriever(vectorStore VectorStore, numDocs int, options ...Option) schema.Retriever

ToRetriever creates a retriever from a vector store.

Types

type ContextNetwork added in v0.15.0

type ContextNetwork struct {
	// Dependencies are documents that the current code imports/depends on
	Dependencies []schema.Document
	// Dependents are documents that import/depend on the current code (impact analysis)
	Dependents []schema.Document
}

ContextNetwork represents the graph neighborhood of a piece of code

type DefinitionRetriever added in v0.15.0

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

func NewDefinitionRetriever added in v0.15.0

func NewDefinitionRetriever(store VectorStore) *DefinitionRetriever

func (*DefinitionRetriever) GetDefinition added in v0.15.0

func (r *DefinitionRetriever) GetDefinition(ctx context.Context, symbolName string) ([]schema.Document, error)

GetDefinition performs an exact match lookup for a symbol name

type DependencyRetriever added in v0.15.0

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

DependencyRetriever optimizes RAG by traversing the dependency graph

func NewDependencyRetriever added in v0.15.0

func NewDependencyRetriever(store VectorStore) *DependencyRetriever

NewDependencyRetriever creates a new graph-based retriever

func (*DependencyRetriever) GetContextNetwork added in v0.15.0

func (r *DependencyRetriever) GetContextNetwork(ctx context.Context, packageName string, imports []string) (*ContextNetwork, error)

GetContextNetwork retrieves both upstream dependencies and downstream impact

type DocumentWithScore

type DocumentWithScore struct {
	Document schema.Document
	Score    float32
}

type MultiQueryRetriever added in v0.15.0

type MultiQueryRetriever struct {
	Retriever schema.Retriever
	LLM       llms.Model
	Count     int
}

func (MultiQueryRetriever) GetRelevantDocuments added in v0.15.0

func (r MultiQueryRetriever) GetRelevantDocuments(ctx context.Context, query string) ([]schema.Document, error)

type Option

type Option func(*Options)

func WithCollectionName added in v0.7.1

func WithCollectionName(name string) Option

WithCollectionName sets the collection name for the Qdrant store.

func WithEmbedder

func WithEmbedder(embedder embeddings.Embedder) Option

func WithFilter

func WithFilter(key string, value any) Option

func WithFilters

func WithFilters(filters map[string]any) Option

func WithNameSpace

func WithNameSpace(namespace string) Option

func WithScoreThreshold

func WithScoreThreshold(threshold float32) Option

func WithSparseQueries added in v0.15.0

func WithSparseQueries(sparse []*schema.SparseVector) Option

func WithSparseQuery added in v0.15.0

func WithSparseQuery(sparse *schema.SparseVector) Option

type Options

type Options struct {
	Embedder       embeddings.Embedder
	NameSpace      string
	CollectionName string
	ScoreThreshold float32
	Filters        map[string]any
	SparseQuery    *schema.SparseVector
	SparseQueries  []*schema.SparseVector
}

func ParseOptions

func ParseOptions(options ...Option) Options

type RerankingRetriever added in v0.15.0

type RerankingRetriever struct {
	Retriever schema.Retriever
	Reranker  schema.Reranker
	TopK      int // Final number of documents to return after reranking
}

RerankingRetriever wraps a standard retriever and uses a reranker to refine results.

func (RerankingRetriever) GetRelevantDocuments added in v0.15.0

func (r RerankingRetriever) GetRelevantDocuments(ctx context.Context, query string) ([]schema.Document, error)

func (RerankingRetriever) GetRelevantScoredDocuments added in v0.15.0

func (r RerankingRetriever) GetRelevantScoredDocuments(ctx context.Context, query string) ([]schema.ScoredDocument, error)

type Retriever

type Retriever interface {
	GetRelevantDocuments(ctx context.Context, query string) ([]schema.Document, error)
}

Retriever is the interface for fetching relevant documents for a query.

type ScoredRetriever added in v0.15.0

type ScoredRetriever interface {
	GetRelevantScoredDocuments(ctx context.Context, query string) ([]schema.ScoredDocument, error)
}

ScoredRetriever is a retriever that returns documents with relevance scores.

type VectorStore

type VectorStore interface {
	AddDocuments(ctx context.Context, docs []schema.Document, options ...Option) ([]string, error)
	SimilaritySearch(ctx context.Context, query string, numDocuments int, options ...Option) ([]schema.Document, error)
	SimilaritySearchBatch(ctx context.Context, queries []string, numDocuments int, options ...Option) ([][]schema.Document, error)
	SimilaritySearchWithScores(ctx context.Context, query string, numDocuments int, options ...Option) ([]DocumentWithScore, error)
	ListCollections(ctx context.Context) ([]string, error)
	DeleteCollection(ctx context.Context, collectionName string) error
	DeleteDocumentsByFilter(ctx context.Context, filters map[string]any, options ...Option) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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