store

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: 19 Imported by: 0

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 ChromaV2Config added in v0.8.5

type ChromaV2Config struct {
	// BaseURL is the base URL of the Chroma server (e.g., http://localhost:8000)
	BaseURL string

	// Tenant is the tenant name (defaults to "default_tenant")
	Tenant string

	// Database is the database name (defaults to "default_database")
	Database string

	// Collection is the collection name
	Collection string

	// CollectionID is the collection UUID (optional, will use Collection name if not provided)
	CollectionID string

	// Embedder is the embedder to use for generating embeddings
	Embedder rag.Embedder

	// HTTPClient is the HTTP client to use (optional, will create default if not provided)
	HTTPClient *http.Client
}

ChromaV2Config contains configuration for ChromaV2VectorStore

type ChromaV2VectorStore added in v0.8.5

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

ChromaV2VectorStore is a vector store implementation using Chroma v2 API It provides persistent vector storage with HTTP backend

Note on Metadata: Chroma v2 API support for metadata storage and filtering may vary by server version. Some versions may store metadata as null even when properly sent in the payload. This is a server-side limitation, not an issue with this implementation.

func NewChromaV2VectorStore added in v0.8.5

func NewChromaV2VectorStore(config ChromaV2Config) (*ChromaV2VectorStore, error)

NewChromaV2VectorStore creates a new ChromaV2VectorStore with the given configuration

func NewChromaV2VectorStoreSimple added in v0.8.5

func NewChromaV2VectorStoreSimple(baseURL, collection string, embedder rag.Embedder) (*ChromaV2VectorStore, error)

NewChromaV2VectorStoreSimple creates a new ChromaV2VectorStore with simple parameters

func (*ChromaV2VectorStore) Add added in v0.8.5

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

Add adds documents to the Chroma v2 vector store

func (*ChromaV2VectorStore) Close added in v0.8.5

func (s *ChromaV2VectorStore) Close() error

Close closes the Chroma v2 vector store and releases resources

func (*ChromaV2VectorStore) Delete added in v0.8.5

func (s *ChromaV2VectorStore) Delete(ctx context.Context, ids []string) error

Delete removes documents by their IDs

func (*ChromaV2VectorStore) GetCollectionID added in v0.8.5

func (s *ChromaV2VectorStore) GetCollectionID() string

GetCollectionID returns the collection ID

func (*ChromaV2VectorStore) GetCollectionName added in v0.8.5

func (s *ChromaV2VectorStore) GetCollectionName() string

GetCollectionName returns the collection name

func (*ChromaV2VectorStore) GetStats added in v0.8.5

GetStats returns statistics about the Chroma v2 vector store

func (*ChromaV2VectorStore) Search added in v0.8.5

func (s *ChromaV2VectorStore) Search(ctx context.Context, query []float32, k int) ([]rag.DocumentSearchResult, error)

Search performs similarity search in the Chroma v2 vector store

func (*ChromaV2VectorStore) SearchWithFilter added in v0.8.5

func (s *ChromaV2VectorStore) SearchWithFilter(ctx context.Context, query []float32, k int, filter map[string]any) ([]rag.DocumentSearchResult, error)

SearchWithFilter performs similarity search with metadata filters

func (*ChromaV2VectorStore) Update added in v0.8.5

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

Update updates documents in the Chroma v2 vector store

type ChromemConfig added in v0.8.5

type ChromemConfig struct {
	// PersistenceDir is the directory to store the chromem database
	// If empty, uses in-memory storage
	PersistenceDir string

	// CollectionName is the name of the collection to use
	// If empty, uses "default"
	CollectionName string

	// Embedder is the embedder to use for generating embeddings
	Embedder rag.Embedder
}

ChromemConfig contains configuration for ChromemVectorStore

type ChromemVectorStore added in v0.8.5

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

ChromemVectorStore is a vector store implementation using chromem-go It provides persistent vector storage with SQLite backend

func NewChromemVectorStore added in v0.8.5

func NewChromemVectorStore(config ChromemConfig) (*ChromemVectorStore, error)

NewChromemVectorStore creates a new ChromemVectorStore with the given configuration

func NewChromemVectorStoreSimple added in v0.8.5

func NewChromemVectorStoreSimple(persistenceDir string, embedder rag.Embedder) (*ChromemVectorStore, error)

NewChromemVectorStoreSimple creates a new ChromemVectorStore with simple parameters For in-memory storage, pass an empty string for persistenceDir

func (*ChromemVectorStore) Add added in v0.8.5

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

Add adds documents to the chromem vector store

func (*ChromemVectorStore) Close added in v0.8.5

func (s *ChromemVectorStore) Close() error

Close closes the chromem vector store and releases resources

func (*ChromemVectorStore) Delete added in v0.8.5

func (s *ChromemVectorStore) Delete(ctx context.Context, ids []string) error

Delete removes documents by their IDs

func (*ChromemVectorStore) GetCollectionName added in v0.8.5

func (s *ChromemVectorStore) GetCollectionName() string

GetCollectionName returns the name of the collection

func (*ChromemVectorStore) GetStats added in v0.8.5

GetStats returns statistics about the chromem vector store

func (*ChromemVectorStore) Search added in v0.8.5

func (s *ChromemVectorStore) Search(ctx context.Context, query []float32, k int) ([]rag.DocumentSearchResult, error)

Search performs similarity search in the chromem vector store

func (*ChromemVectorStore) SearchWithFilter added in v0.8.5

func (s *ChromemVectorStore) SearchWithFilter(ctx context.Context, query []float32, k int, filter map[string]any) ([]rag.DocumentSearchResult, error)

SearchWithFilter performs similarity search with metadata filters

func (*ChromemVectorStore) Update added in v0.8.5

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

Update updates documents in the chromem vector store

type CollectionInfo added in v0.8.5

type CollectionInfo struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

CollectionInfo represents collection information

type Edge

type Edge struct {
	Source      *Node
	Destination *Node
	Relation    string
	Properties  map[string]any
}

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.UniversalClient
}

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

func NewGraph

func NewGraph(name string, conn redis.UniversalClient) 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(ctx context.Context) (QueryResult, error)

Commit creates the entire graph (using CREATE).

func (*Graph) Delete

func (g *Graph) Delete(ctx context.Context) error

func (*Graph) Query

func (g *Graph) Query(ctx context.Context, 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]any
}

Node represents a node within a graph.

func (*Node) String

func (n *Node) String() string

type QueryResult

type QueryResult struct {
	Header     []string
	Results    [][]any
	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