Documentation
¶
Index ¶
- Variables
- type CreateCollectionRequest
- type Distance
- type GraphStore
- type InMemoryStore
- func (s *InMemoryStore) Count(_ context.Context) (int, error)
- func (s *InMemoryStore) DeleteMemory(_ context.Context, ids []int64) error
- func (s *InMemoryStore) Iterate(_ context.Context, fn func(model.MemoryRecord) bool) error
- func (s *InMemoryStore) SearchMemory(_ context.Context, sessionID string, queryEmbedding []float32, limit int) ([]model.MemoryRecord, error)
- func (s *InMemoryStore) StoreMemory(_ context.Context, sessionID, content string, metadata map[string]any, ...) error
- func (s *InMemoryStore) UpdateEmbedding(_ context.Context, id int64, embedding []float32, lastEmbedded time.Time) error
- type MongoStore
- func (ms *MongoStore) Close() error
- func (ms *MongoStore) Count(ctx context.Context) (int, error)
- func (ms *MongoStore) CreateSchema(ctx context.Context, _ string) error
- func (ms *MongoStore) DeleteMemory(ctx context.Context, ids []int64) error
- func (ms *MongoStore) Iterate(ctx context.Context, fn func(model.MemoryRecord) bool) error
- func (ms *MongoStore) SearchMemory(ctx context.Context, sessionID string, queryEmbedding []float32, limit int) ([]model.MemoryRecord, error)
- func (ms *MongoStore) StoreMemory(ctx context.Context, sessionID, content string, metadata map[string]any, ...) error
- func (ms *MongoStore) UpdateEmbedding(ctx context.Context, id int64, embedding []float32, lastEmbedded time.Time) error
- type Neo4jAccessMode
- type Neo4jSessionConfig
- type Neo4jStore
- func (s *Neo4jStore) Close() error
- func (s *Neo4jStore) Count(ctx context.Context) (int, error)
- func (s *Neo4jStore) CreateSchema(ctx context.Context, schemaPath string) error
- func (s *Neo4jStore) DeleteMemory(ctx context.Context, ids []int64) error
- func (s *Neo4jStore) Iterate(ctx context.Context, fn func(model.MemoryRecord) bool) error
- func (s *Neo4jStore) Neighborhood(ctx context.Context, sessionID string, seedIDs []int64, hops, limit int) ([]model.MemoryRecord, error)
- func (s *Neo4jStore) SearchMemory(ctx context.Context, sessionID string, queryEmbedding []float32, limit int) ([]model.MemoryRecord, error)
- func (s *Neo4jStore) StoreMemory(ctx context.Context, sessionID, content string, metadata map[string]any, ...) error
- func (s *Neo4jStore) UpdateEmbedding(ctx context.Context, id int64, embedding []float32, lastEmbedded time.Time) error
- func (s *Neo4jStore) UpsertGraph(ctx context.Context, record model.MemoryRecord, edges []model.GraphEdge) error
- type PostgresStore
- func (ps *PostgresStore) Close() error
- func (ps *PostgresStore) Count(ctx context.Context) (int, error)
- func (ps *PostgresStore) CreateSchema(ctx context.Context, schemaPath string) error
- func (ps *PostgresStore) DeleteMemory(ctx context.Context, ids []int64) error
- func (ps *PostgresStore) Iterate(ctx context.Context, fn func(model.MemoryRecord) bool) error
- func (ps *PostgresStore) Neighborhood(ctx context.Context, sessionID string, seedIDs []int64, hops, limit int) ([]model.MemoryRecord, error)
- func (ps *PostgresStore) SearchMemory(ctx context.Context, sessionID string, queryEmbedding []float32, limit int) ([]model.MemoryRecord, error)
- func (ps *PostgresStore) StoreMemory(ctx context.Context, sessionID, content string, metadata map[string]any, ...) error
- func (ps *PostgresStore) UpdateEmbedding(ctx context.Context, id int64, embedding []float32, lastEmbedded time.Time) error
- func (ps *PostgresStore) UpsertGraph(ctx context.Context, record model.MemoryRecord, edges []model.GraphEdge) error
- type QdrantStore
- func (qs *QdrantStore) Count(ctx context.Context) (int, error)
- func (qs *QdrantStore) CreateSchema(ctx context.Context, schemaPath string) error
- func (qs *QdrantStore) DeleteMemory(ctx context.Context, ids []int64) error
- func (qs *QdrantStore) Iterate(ctx context.Context, fn func(model.MemoryRecord) bool) error
- func (qs *QdrantStore) Neighborhood(ctx context.Context, seedIDs []int64, hops, limit int) ([]model.MemoryRecord, error)
- func (qs *QdrantStore) SearchMemory(ctx context.Context, sessionID string, queryEmbedding []float32, limit int) ([]model.MemoryRecord, error)
- func (qs *QdrantStore) StoreMemory(ctx context.Context, sessionID, content string, metadata map[string]any, ...) error
- func (qs *QdrantStore) UpdateEmbedding(ctx context.Context, id int64, embedding []float32, lastEmbedded time.Time) error
- func (qs *QdrantStore) UpsertGraph(ctx context.Context, record model.MemoryRecord, edges []model.GraphEdge) error
- type SchemaInitializer
- type VectorStore
Constants ¶
This section is empty.
Variables ¶
ErrNeo4jUnavailable is returned when graph operations are attempted without a configured driver.
Functions ¶
This section is empty.
Types ¶
type CreateCollectionRequest ¶
type CreateCollectionRequest struct {
Vectors json.RawMessage `json:"vectors"` // {"size":1536,"distance":"Cosine"} OR {"text":{"size":768,"distance":"Cosine"}}
ShardNumber *int `json:"shard_number,omitempty"`
ReplicationFactor *int `json:"replication_factor,omitempty"`
WriteConsistencyFactor *int `json:"write_consistency_factor,omitempty"`
OnDiskPayload *bool `json:"on_disk_payload,omitempty"`
}
CreateCollectionRequest matches Qdrant's API; Vectors supports single or named vectors.
type GraphStore ¶
type GraphStore interface {
UpsertGraph(ctx context.Context, record model.MemoryRecord, edges []model.GraphEdge) error
Neighborhood(ctx context.Context, sessionID string, seedIDs []int64, hops, limit int) ([]model.MemoryRecord, error)
}
GraphStore is implemented by vector stores that maintain graph neighborhoods for memories.
type InMemoryStore ¶
type InMemoryStore struct {
// contains filtered or unexported fields
}
InMemoryStore implements VectorStore for tests and lightweight deployments.
func NewInMemoryStore ¶
func NewInMemoryStore() *InMemoryStore
func (*InMemoryStore) DeleteMemory ¶
func (s *InMemoryStore) DeleteMemory(_ context.Context, ids []int64) error
func (*InMemoryStore) Iterate ¶
func (s *InMemoryStore) Iterate(_ context.Context, fn func(model.MemoryRecord) bool) error
func (*InMemoryStore) SearchMemory ¶
func (s *InMemoryStore) SearchMemory(_ context.Context, sessionID string, queryEmbedding []float32, limit int) ([]model.MemoryRecord, error)
func (*InMemoryStore) StoreMemory ¶
func (*InMemoryStore) UpdateEmbedding ¶
type MongoStore ¶
type MongoStore struct {
// contains filtered or unexported fields
}
func NewMongoStore ¶
func NewMongoStore(ctx context.Context, uri, database, collection string) (*MongoStore, error)
func (*MongoStore) Close ¶
func (ms *MongoStore) Close() error
Close releases the underlying MongoDB client.
func (*MongoStore) CreateSchema ¶
func (ms *MongoStore) CreateSchema(ctx context.Context, _ string) error
CreateSchema ensures the primary collection has useful indexes and initializes the counter collection.
func (*MongoStore) DeleteMemory ¶
func (ms *MongoStore) DeleteMemory(ctx context.Context, ids []int64) error
func (*MongoStore) Iterate ¶
func (ms *MongoStore) Iterate(ctx context.Context, fn func(model.MemoryRecord) bool) error
func (*MongoStore) SearchMemory ¶
func (ms *MongoStore) SearchMemory(ctx context.Context, sessionID string, queryEmbedding []float32, limit int) ([]model.MemoryRecord, error)
func (*MongoStore) StoreMemory ¶
func (*MongoStore) UpdateEmbedding ¶
type Neo4jAccessMode ¶
type Neo4jAccessMode string
Neo4jAccessMode controls whether a session is opened for read or write operations.
const ( // AccessModeWrite opens a session with write access. AccessModeWrite Neo4jAccessMode = "write" // AccessModeRead opens a session with read access. AccessModeRead Neo4jAccessMode = "read" )
type Neo4jSessionConfig ¶
type Neo4jSessionConfig struct {
AccessMode Neo4jAccessMode
DatabaseName string
}
Neo4jSessionConfig mirrors the minimal subset of Neo4j session configuration we require.
type Neo4jStore ¶
type Neo4jStore struct {
// contains filtered or unexported fields
}
Neo4jStore composes an existing VectorStore with a Neo4j-backed knowledge graph implementation.
Vector embeddings and similarity search remain delegated to the base store, while graph specific operations are persisted inside Neo4j.
func NewNeo4jStore ¶
func NewNeo4jStore(base VectorStore, driver neo4jDriver, database string) (*Neo4jStore, error)
NewNeo4jStore constructs a store that delegates vector operations to base and uses the provided Neo4j driver for graph persistence.
func (*Neo4jStore) Close ¶
func (s *Neo4jStore) Close() error
Close releases both the base store (when it implements Close) and the Neo4j driver.
func (*Neo4jStore) Count ¶
func (s *Neo4jStore) Count(ctx context.Context) (int, error)
Count forwards the call to the underlying vector store.
func (*Neo4jStore) CreateSchema ¶
func (s *Neo4jStore) CreateSchema(ctx context.Context, schemaPath string) error
CreateSchema delegates to the base store if it exposes SchemaInitializer and ensures Neo4j graph constraints are present.
func (*Neo4jStore) DeleteMemory ¶
func (s *Neo4jStore) DeleteMemory(ctx context.Context, ids []int64) error
DeleteMemory forwards the call to the underlying vector store.
func (*Neo4jStore) Iterate ¶
func (s *Neo4jStore) Iterate(ctx context.Context, fn func(model.MemoryRecord) bool) error
Iterate forwards the call to the underlying vector store.
func (*Neo4jStore) Neighborhood ¶
func (s *Neo4jStore) Neighborhood(ctx context.Context, sessionID string, seedIDs []int64, hops, limit int) ([]model.MemoryRecord, error)
Neighborhood returns the nodes within the requested number of hops from the provided seeds.
func (*Neo4jStore) SearchMemory ¶
func (s *Neo4jStore) SearchMemory(ctx context.Context, sessionID string, queryEmbedding []float32, limit int) ([]model.MemoryRecord, error)
SearchMemory delegates retrieval to the vector store. VectorStore requires ordered, normalized results, so rescoring here would duplicate the base store's hottest retrieval work.
func (*Neo4jStore) StoreMemory ¶
func (s *Neo4jStore) StoreMemory(ctx context.Context, sessionID, content string, metadata map[string]any, embedding []float32) error
StoreMemory forwards the call to the underlying vector store.
func (*Neo4jStore) UpdateEmbedding ¶
func (s *Neo4jStore) UpdateEmbedding(ctx context.Context, id int64, embedding []float32, lastEmbedded time.Time) error
UpdateEmbedding forwards the call to the underlying vector store.
func (*Neo4jStore) UpsertGraph ¶
func (s *Neo4jStore) UpsertGraph(ctx context.Context, record model.MemoryRecord, edges []model.GraphEdge) error
UpsertGraph ensures the corresponding Memory node exists in Neo4j and refreshes its outgoing relationships.
type PostgresStore ¶
PostgresStore implements VectorStore using Postgres + pgvector.
func NewPostgresStore ¶
func NewPostgresStore(ctx context.Context, connStr string) (*PostgresStore, error)
NewPostgresStore connects to Postgres and returns a Postgres-backed VectorStore implementation.
func (*PostgresStore) Close ¶
func (ps *PostgresStore) Close() error
Close releases the underlying Postgres connection pool.
func (*PostgresStore) CreateSchema ¶
func (ps *PostgresStore) CreateSchema(ctx context.Context, schemaPath string) error
CreateSchema ensures pgvector extension and memory table are available.
func (*PostgresStore) DeleteMemory ¶
func (ps *PostgresStore) DeleteMemory(ctx context.Context, ids []int64) error
func (*PostgresStore) Iterate ¶
func (ps *PostgresStore) Iterate(ctx context.Context, fn func(model.MemoryRecord) bool) error
func (*PostgresStore) Neighborhood ¶
func (ps *PostgresStore) Neighborhood(ctx context.Context, sessionID string, seedIDs []int64, hops, limit int) ([]model.MemoryRecord, error)
Neighborhood returns memories connected within the configured hop distance.
func (*PostgresStore) SearchMemory ¶
func (ps *PostgresStore) SearchMemory(ctx context.Context, sessionID string, queryEmbedding []float32, limit int) ([]model.MemoryRecord, error)
SearchMemory returns top-k similar memories from Postgres.
func (*PostgresStore) StoreMemory ¶
func (ps *PostgresStore) StoreMemory(ctx context.Context, sessionID, content string, metadata map[string]any, embedding []float32) error
StoreMemory inserts a long-term record into Postgres.
func (*PostgresStore) UpdateEmbedding ¶
func (*PostgresStore) UpsertGraph ¶
func (ps *PostgresStore) UpsertGraph(ctx context.Context, record model.MemoryRecord, edges []model.GraphEdge) error
UpsertGraph ensures the knowledge graph stays aligned with stored memories.
type QdrantStore ¶
type QdrantStore struct {
// contains filtered or unexported fields
}
Your store type.
func NewQdrantStore ¶
func NewQdrantStore(baseURL, collection, apiKey string) *QdrantStore
NewQdrantStore creates a Qdrant-backed VectorStore implementation.
func (*QdrantStore) Count ¶
func (qs *QdrantStore) Count(ctx context.Context) (int, error)
Count returns the total number of points in the collection.
func (*QdrantStore) CreateSchema ¶
func (qs *QdrantStore) CreateSchema(ctx context.Context, schemaPath string) error
CreateSchema implements SchemaInitializer. schemaPath must point to a JSON file that matches qdrantSchemaFile.
func (*QdrantStore) DeleteMemory ¶
func (qs *QdrantStore) DeleteMemory(ctx context.Context, ids []int64) error
DeleteMemory removes points by id.
func (*QdrantStore) Iterate ¶
func (qs *QdrantStore) Iterate(ctx context.Context, fn func(model.MemoryRecord) bool) error
Iterate streams through all points in created_at order.
func (*QdrantStore) Neighborhood ¶
func (qs *QdrantStore) Neighborhood(ctx context.Context, seedIDs []int64, hops, limit int) ([]model.MemoryRecord, error)
Neighborhood walks the edge payloads to return nearby memories.
func (*QdrantStore) SearchMemory ¶
func (qs *QdrantStore) SearchMemory(ctx context.Context, sessionID string, queryEmbedding []float32, limit int) ([]model.MemoryRecord, error)
SearchMemory performs a similarity search.
func (*QdrantStore) StoreMemory ¶
func (qs *QdrantStore) StoreMemory(ctx context.Context, sessionID, content string, metadata map[string]any, embedding []float32) error
StoreMemory upserts a memory point into Qdrant.
func (*QdrantStore) UpdateEmbedding ¶
func (qs *QdrantStore) UpdateEmbedding(ctx context.Context, id int64, embedding []float32, lastEmbedded time.Time) error
UpdateEmbedding updates the vector and last embedded timestamp.
func (*QdrantStore) UpsertGraph ¶
func (qs *QdrantStore) UpsertGraph(ctx context.Context, record model.MemoryRecord, edges []model.GraphEdge) error
UpsertGraph updates the stored payload to reflect graph metadata.
type SchemaInitializer ¶
SchemaInitializer allows stores to expose optional schema/bootstrap routines.
type VectorStore ¶
type VectorStore interface {
StoreMemory(ctx context.Context, sessionID, content string, metadata map[string]any, embedding []float32) error
SearchMemory(ctx context.Context, sessionID string, queryEmbedding []float32, limit int) ([]model.MemoryRecord, error)
UpdateEmbedding(ctx context.Context, id int64, embedding []float32, lastEmbedded time.Time) error
DeleteMemory(ctx context.Context, ids []int64) error
Iterate(ctx context.Context, fn func(model.MemoryRecord) bool) error
Count(ctx context.Context) (int, error)
}
VectorStore defines the contract for long-term memory backends.