Documentation
¶
Overview ¶
Package memory provides a stable, library-first API for using the libSQL-backed knowledge graph and vector search engine without running the MCP server transport.
Quickstart:
cfg := &memory.Config{ URL: "file:./libsql.db", EmbeddingDims: 1536 }
svc, err := memory.NewService(cfg)
if err != nil { log.Fatal(err) }
defer svc.Close()
ctx := context.Background()
_ = svc.CreateEntities(ctx, "default", []memory.Entity{{
Name: "Task:1", EntityType: "Task", Observations: []string{"Hello"},
}})
ents, rels, err := svc.SearchText(ctx, "default", "Hello", 10, 0)
_ = ents; _ = rels; _ = err
Index ¶
- type Config
- type Entity
- type GraphResult
- type Relation
- type SearchResult
- type Service
- func (s *Service) AddObservations(ctx context.Context, project, entityName string, observations []string) error
- func (s *Service) Close() error
- func (s *Service) CreateEntities(ctx context.Context, project string, ents []Entity) error
- func (s *Service) CreateRelations(ctx context.Context, project string, rels []Relation) error
- func (s *Service) DeleteEntities(ctx context.Context, project string, names []string) error
- func (s *Service) DeleteEntity(ctx context.Context, project, name string) error
- func (s *Service) DeleteObservations(ctx context.Context, project, entity string, ids []int64, contents []string) (int64, error)
- func (s *Service) DeleteRelation(ctx context.Context, project, source, target, relationType string) error
- func (s *Service) DeleteRelations(ctx context.Context, project string, rels []Relation) error
- func (s *Service) DisableHybridSearch()
- func (s *Service) EnableHybridSearch(textWeight, vectorWeight, rrfK float64)
- func (s *Service) Neighbors(ctx context.Context, project string, names []string, direction string, ...) ([]Entity, []Relation, error)
- func (s *Service) OpenNodes(ctx context.Context, project string, names []string, includeRelations bool) ([]Entity, []Relation, error)
- func (s *Service) ReadGraph(ctx context.Context, project string, limit int) ([]Entity, []Relation, error)
- func (s *Service) SearchSimilar(ctx context.Context, project string, embedding []float32, limit, offset int) ([]SearchResult, error)
- func (s *Service) SearchText(ctx context.Context, project string, query string, limit, offset int) ([]Entity, []Relation, error)
- func (s *Service) SearchVector(ctx context.Context, project string, vector []float32, limit, offset int) ([]Entity, []Relation, error)
- func (s *Service) ShortestPath(ctx context.Context, project, from, to, direction string) ([]Entity, []Relation, error)
- func (s *Service) UpdateEntities(ctx context.Context, project string, updates []UpdateEntitySpec) error
- func (s *Service) UpdateRelations(ctx context.Context, project string, updates []UpdateRelationChange) error
- func (s *Service) Walk(ctx context.Context, project string, names []string, maxDepth int, ...) ([]Entity, []Relation, error)
- type UpdateEntitySpec
- type UpdateRelationChange
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
URL string
AuthToken string
ProjectsDir string
MultiProjectMode bool
EmbeddingDims int
MaxOpenConns int
MaxIdleConns int
ConnMaxIdleSec int
ConnMaxLifeSec int
EmbeddingsProvider string
}
Config exposes a stable wrapper for database configuration in package mode. Most fields map directly to internal/database.Config.
type GraphResult ¶ added in v0.6.0
type GraphResult = apptype.GraphResult
type SearchResult ¶ added in v0.6.0
type SearchResult = apptype.SearchResult
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides a library-first API for memory operations without MCP transport.
func NewService ¶
NewService constructs a Service with the provided config.
func (*Service) AddObservations ¶
func (s *Service) AddObservations(ctx context.Context, project, entityName string, observations []string) error
AddObservations appends observations to an entity.
func (*Service) CreateEntities ¶
CreateEntities inserts entities.
func (*Service) CreateRelations ¶
CreateRelations inserts relations.
func (*Service) DeleteEntities ¶
func (*Service) DeleteEntity ¶
Deletes / Updates
func (*Service) DeleteObservations ¶
func (*Service) DeleteRelation ¶
func (*Service) DeleteRelations ¶
func (*Service) DisableHybridSearch ¶
func (s *Service) DisableHybridSearch()
func (*Service) EnableHybridSearch ¶
Hybrid search toggles
func (*Service) Neighbors ¶
func (s *Service) Neighbors(ctx context.Context, project string, names []string, direction string, limit int) ([]Entity, []Relation, error)
Graph helpers
func (*Service) OpenNodes ¶
func (s *Service) OpenNodes(ctx context.Context, project string, names []string, includeRelations bool) ([]Entity, []Relation, error)
OpenNodes fetches entities (and optionally relations) by names.
func (*Service) ReadGraph ¶
func (s *Service) ReadGraph(ctx context.Context, project string, limit int) ([]Entity, []Relation, error)
ReadGraph returns recent entities + relations with limit.
func (*Service) SearchSimilar ¶ added in v0.6.0
func (s *Service) SearchSimilar(ctx context.Context, project string, embedding []float32, limit, offset int) ([]SearchResult, error)
SearchSimilar returns entities ranked by vector distance from the given embedding. Distance is cosine distance (lower is closer) when libSQL vector functions are available.
func (*Service) SearchText ¶
func (s *Service) SearchText(ctx context.Context, project string, query string, limit, offset int) ([]Entity, []Relation, error)
SearchText performs text search via underlying DB.
func (*Service) SearchVector ¶
func (s *Service) SearchVector(ctx context.Context, project string, vector []float32, limit, offset int) ([]Entity, []Relation, error)
SearchVector performs vector search.
func (*Service) ShortestPath ¶
func (*Service) UpdateEntities ¶
func (*Service) UpdateRelations ¶
type UpdateEntitySpec ¶ added in v0.6.0
type UpdateEntitySpec = apptype.UpdateEntitySpec
type UpdateRelationChange ¶ added in v0.6.0
type UpdateRelationChange = apptype.UpdateRelationChange