retriever

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CombinedDocumentScore

type CombinedDocumentScore struct {
	Document       rag.Document
	TotalScore     float64
	RetrieverCount int
	Sources        []string
	Metadata       map[string]any
}

CombinedDocumentScore tracks score information for a document from multiple retrievers

type GraphRetriever

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

GraphRetriever implements document retrieval using knowledge graphs

func NewGraphRetriever

func NewGraphRetriever(knowledgeGraph rag.KnowledgeGraph, embedder rag.Embedder, config rag.RetrievalConfig) *GraphRetriever

NewGraphRetriever creates a new graph retriever

func (*GraphRetriever) Retrieve

func (r *GraphRetriever) Retrieve(ctx context.Context, query string) ([]rag.Document, error)

Retrieve retrieves documents based on a query using the knowledge graph

func (*GraphRetriever) RetrieveWithConfig

func (r *GraphRetriever) RetrieveWithConfig(ctx context.Context, query string, config *rag.RetrievalConfig) ([]rag.DocumentSearchResult, error)

RetrieveWithConfig retrieves documents with custom configuration

func (*GraphRetriever) RetrieveWithK

func (r *GraphRetriever) RetrieveWithK(ctx context.Context, query string, k int) ([]rag.Document, error)

RetrieveWithK retrieves exactly k documents

type HybridRetriever

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

HybridRetriever combines multiple retrieval strategies

func NewHybridRetriever

func NewHybridRetriever(retrievers []rag.Retriever, weights []float64, config rag.RetrievalConfig) *HybridRetriever

NewHybridRetriever creates a new hybrid retriever that combines multiple retrievers

func (*HybridRetriever) AddRetriever

func (h *HybridRetriever) AddRetriever(retriever rag.Retriever, weight float64)

AddRetriever adds a new retriever to the hybrid strategy

func (*HybridRetriever) GetRetrieverCount

func (h *HybridRetriever) GetRetrieverCount() int

GetRetrieverCount returns the number of retrievers being used

func (*HybridRetriever) GetWeights

func (h *HybridRetriever) GetWeights() []float64

GetWeights returns the weights being used for each retriever

func (*HybridRetriever) RemoveRetriever

func (h *HybridRetriever) RemoveRetriever(index int) error

RemoveRetriever removes a retriever by index

func (*HybridRetriever) Retrieve

func (h *HybridRetriever) Retrieve(ctx context.Context, query string) ([]rag.Document, error)

Retrieve retrieves documents using all configured retrievers and combines results

func (*HybridRetriever) RetrieveWithConfig

func (h *HybridRetriever) RetrieveWithConfig(ctx context.Context, query string, config *rag.RetrievalConfig) ([]rag.DocumentSearchResult, error)

RetrieveWithConfig retrieves documents with custom configuration using hybrid strategy

func (*HybridRetriever) RetrieveWithK

func (h *HybridRetriever) RetrieveWithK(ctx context.Context, query string, k int) ([]rag.Document, error)

RetrieveWithK retrieves exactly k documents using hybrid strategy

func (*HybridRetriever) SetWeights

func (h *HybridRetriever) SetWeights(weights []float64) error

SetWeights updates the weights for each retriever

type SimpleReranker

type SimpleReranker struct {
}

SimpleReranker is a simple reranker that scores documents based on keyword matching

func NewSimpleReranker

func NewSimpleReranker() *SimpleReranker

NewSimpleReranker creates a new SimpleReranker

func (*SimpleReranker) Rerank

func (r *SimpleReranker) Rerank(ctx context.Context, query string, documents []rag.DocumentSearchResult) ([]rag.DocumentSearchResult, error)

Rerank reranks documents based on query relevance

type VectorRetriever

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

VectorRetriever implements document retrieval using vector similarity

func NewVectorRetriever

func NewVectorRetriever(vectorStore rag.VectorStore, embedder rag.Embedder, config rag.RetrievalConfig) *VectorRetriever

NewVectorRetriever creates a new vector retriever

func (*VectorRetriever) Retrieve

func (r *VectorRetriever) Retrieve(ctx context.Context, query string) ([]rag.Document, error)

Retrieve retrieves documents based on a query

func (*VectorRetriever) RetrieveWithConfig

func (r *VectorRetriever) RetrieveWithConfig(ctx context.Context, query string, config *rag.RetrievalConfig) ([]rag.DocumentSearchResult, error)

RetrieveWithConfig retrieves documents with custom configuration

func (*VectorRetriever) RetrieveWithK

func (r *VectorRetriever) RetrieveWithK(ctx context.Context, query string, k int) ([]rag.Document, error)

RetrieveWithK retrieves exactly k documents

type VectorStoreRetriever

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

VectorStoreRetriever implements Retriever using a VectorStore with backward compatibility

func NewVectorStoreRetriever

func NewVectorStoreRetriever(vectorStore rag.VectorStore, embedder rag.Embedder, topK int) *VectorStoreRetriever

NewVectorStoreRetriever creates a new VectorStoreRetriever

func (*VectorStoreRetriever) Retrieve

func (r *VectorStoreRetriever) Retrieve(ctx context.Context, query string) ([]rag.Document, error)

Retrieve retrieves relevant documents for a query

func (*VectorStoreRetriever) RetrieveWithConfig

func (r *VectorStoreRetriever) RetrieveWithConfig(ctx context.Context, query string, config *rag.RetrievalConfig) ([]rag.DocumentSearchResult, error)

RetrieveWithConfig retrieves documents with custom configuration

func (*VectorStoreRetriever) RetrieveWithK

func (r *VectorStoreRetriever) RetrieveWithK(ctx context.Context, query string, k int) ([]rag.Document, error)

RetrieveWithK retrieves exactly k documents

Jump to

Keyboard shortcuts

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