Documentation
¶
Overview ¶
Package graph provides GraphRAG retrieval implementation following Microsoft GraphRAG architecture. It supports three search modes: Local, Global, and Hybrid.
Index ¶
- func DefaultGraphRetriever(opts ...Option) (core.Retriever, error)
- func NewRetriever(vectorStore core.VectorStore, graphStore core.GraphStore, ...) core.Retriever
- type CypherStep
- type ExtractionStrategy
- type Option
- func WithCustomStep(step pipeline.Step[*core.RetrievalContext]) Option
- func WithDepth(d int) Option
- func WithDocStore(s core.DocStore) Option
- func WithEmbedder(e embedding.Provider) Option
- func WithEntityExtractor(extractor core.EntityExtractor) Option
- func WithExtractionStrategy(strategy ExtractionStrategy) Option
- func WithGraphStore(s core.GraphStore) Option
- func WithLLM(l chat.Client) Option
- func WithLimit(l int) Option
- func WithLogger(l logging.Logger) Option
- func WithName(name string) Option
- func WithPromptTemplate(t string) Option
- func WithSearchMode(mode core.SearchMode) Option
- func WithTopK(k int) Option
- func WithTracer(t observability.Tracer) Option
- func WithVectorStore(s core.VectorStore) Option
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultGraphRetriever ¶ added in v1.1.3
DefaultGraphRetriever creates a GraphRAG retriever with default settings. It automatically selects search mode based on available components.
func NewRetriever ¶
func NewRetriever( vectorStore core.VectorStore, graphStore core.GraphStore, embedder embedding.Provider, llm chat.Client, opts ...Option, ) core.Retriever
NewRetriever creates a new GraphRAG retriever with configurable search mode. Following Microsoft GraphRAG architecture: - Local: Entity-centric graph traversal (best for specific questions) - Global: Community-based search (best for thematic questions) - Hybrid: Combines local, global, and vector search
Types ¶
type CypherStep ¶
type CypherStep struct {
// contains filtered or unexported fields
}
CypherStep allows using Cypher templates for deep relationship retrieval. It is specifically designed for GraphStores that support Cypher (like Neo4j).
func NewCypherStep ¶
func NewCypherStep(store core.GraphStore, template string, logger logging.Logger) *CypherStep
NewCypherStep creates a new step for Cypher-based graph retrieval.
func (*CypherStep) Execute ¶
func (s *CypherStep) Execute(ctx context.Context, retrievalCtx *core.RetrievalContext) error
func (*CypherStep) Name ¶
func (s *CypherStep) Name() string
type ExtractionStrategy ¶ added in v1.1.6
type ExtractionStrategy string
ExtractionStrategy defines the entity extraction strategy.
const ( ExtractionStrategyLLM ExtractionStrategy = "llm" ExtractionStrategyVector ExtractionStrategy = "vector" ExtractionStrategyKeyword ExtractionStrategy = "keyword" ExtractionStrategyAuto ExtractionStrategy = "auto" )
type Option ¶
type Option func(*Options)
func WithCustomStep ¶
func WithCustomStep(step pipeline.Step[*core.RetrievalContext]) Option
WithCustomStep adds a custom pipeline step.
func WithDocStore ¶
WithDocStore sets the document store for chunk enrichment.
func WithEmbedder ¶ added in v1.1.3
WithEmbedder sets the embedding provider.
func WithEntityExtractor ¶ added in v1.1.6
func WithEntityExtractor(extractor core.EntityExtractor) Option
WithEntityExtractor sets a custom entity extractor.
func WithExtractionStrategy ¶ added in v1.1.6
func WithExtractionStrategy(strategy ExtractionStrategy) Option
WithExtractionStrategy sets the entity extraction strategy.
func WithGraphStore ¶ added in v1.1.3
func WithGraphStore(s core.GraphStore) Option
WithGraphStore sets the graph store (required).
func WithPromptTemplate ¶
WithPromptTemplate sets the generation prompt template.
func WithSearchMode ¶ added in v1.1.6
func WithSearchMode(mode core.SearchMode) Option
WithSearchMode sets the GraphRAG search mode. Options: SearchModeLocal, SearchModeGlobal, SearchModeHybrid.
func WithVectorStore ¶ added in v1.1.3
func WithVectorStore(s core.VectorStore) Option
WithVectorStore sets the vector store.