Documentation
¶
Index ¶
- Variables
- func ContentHash(content string) string
- type Manager
- func (m *Manager) Add(ctx context.Context, content string, memType MemoryType, filter *SearchFilter, ...) (*Memory, error)
- func (m *Manager) Delete(ctx context.Context, id string) error
- func (m *Manager) Get(ctx context.Context, id string) (*Memory, error)
- func (m *Manager) List(ctx context.Context, filter *SearchFilter, limit, offset int) ([]*Memory, int, error)
- func (m *Manager) Search(ctx context.Context, query string, k int, filter *SearchFilter) ([]SearchResult, error)
- func (m *Manager) Stats(ctx context.Context, filter *SearchFilter) (*Stats, error)
- func (m *Manager) Update(ctx context.Context, id string, content *string, metadata map[string]any) (*Memory, error)
- type Memory
- type MemoryType
- type SearchFilter
- type SearchResult
- type Stats
- type VectorStore
Constants ¶
This section is empty.
Variables ¶
View Source
var ValidMemoryTypes = map[MemoryType]bool{ TypeFact: true, TypeConversation: true, TypeDecision: true, TypeCodePattern: true, TypeCorrection: true, }
Functions ¶
func ContentHash ¶
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func NewManager(s VectorStore, e embedding.Provider) *Manager
func (*Manager) Add ¶
func (m *Manager) Add(ctx context.Context, content string, memType MemoryType, filter *SearchFilter, metadata map[string]any) (*Memory, error)
func (*Manager) Search ¶
func (m *Manager) Search(ctx context.Context, query string, k int, filter *SearchFilter) ([]SearchResult, error)
type Memory ¶
type Memory struct {
ID string `json:"id"`
Content string `json:"content"`
MemoryType MemoryType `json:"memory_type"`
UserID string `json:"user_id,omitempty"`
AgentID string `json:"agent_id,omitempty"`
AppID string `json:"app_id,omitempty"`
RunID string `json:"run_id,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
ContentHash string `json:"content_hash"`
Embedding []float32 `json:"-"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type MemoryType ¶
type MemoryType string
const ( TypeFact MemoryType = "fact" TypeConversation MemoryType = "conversation" TypeDecision MemoryType = "decision" TypeCodePattern MemoryType = "code_pattern" TypeCorrection MemoryType = "correction" )
func (MemoryType) Valid ¶
func (mt MemoryType) Valid() bool
type SearchFilter ¶
type SearchFilter struct {
UserID string `json:"user_id,omitempty"`
AgentID string `json:"agent_id,omitempty"`
AppID string `json:"app_id,omitempty"`
RunID string `json:"run_id,omitempty"`
MemoryType MemoryType `json:"memory_type,omitempty"`
Since *time.Time `json:"since,omitempty"`
Until *time.Time `json:"until,omitempty"`
}
type SearchResult ¶
type VectorStore ¶
type VectorStore interface {
Insert(ctx context.Context, mem *Memory) error
Update(ctx context.Context, mem *Memory) error
Delete(ctx context.Context, id string) error
Get(ctx context.Context, id string) (*Memory, error)
GetByHash(ctx context.Context, contentHash string, filter *SearchFilter) (*Memory, error)
Search(ctx context.Context, vector []float32, k int, filter *SearchFilter) ([]SearchResult, error)
List(ctx context.Context, filter *SearchFilter, limit, offset int) ([]*Memory, int, error)
Stats(ctx context.Context, filter *SearchFilter) (*Stats, error)
Close() error
}
VectorStore is the storage interface for memories. Implementations live in internal/store.
Click to show internal directories.
Click to hide internal directories.