Documentation
¶
Overview ¶
Package weaviate provides a Weaviate-based implementation of the GraphRAG interface.
This implementation stores entities and relationships in separate Weaviate collections, using vector embeddings for semantic search and metadata filtering for graph traversal.
Index ¶
- type Config
- type Option
- type Store
- func (s *Store) ApplySchema(ctx context.Context, schema interfaces.GraphSchema) error
- func (s *Store) Close() error
- func (s *Store) CountAllEntities(ctx context.Context) (int, error)
- func (s *Store) DeleteEntity(ctx context.Context, id string, opts ...interfaces.GraphStoreOption) error
- func (s *Store) DeleteRelationship(ctx context.Context, id string, opts ...interfaces.GraphStoreOption) error
- func (s *Store) DeleteSchema(ctx context.Context) error
- func (s *Store) DiscoverSchema(ctx context.Context) (*interfaces.GraphSchema, error)
- func (s *Store) ExtractFromText(ctx context.Context, text string, llm interfaces.LLM, ...) (*interfaces.ExtractionResult, error)
- func (s *Store) GetEntity(ctx context.Context, id string, opts ...interfaces.GraphStoreOption) (*interfaces.Entity, error)
- func (s *Store) GetRelationships(ctx context.Context, entityID string, ...) ([]interfaces.Relationship, error)
- func (s *Store) GetTenant() string
- func (s *Store) GlobalSearch(ctx context.Context, query string, communityLevel int, ...) ([]interfaces.GraphSearchResult, error)
- func (s *Store) ListAllEntities(ctx context.Context, limit int) ([]interfaces.Entity, error)
- func (s *Store) LocalSearch(ctx context.Context, query string, entityID string, depth int, ...) ([]interfaces.GraphSearchResult, error)
- func (s *Store) Search(ctx context.Context, query string, limit int, ...) ([]interfaces.GraphSearchResult, error)
- func (s *Store) SetTenant(tenant string)
- func (s *Store) ShortestPath(ctx context.Context, sourceID, targetID string, ...) (*interfaces.GraphPath, error)
- func (s *Store) StoreEntities(ctx context.Context, entities []interfaces.Entity, ...) error
- func (s *Store) StoreRelationships(ctx context.Context, relationships []interfaces.Relationship, ...) error
- func (s *Store) TraverseFrom(ctx context.Context, entityID string, depth int, ...) (*interfaces.GraphContext, error)
- func (s *Store) UpdateEntity(ctx context.Context, entity interfaces.Entity, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Host is the hostname of the Weaviate server (e.g., "localhost:8080")
Host string
// Scheme is the URL scheme ("http" or "https")
Scheme string
// APIKey is the authentication key for Weaviate Cloud
APIKey string
// ClassPrefix is the prefix for entity/relationship collections (default: "Graph")
ClassPrefix string
}
Config holds configuration for the Weaviate GraphRAG store.
type Option ¶
type Option func(*Store)
Option represents an option for configuring the Store.
func WithClassPrefix ¶
WithClassPrefix sets the class prefix for entity/relationship collections.
func WithEmbedder ¶
WithEmbedder sets the embedder for generating vectors.
func WithLogger ¶
WithLogger sets the logger for the store.
func WithSchema ¶
func WithSchema(schema *interfaces.GraphSchema) Option
WithSchema sets an initial schema for the store.
func WithStoreTenant ¶
WithStoreTenant sets the default tenant.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store implements the GraphRAGStore interface using Weaviate as the backend.
func (*Store) ApplySchema ¶
func (s *Store) ApplySchema(ctx context.Context, schema interfaces.GraphSchema) error
ApplySchema stores the schema definition for use in extraction and validation.
func (*Store) Close ¶
Close closes the store connection. Note: Weaviate client doesn't require explicit closing.
func (*Store) CountAllEntities ¶
CountAllEntities is a diagnostic method that counts all entities without any filter. This is useful for debugging to verify data is actually stored.
func (*Store) DeleteEntity ¶
func (s *Store) DeleteEntity(ctx context.Context, id string, opts ...interfaces.GraphStoreOption) error
DeleteEntity deletes an entity by its ID.
func (*Store) DeleteRelationship ¶
func (s *Store) DeleteRelationship(ctx context.Context, id string, opts ...interfaces.GraphStoreOption) error
DeleteRelationship deletes a relationship by its ID.
func (*Store) DeleteSchema ¶
DeleteSchema deletes the entity and relationship collections. Use with caution - this will delete all data!
func (*Store) DiscoverSchema ¶
func (s *Store) DiscoverSchema(ctx context.Context) (*interfaces.GraphSchema, error)
DiscoverSchema infers schema from existing data in the graph.
func (*Store) ExtractFromText ¶
func (s *Store) ExtractFromText(ctx context.Context, text string, llm interfaces.LLM, opts ...interfaces.ExtractionOption) (*interfaces.ExtractionResult, error)
ExtractFromText extracts entities and relationships from text using an LLM.
func (*Store) GetEntity ¶
func (s *Store) GetEntity(ctx context.Context, id string, opts ...interfaces.GraphStoreOption) (*interfaces.Entity, error)
GetEntity retrieves an entity by its ID.
func (*Store) GetRelationships ¶
func (s *Store) GetRelationships(ctx context.Context, entityID string, direction interfaces.RelationshipDirection, opts ...interfaces.GraphSearchOption) ([]interfaces.Relationship, error)
GetRelationships retrieves relationships for an entity based on direction.
func (*Store) GlobalSearch ¶
func (s *Store) GlobalSearch(ctx context.Context, query string, communityLevel int, opts ...interfaces.GraphSearchOption) ([]interfaces.GraphSearchResult, error)
GlobalSearch performs a community-based search across the knowledge graph. It groups entities by type and searches across communities.
func (*Store) ListAllEntities ¶
ListAllEntities is a diagnostic method that lists all entities without any filter.
func (*Store) LocalSearch ¶
func (s *Store) LocalSearch(ctx context.Context, query string, entityID string, depth int, opts ...interfaces.GraphSearchOption) ([]interfaces.GraphSearchResult, error)
LocalSearch performs a search starting from a specific entity and traversing the graph.
func (*Store) Search ¶
func (s *Store) Search(ctx context.Context, query string, limit int, opts ...interfaces.GraphSearchOption) ([]interfaces.GraphSearchResult, error)
Search performs a search on the knowledge graph. It supports vector, keyword, and hybrid search modes.
func (*Store) ShortestPath ¶
func (s *Store) ShortestPath(ctx context.Context, sourceID, targetID string, opts ...interfaces.GraphSearchOption) (*interfaces.GraphPath, error)
ShortestPath finds the shortest path between two entities using BFS.
func (*Store) StoreEntities ¶
func (s *Store) StoreEntities(ctx context.Context, entities []interfaces.Entity, opts ...interfaces.GraphStoreOption) error
StoreEntities stores multiple entities in the knowledge graph.
func (*Store) StoreRelationships ¶
func (s *Store) StoreRelationships(ctx context.Context, relationships []interfaces.Relationship, opts ...interfaces.GraphStoreOption) error
StoreRelationships stores multiple relationships in the knowledge graph.
func (*Store) TraverseFrom ¶
func (s *Store) TraverseFrom(ctx context.Context, entityID string, depth int, opts ...interfaces.GraphSearchOption) (*interfaces.GraphContext, error)
TraverseFrom performs a breadth-first traversal from a starting entity. Note: Weaviate doesn't support native graph traversal, so this requires multiple queries (one per hop level).
func (*Store) UpdateEntity ¶
func (s *Store) UpdateEntity(ctx context.Context, entity interfaces.Entity, opts ...interfaces.GraphStoreOption) error
UpdateEntity updates an existing entity.