store

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: 12 Imported by: 1

Documentation

Index

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.

func (*Edge) String

func (e *Edge) String() string

type FalkorDBGraph

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

FalkorDBGraph implements a FalkorDB knowledge graph

func (*FalkorDBGraph) AddEntity

func (f *FalkorDBGraph) AddEntity(ctx context.Context, entity *rag.Entity) error

AddEntity adds an entity to the graph

func (*FalkorDBGraph) AddRelationship

func (f *FalkorDBGraph) AddRelationship(ctx context.Context, rel *rag.Relationship) error

AddRelationship adds a relationship to the graph

func (*FalkorDBGraph) Close

func (f *FalkorDBGraph) Close() error

Close closes the driver

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) GetEntity

func (f *FalkorDBGraph) GetEntity(ctx context.Context, id string) (*rag.Entity, error)

GetEntity retrieves an entity by ID

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

Query performs a graph query

func (*FalkorDBGraph) UpdateEntity

func (f *FalkorDBGraph) UpdateEntity(ctx context.Context, entity *rag.Entity) error

UpdateEntity updates an entity

func (*FalkorDBGraph) UpdateRelationship

func (f *FalkorDBGraph) UpdateRelationship(ctx context.Context, rel *rag.Relationship) error

UpdateRelationship updates a relationship

type Graph

type Graph struct {
	Name  string
	Nodes map[string]*Node
	Edges []*Edge
	Conn  redis.Conn
}

Graph represents a graph, which is a collection of nodes and edges.

func NewGraph

func NewGraph(name string, conn redis.Conn) Graph

NewGraph creates a new graph (helper constructor).

func (*Graph) AddEdge

func (g *Graph) AddEdge(e *Edge) error

AddEdge adds an edge to the graph structure (for Commit usage).

func (*Graph) AddNode

func (g *Graph) AddNode(n *Node) error

AddNode adds a node to the graph structure (for Commit usage).

func (*Graph) Commit

func (g *Graph) Commit() (QueryResult, error)

Commit creates the entire graph (using CREATE).

func (*Graph) Delete

func (g *Graph) Delete() error

func (*Graph) Query

func (g *Graph) Query(q string) (QueryResult, error)

Query executes a query against the graph.

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) Add

func (s *InMemoryVectorStore) Add(ctx context.Context, documents []rag.Document) error

Add adds multiple documents to the in-memory vector store

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

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) Update

func (s *InMemoryVectorStore) Update(ctx context.Context, documents []rag.Document) error

Update updates documents in the vector store

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) AddEntity

func (m *MemoryGraph) AddEntity(ctx context.Context, entity *rag.Entity) error

AddEntity adds an entity to the memory 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) GetEntity

func (m *MemoryGraph) GetEntity(ctx context.Context, id string) (*rag.Entity, error)

GetEntity retrieves an entity by ID

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

func (m *MemoryGraph) UpdateEntity(ctx context.Context, entity *rag.Entity) error

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

func (e *MockEmbedder) EmbedDocument(ctx context.Context, text string) ([]float32, error)

EmbedDocument generates mock embedding for a document

func (*MockEmbedder) EmbedDocuments

func (e *MockEmbedder) EmbedDocuments(ctx context.Context, texts []string) ([][]float32, error)

EmbedDocuments generates mock embeddings for documents

func (*MockEmbedder) GetDimension

func (e *MockEmbedder) GetDimension() int

GetDimension returns the embedding dimension

type Node

type Node struct {
	ID         string
	Alias      string
	Label      string
	Properties map[string]interface{}
}

Node represents a node within a graph.

func (*Node) String

func (n *Node) String() string

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

Jump to

Keyboard shortcuts

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