Documentation
¶
Index ¶
- func NewFalkorDBGraph(connectionString string) (rag.KnowledgeGraph, error)
- func NewKnowledgeGraph(databaseURL string) (rag.KnowledgeGraph, error)
- type ChromaV2Config
- type ChromaV2VectorStore
- func (s *ChromaV2VectorStore) Add(ctx context.Context, documents []rag.Document) error
- func (s *ChromaV2VectorStore) Close() error
- func (s *ChromaV2VectorStore) Delete(ctx context.Context, ids []string) error
- func (s *ChromaV2VectorStore) GetCollectionID() string
- func (s *ChromaV2VectorStore) GetCollectionName() string
- func (s *ChromaV2VectorStore) GetStats(ctx context.Context) (*rag.VectorStoreStats, error)
- func (s *ChromaV2VectorStore) Search(ctx context.Context, query []float32, k int) ([]rag.DocumentSearchResult, error)
- func (s *ChromaV2VectorStore) SearchWithFilter(ctx context.Context, query []float32, k int, filter map[string]any) ([]rag.DocumentSearchResult, error)
- func (s *ChromaV2VectorStore) Update(ctx context.Context, documents []rag.Document) error
- type ChromemConfig
- type ChromemVectorStore
- func (s *ChromemVectorStore) Add(ctx context.Context, documents []rag.Document) error
- func (s *ChromemVectorStore) Close() error
- func (s *ChromemVectorStore) Delete(ctx context.Context, ids []string) error
- func (s *ChromemVectorStore) GetCollectionName() string
- func (s *ChromemVectorStore) GetStats(ctx context.Context) (*rag.VectorStoreStats, error)
- func (s *ChromemVectorStore) Search(ctx context.Context, query []float32, k int) ([]rag.DocumentSearchResult, error)
- func (s *ChromemVectorStore) SearchWithFilter(ctx context.Context, query []float32, k int, filter map[string]any) ([]rag.DocumentSearchResult, error)
- func (s *ChromemVectorStore) Update(ctx context.Context, documents []rag.Document) error
- type CollectionInfo
- 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 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) 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
func (s *ChromaV2VectorStore) GetStats(ctx context.Context) (*rag.VectorStoreStats, error)
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
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) 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
func (s *ChromemVectorStore) GetStats(ctx context.Context) (*rag.VectorStoreStats, error)
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
type CollectionInfo ¶ added in v0.8.5
CollectionInfo represents collection information
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 NewGraph ¶
func NewGraph(name string, conn redis.UniversalClient) Graph
NewGraph creates a new graph (helper constructor).
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 ¶
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