memory

package
v0.0.0-...-7f732e0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2026 License: AGPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultEmbeddingModel emits 4096-d vectors natively; we truncate to
	// embeddingDimensions via Matryoshka so pgvector's halfvec HNSW dim cap holds.
	DefaultEmbeddingModel     = "qwen/qwen3-embedding-8b"
	DefaultContradictionModel = "mistralai/mistral-medium-3-5"

	DefaultHalfLife           = 7 * 24 * time.Hour
	DefaultHardCap            = 5000
	DefaultDedupeUpper        = 0.92
	DefaultDedupeLower        = 0.65
	DefaultForgetAmbiguityGap = 0.05
	DefaultPerResultBytes     = 1024
	DefaultAggregateBytes     = 8192
	DefaultTruncationSuffix   = "…"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ForgetCandidate

type ForgetCandidate struct {
	ID         uuid.UUID
	Content    string
	Similarity float64
}

type ForgetResult

type ForgetResult struct {
	Forgotten  bool
	ID         *uuid.UUID
	Content    *string
	Reason     string // "" | "no_match" | "ambiguous"
	Candidates []ForgetCandidate
}

type ListParams

type ListParams struct {
	AssistantID     uuid.UUID
	Tags            []string
	IncludeDeleted  bool
	CursorCreatedAt *time.Time
	CursorID        *uuid.UUID
	Limit           int32
}

type ListResult

type ListResult struct {
	Memories []repo.ListAssistantMemoriesForAdminRow
}

type MemoryService

type MemoryService struct {
	// contains filtered or unexported fields
}

func NewMemoryService

func NewMemoryService(
	logger *slog.Logger,
	tracerProvider trace.TracerProvider,
	meterProvider metric.MeterProvider,
	db *pgxpool.Pool,
	completions openrouter.CompletionClient,
	auditLogger *audit.Logger,
) *MemoryService

func (*MemoryService) DeleteByID

func (s *MemoryService) DeleteByID(ctx context.Context, projectID uuid.UUID, id uuid.UUID) (err error)

func (*MemoryService) Forget

func (s *MemoryService) Forget(
	ctx context.Context,
	assistantID uuid.UUID,
	projectID uuid.UUID,
	organizationID string,
	query string,
	tags []string,
) (result ForgetResult, err error)

func (*MemoryService) Get

func (*MemoryService) List

func (s *MemoryService) List(ctx context.Context, projectID uuid.UUID, params ListParams) (ListResult, error)

func (*MemoryService) Recall

func (s *MemoryService) Recall(
	ctx context.Context,
	assistantID uuid.UUID,
	organizationID string,
	query string,
	limit int,
	tags []string,
) (results []RecallResult, err error)

Recall finds the nearest active memories for an assistant. Embedding errors degrade to an empty result so recall failure is a recall miss for the agent.

func (*MemoryService) Remember

func (s *MemoryService) Remember(
	ctx context.Context,
	assistantID uuid.UUID,
	projectID uuid.UUID,
	organizationID string,
	content string,
	tags []string,
) (result RememberResult, err error)

type RecallResult

type RecallResult struct {
	ID         uuid.UUID
	Content    string
	Tags       []string
	Score      float64
	Similarity float64
	CreatedAt  time.Time
}

type RememberResult

type RememberResult struct {
	ID           uuid.UUID
	CreatedAt    time.Time
	Deduped      bool
	SupersededID *uuid.UUID
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL