engine

package
v0.8.5 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultExtractionPrompt = `` /* 289-byte string literal not displayed */

	RelationshipExtractionPrompt = `` /* 416-byte string literal not displayed */

)

Constants for default prompts and entity types

Variables

View Source
var DefaultEntityTypes = []string{
	"PERSON",
	"ORGANIZATION",
	"LOCATION",
	"DATE",
	"PRODUCT",
	"EVENT",
	"CONCEPT",
	"TECHNOLOGY",
}

DefaultEntityTypes contains commonly used entity types

Functions

func NewVectorStoreRetriever

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

NewVectorStoreRetriever creates a vector store retriever

Types

type EntityExtractionResult

type EntityExtractionResult struct {
	Entities []ExtractedEntity `json:"entities"`
}

Supporting structs for JSON parsing

type ExtractedEntity

type ExtractedEntity struct {
	Name        string         `json:"name"`
	Type        string         `json:"type"`
	Description string         `json:"description"`
	Properties  map[string]any `json:"properties"`
}

type ExtractedRelationship

type ExtractedRelationship struct {
	Source     string         `json:"source"`
	Target     string         `json:"target"`
	Type       string         `json:"type"`
	Properties map[string]any `json:"properties"`
	Confidence float64        `json:"confidence"`
}

type GraphRAGEngine

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

GraphRAGEngine implements GraphRAG functionality with knowledge graphs

func NewGraphRAGEngine

func NewGraphRAGEngine(config rag.GraphRAGConfig, llm rag.LLMInterface, embedder rag.Embedder, kg rag.KnowledgeGraph) (*GraphRAGEngine, error)

NewGraphRAGEngine creates a new GraphRAG engine

func (*GraphRAGEngine) AddDocuments

func (g *GraphRAGEngine) AddDocuments(ctx context.Context, docs []rag.Document) error

AddDocuments adds documents to the knowledge graph

func (*GraphRAGEngine) DeleteDocument

func (g *GraphRAGEngine) DeleteDocument(ctx context.Context, docID string) error

DeleteDocument removes entities and relationships associated with a document

func (*GraphRAGEngine) GetKnowledgeGraph

func (g *GraphRAGEngine) GetKnowledgeGraph() rag.KnowledgeGraph

GetKnowledgeGraph returns the underlying knowledge graph for advanced operations

func (*GraphRAGEngine) GetMetrics

func (g *GraphRAGEngine) GetMetrics() *rag.Metrics

GetMetrics returns the current metrics

func (*GraphRAGEngine) Query

func (g *GraphRAGEngine) Query(ctx context.Context, query string) (*rag.QueryResult, error)

Query performs a GraphRAG query

func (*GraphRAGEngine) QueryWithConfig

func (g *GraphRAGEngine) QueryWithConfig(ctx context.Context, query string, config *rag.RetrievalConfig) (*rag.QueryResult, error)

QueryWithConfig performs a GraphRAG query with custom configuration

func (*GraphRAGEngine) SimilaritySearch

func (g *GraphRAGEngine) SimilaritySearch(ctx context.Context, query string, k int) ([]rag.Document, error)

SimilaritySearch performs entity-based similarity search

func (*GraphRAGEngine) SimilaritySearchWithScores

func (g *GraphRAGEngine) SimilaritySearchWithScores(ctx context.Context, query string, k int) ([]rag.DocumentSearchResult, error)

SimilaritySearchWithScores performs entity-based similarity search with scores

func (*GraphRAGEngine) UpdateDocument

func (g *GraphRAGEngine) UpdateDocument(ctx context.Context, doc rag.Document) error

UpdateDocument updates a document in the knowledge graph

type LightRAGEngine added in v0.8.2

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

LightRAGEngine implements LightRAG functionality LightRAG combines low-level semantic chunks with high-level graph structures It supports four retrieval modes: naive, local, global, and hybrid

func NewLightRAGEngine added in v0.8.2

func NewLightRAGEngine(
	config rag.LightRAGConfig,
	llm rag.LLMInterface,
	embedder rag.Embedder,
	kg rag.KnowledgeGraph,
	vectorStore rag.VectorStore,
) (*LightRAGEngine, error)

NewLightRAGEngine creates a new LightRAG engine

func (*LightRAGEngine) AddDocuments added in v0.8.2

func (l *LightRAGEngine) AddDocuments(ctx context.Context, docs []rag.Document) error

AddDocuments adds documents to the LightRAG system

func (*LightRAGEngine) DeleteDocument added in v0.8.2

func (l *LightRAGEngine) DeleteDocument(ctx context.Context, docID string) error

DeleteDocument removes a document from the system

func (*LightRAGEngine) GetConfig added in v0.8.2

func (l *LightRAGEngine) GetConfig() rag.LightRAGConfig

GetConfig returns the current configuration

func (*LightRAGEngine) GetKnowledgeGraph added in v0.8.2

func (l *LightRAGEngine) GetKnowledgeGraph() rag.KnowledgeGraph

GetKnowledgeGraph returns the underlying knowledge graph

func (*LightRAGEngine) GetMetrics added in v0.8.2

func (l *LightRAGEngine) GetMetrics() *rag.Metrics

GetMetrics returns the current metrics

func (*LightRAGEngine) Query added in v0.8.2

func (l *LightRAGEngine) Query(ctx context.Context, query string) (*rag.QueryResult, error)

Query performs a LightRAG query with the configured mode

func (*LightRAGEngine) QueryWithConfig added in v0.8.2

func (l *LightRAGEngine) QueryWithConfig(ctx context.Context, query string, config *rag.RetrievalConfig) (*rag.QueryResult, error)

QueryWithConfig performs a LightRAG query with custom configuration

func (*LightRAGEngine) SimilaritySearch added in v0.8.2

func (l *LightRAGEngine) SimilaritySearch(ctx context.Context, query string, k int) ([]rag.Document, error)

SimilaritySearch performs similarity search

func (*LightRAGEngine) SimilaritySearchWithScores added in v0.8.2

func (l *LightRAGEngine) SimilaritySearchWithScores(ctx context.Context, query string, k int) ([]rag.DocumentSearchResult, error)

SimilaritySearchWithScores performs similarity search with scores

func (*LightRAGEngine) UpdateDocument added in v0.8.2

func (l *LightRAGEngine) UpdateDocument(ctx context.Context, doc rag.Document) error

UpdateDocument updates a document in the system

type RelationshipExtractionResult

type RelationshipExtractionResult struct {
	Relationships []ExtractedRelationship `json:"relationships"`
}

type VectorRAGEngine

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

VectorRAGEngine implements traditional vector-based RAG

func NewVectorRAGEngine

func NewVectorRAGEngine(llm rag.LLMInterface, embedder rag.Embedder, vectorStore rag.VectorStore, k int) (*VectorRAGEngine, error)

NewVectorRAGEngine creates a new vector RAG engine

func NewVectorRAGEngineWithConfig

func NewVectorRAGEngineWithConfig(llm rag.LLMInterface, embedder rag.Embedder, vectorStore rag.VectorStore, config rag.VectorRAGConfig) (*VectorRAGEngine, error)

NewVectorRAGEngineWithConfig creates a new vector RAG engine with custom configuration

func (*VectorRAGEngine) AddDocuments

func (v *VectorRAGEngine) AddDocuments(ctx context.Context, docs []rag.Document) error

AddDocuments adds documents to the vector store

func (*VectorRAGEngine) DeleteDocument

func (v *VectorRAGEngine) DeleteDocument(ctx context.Context, docID string) error

DeleteDocument removes documents from the vector store

func (*VectorRAGEngine) GetMetrics

func (v *VectorRAGEngine) GetMetrics() *rag.Metrics

GetMetrics returns the current metrics

func (*VectorRAGEngine) GetStats

GetStats returns vector store statistics

func (*VectorRAGEngine) GetVectorStore

func (v *VectorRAGEngine) GetVectorStore() rag.VectorStore

GetVectorStore returns the underlying vector store for advanced operations

func (*VectorRAGEngine) Query

func (v *VectorRAGEngine) Query(ctx context.Context, query string) (*rag.QueryResult, error)

Query performs a vector RAG query

func (*VectorRAGEngine) QueryWithConfig

func (v *VectorRAGEngine) QueryWithConfig(ctx context.Context, query string, config *rag.RetrievalConfig) (*rag.QueryResult, error)

QueryWithConfig performs a vector RAG query with custom configuration

func (*VectorRAGEngine) SimilaritySearch

func (v *VectorRAGEngine) SimilaritySearch(ctx context.Context, query string, k int) ([]rag.Document, error)

SimilaritySearch performs similarity search without generation

func (*VectorRAGEngine) SimilaritySearchWithScores

func (v *VectorRAGEngine) SimilaritySearchWithScores(ctx context.Context, query string, k int) ([]rag.DocumentSearchResult, error)

SimilaritySearchWithScores performs similarity search with scores

func (*VectorRAGEngine) UpdateDocument

func (v *VectorRAGEngine) UpdateDocument(ctx context.Context, doc rag.Document) error

UpdateDocument updates documents in the vector store

Jump to

Keyboard shortcuts

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