Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotFound = errors.New("memory: not found")
Functions ¶
func EncodeRecord ¶ added in v0.1.5
func EncodeRecord(record CognitiveRecord) (json.RawMessage, error)
EncodeRecord serializes a cognitive record for repository storage.
Types ¶
type CognitiveMemory ¶ added in v0.1.5
type CognitiveMemory interface {
Remember(ctx context.Context, ns Namespace, record CognitiveRecord) error
Recall(ctx context.Context, ns Namespace, query string, limit int) ([]CognitiveRecord, error)
}
CognitiveMemory stores and recalls scored memories for agents.
type CognitiveRecord ¶ added in v0.1.5
type CognitiveRecord struct {
ID string `json:"id"`
Content string `json:"content"`
Scope string `json:"scope"`
Categories []string `json:"categories,omitempty"`
Importance float64 `json:"importance"`
CreatedAt time.Time `json:"created_at"`
Metadata map[string]string `json:"metadata,omitempty"`
}
CognitiveRecord is a scored long-term memory entry.
func DecodeRecord ¶ added in v0.1.5
func DecodeRecord(raw json.RawMessage) (CognitiveRecord, error)
DecodeRecord deserializes a cognitive record from repository storage.
type Entry ¶
type Entry struct {
Key string `json:"key"`
Value json.RawMessage `json:"value"`
}
type Namespace ¶
type RecallScore ¶ added in v0.1.5
type RecallScore struct {
Record CognitiveRecord
Score float64
}
RecallScore ranks a memory for composite recall scoring.
func RankMemories ¶ added in v0.1.5
func RankMemories(query string, records []CognitiveRecord, now time.Time, semanticWeight, recencyWeight, importanceWeight float64) []RecallScore
RankMemories applies semantic overlap, recency, and importance weighting.
type Repository ¶
type Repository interface {
Get(ctx context.Context, ns Namespace, key string) (json.RawMessage, error)
Set(ctx context.Context, ns Namespace, key string, value json.RawMessage) error
Append(ctx context.Context, ns Namespace, key string, value json.RawMessage) error
Delete(ctx context.Context, ns Namespace, key string) error
// List returns all entries whose keys begin with prefix within the
// namespace. An empty prefix matches all keys in the namespace.
List(ctx context.Context, ns Namespace, prefix string) ([]Entry, error)
}
Click to show internal directories.
Click to hide internal directories.