Documentation
¶
Index ¶
- func NewFalkorDBGraph(connectionString string) (rag.KnowledgeGraph, error)
- func NewKnowledgeGraph(databaseURL string) (rag.KnowledgeGraph, error)
- type Edge
- type FalkorDBGraph
- func (f *FalkorDBGraph) AddEntity(ctx context.Context, entity *rag.Entity) error
- func (f *FalkorDBGraph) AddRelationship(ctx context.Context, rel *rag.Relationship) error
- func (f *FalkorDBGraph) Close() error
- func (f *FalkorDBGraph) DeleteEntity(ctx context.Context, id string) error
- func (f *FalkorDBGraph) DeleteRelationship(ctx context.Context, id string) error
- func (f *FalkorDBGraph) GetEntity(ctx context.Context, id string) (*rag.Entity, error)
- func (f *FalkorDBGraph) GetRelatedEntities(ctx context.Context, entityID string, maxDepth int) ([]*rag.Entity, error)
- func (f *FalkorDBGraph) GetRelationship(ctx context.Context, id string) (*rag.Relationship, error)
- func (f *FalkorDBGraph) Query(ctx context.Context, query *rag.GraphQuery) (*rag.GraphQueryResult, error)
- func (f *FalkorDBGraph) UpdateEntity(ctx context.Context, entity *rag.Entity) error
- func (f *FalkorDBGraph) UpdateRelationship(ctx context.Context, rel *rag.Relationship) error
- type Graph
- type InMemoryVectorStore
- func (s *InMemoryVectorStore) Add(ctx context.Context, documents []rag.Document) error
- func (s *InMemoryVectorStore) AddBatch(ctx context.Context, documents []rag.Document, embeddings [][]float32) error
- func (s *InMemoryVectorStore) AddWithEmbedding(ctx context.Context, doc rag.Document, embedding []float32) error
- func (s *InMemoryVectorStore) Close() error
- func (s *InMemoryVectorStore) Delete(ctx context.Context, ids []string) error
- func (s *InMemoryVectorStore) GetStats(ctx context.Context) (*rag.VectorStoreStats, error)
- func (s *InMemoryVectorStore) Search(ctx context.Context, queryEmbedding []float32, k int) ([]rag.DocumentSearchResult, error)
- func (s *InMemoryVectorStore) SearchWithFilter(ctx context.Context, queryEmbedding []float32, k int, filter map[string]any) ([]rag.DocumentSearchResult, error)
- func (s *InMemoryVectorStore) Update(ctx context.Context, documents []rag.Document) error
- func (s *InMemoryVectorStore) UpdateWithEmbedding(ctx context.Context, doc rag.Document, embedding []float32) error
- type MemoryGraph
- func (m *MemoryGraph) AddEntity(ctx context.Context, entity *rag.Entity) error
- func (m *MemoryGraph) AddRelationship(ctx context.Context, rel *rag.Relationship) error
- func (m *MemoryGraph) Close() error
- func (m *MemoryGraph) DeleteEntity(ctx context.Context, id string) error
- func (m *MemoryGraph) DeleteRelationship(ctx context.Context, id string) error
- func (m *MemoryGraph) GetEntity(ctx context.Context, id string) (*rag.Entity, error)
- func (m *MemoryGraph) GetRelatedEntities(ctx context.Context, entityID string, maxDepth int) ([]*rag.Entity, error)
- func (m *MemoryGraph) GetRelationship(ctx context.Context, id string) (*rag.Relationship, error)
- func (m *MemoryGraph) Query(ctx context.Context, query *rag.GraphQuery) (*rag.GraphQueryResult, error)
- func (m *MemoryGraph) UpdateEntity(ctx context.Context, entity *rag.Entity) error
- func (m *MemoryGraph) UpdateRelationship(ctx context.Context, rel *rag.Relationship) error
- type MockEmbedder
- type Node
- type QueryResult
- type SimpleReranker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewFalkorDBGraph ¶
func NewFalkorDBGraph(connectionString string) (rag.KnowledgeGraph, error)
NewFalkorDBGraph creates a new FalkorDB knowledge graph
func NewKnowledgeGraph ¶
func NewKnowledgeGraph(databaseURL string) (rag.KnowledgeGraph, error)
NewKnowledgeGraph creates a new knowledge graph based on the database URL
Types ¶
type Edge ¶
type Edge struct {
Source *Node
Destination *Node
Relation string
Properties map[string]interface{}
}
Edge represents an edge connecting two nodes in the graph.
type FalkorDBGraph ¶
type FalkorDBGraph struct {
// contains filtered or unexported fields
}
FalkorDBGraph implements a FalkorDB knowledge graph
func (*FalkorDBGraph) AddRelationship ¶
func (f *FalkorDBGraph) AddRelationship(ctx context.Context, rel *rag.Relationship) error
AddRelationship adds a relationship to the graph
func (*FalkorDBGraph) DeleteEntity ¶
func (f *FalkorDBGraph) DeleteEntity(ctx context.Context, id string) error
DeleteEntity removes an entity
func (*FalkorDBGraph) DeleteRelationship ¶
func (f *FalkorDBGraph) DeleteRelationship(ctx context.Context, id string) error
DeleteRelationship removes a relationship
func (*FalkorDBGraph) GetRelatedEntities ¶
func (f *FalkorDBGraph) GetRelatedEntities(ctx context.Context, entityID string, maxDepth int) ([]*rag.Entity, error)
GetRelatedEntities finds entities related to a given entity
func (*FalkorDBGraph) GetRelationship ¶
func (f *FalkorDBGraph) GetRelationship(ctx context.Context, id string) (*rag.Relationship, error)
GetRelationship retrieves a relationship by ID
func (*FalkorDBGraph) Query ¶
func (f *FalkorDBGraph) Query(ctx context.Context, query *rag.GraphQuery) (*rag.GraphQueryResult, error)
Query performs a graph query
func (*FalkorDBGraph) UpdateEntity ¶
UpdateEntity updates an entity
func (*FalkorDBGraph) UpdateRelationship ¶
func (f *FalkorDBGraph) UpdateRelationship(ctx context.Context, rel *rag.Relationship) error
UpdateRelationship updates a relationship
type Graph ¶
Graph represents a graph, which is a collection of nodes and edges.
func (*Graph) Commit ¶
func (g *Graph) Commit() (QueryResult, error)
Commit creates the entire graph (using CREATE).
type InMemoryVectorStore ¶
type InMemoryVectorStore struct {
// contains filtered or unexported fields
}
InMemoryVectorStore is a simple in-memory vector store implementation
func NewInMemoryVectorStore ¶
func NewInMemoryVectorStore(embedder rag.Embedder) *InMemoryVectorStore
NewInMemoryVectorStore creates a new InMemoryVectorStore
func (*InMemoryVectorStore) AddBatch ¶
func (s *InMemoryVectorStore) AddBatch(ctx context.Context, documents []rag.Document, embeddings [][]float32) error
AddBatch adds multiple documents with explicit embeddings
func (*InMemoryVectorStore) AddWithEmbedding ¶
func (s *InMemoryVectorStore) AddWithEmbedding(ctx context.Context, doc rag.Document, embedding []float32) error
AddWithEmbedding adds a document to the in-memory vector store with an explicit embedding
func (*InMemoryVectorStore) Close ¶
func (s *InMemoryVectorStore) Close() error
Close closes the vector store (no-op for in-memory implementation)
func (*InMemoryVectorStore) Delete ¶
func (s *InMemoryVectorStore) Delete(ctx context.Context, ids []string) error
Delete removes a document by ID
func (*InMemoryVectorStore) GetStats ¶
func (s *InMemoryVectorStore) GetStats(ctx context.Context) (*rag.VectorStoreStats, error)
GetStats returns statistics about the vector store
func (*InMemoryVectorStore) Search ¶
func (s *InMemoryVectorStore) Search(ctx context.Context, queryEmbedding []float32, k int) ([]rag.DocumentSearchResult, error)
Search performs similarity search
func (*InMemoryVectorStore) SearchWithFilter ¶
func (s *InMemoryVectorStore) SearchWithFilter(ctx context.Context, queryEmbedding []float32, k int, filter map[string]any) ([]rag.DocumentSearchResult, error)
SearchWithFilter performs similarity search with filters
func (*InMemoryVectorStore) UpdateWithEmbedding ¶
func (s *InMemoryVectorStore) UpdateWithEmbedding(ctx context.Context, doc rag.Document, embedding []float32) error
UpdateWithEmbedding updates a document and its embedding
type MemoryGraph ¶
type MemoryGraph struct {
// contains filtered or unexported fields
}
MemoryGraph implements an in-memory knowledge graph
func (*MemoryGraph) AddRelationship ¶
func (m *MemoryGraph) AddRelationship(ctx context.Context, rel *rag.Relationship) error
AddRelationship adds a relationship to the memory graph
func (*MemoryGraph) Close ¶
func (m *MemoryGraph) Close() error
Close closes the memory graph (no-op for in-memory implementation)
func (*MemoryGraph) DeleteEntity ¶
func (m *MemoryGraph) DeleteEntity(ctx context.Context, id string) error
DeleteEntity removes an entity from the memory graph
func (*MemoryGraph) DeleteRelationship ¶
func (m *MemoryGraph) DeleteRelationship(ctx context.Context, id string) error
DeleteRelationship removes a relationship from the memory graph
func (*MemoryGraph) GetRelatedEntities ¶
func (m *MemoryGraph) GetRelatedEntities(ctx context.Context, entityID string, maxDepth int) ([]*rag.Entity, error)
GetRelatedEntities finds entities related to a given entity
func (*MemoryGraph) GetRelationship ¶
func (m *MemoryGraph) GetRelationship(ctx context.Context, id string) (*rag.Relationship, error)
GetRelationship retrieves a relationship by ID
func (*MemoryGraph) Query ¶
func (m *MemoryGraph) Query(ctx context.Context, query *rag.GraphQuery) (*rag.GraphQueryResult, error)
Query performs a graph query
func (*MemoryGraph) UpdateEntity ¶
UpdateEntity updates an entity in the memory graph
func (*MemoryGraph) UpdateRelationship ¶
func (m *MemoryGraph) UpdateRelationship(ctx context.Context, rel *rag.Relationship) error
UpdateRelationship updates a relationship in the memory graph
type MockEmbedder ¶
type MockEmbedder struct {
Dimension int
}
MockEmbedder is a simple mock embedder for testing
func NewMockEmbedder ¶
func NewMockEmbedder(dimension int) *MockEmbedder
NewMockEmbedder creates a new MockEmbedder
func (*MockEmbedder) EmbedDocument ¶
EmbedDocument generates mock embedding for a document
func (*MockEmbedder) EmbedDocuments ¶
EmbedDocuments generates mock embeddings for documents
func (*MockEmbedder) GetDimension ¶
func (e *MockEmbedder) GetDimension() int
GetDimension returns the embedding dimension
type QueryResult ¶
type QueryResult struct {
Header []string // Extracted from first row usually? No, GRAPH.QUERY returns header.
Results [][]interface{} // Changed from [][]string
Statistics []string
}
QueryResult represents the results of a query.
func (*QueryResult) PrettyPrint ¶
func (qr *QueryResult) PrettyPrint()
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