mem0

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: BSD-2-Clause Imports: 15 Imported by: 0

Documentation

Overview

Package mem0 adds long-term memory to a jargo voice agent, backed by a mem0 server (https://github.com/mem0ai/mem0).

It is a frame processor placed between the user aggregator and the LLM. On each turn it searches mem0 for memories relevant to the user's latest message and folds them into the context's system prompt (see frames.LLMContext.SetRecall), then stores the new user and assistant turns back to mem0 in the background so retrieval never blocks on writes.

mem := mem0.NewMemory(mem0.Config{Host: "http://localhost:8000", UserID: caller})
pipeline.New(input, stt, agg.User(), mem, llm, tts, output, agg.Assistant())

Point Host at a mem0 REST server — self-hosted, or the managed API with an APIKey — and scope memories to a caller with UserID. Memory is best-effort: search and store failures are logged and never break the conversation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Host is the base URL of the mem0 REST server, e.g. http://localhost:8000.
	// Required.
	Host string `validate:"required"`
	// APIKey is an optional bearer token sent as "Authorization: Token <key>"
	// (the managed mem0 API, or a secured self-hosted server).
	APIKey string
	// UserID scopes memories to a caller. Recommended; without it memories are
	// not partitioned per user.
	UserID string
	// AgentID and RunID optionally scope memories to an agent or a session.
	AgentID string
	RunID   string
	// SearchLimit caps how many memories are retrieved per turn; 0 uses a default.
	SearchLimit int
	// SearchThreshold is the minimum relevance score for a memory to be used; 0
	// leaves the cutoff to the server.
	SearchThreshold float64
	// Timeout bounds a single mem0 request; 0 uses a default.
	Timeout time.Duration
	// HTTPClient overrides the HTTP client; nil uses one with Timeout.
	HTTPClient *http.Client
}

Config configures the memory service.

func (Config) Validate

func (c Config) Validate() error

Validate reports whether the configuration is usable.

type Service

type Service struct {
	*processor.Base
	// contains filtered or unexported fields
}

Service is the memory frame processor.

func NewMemory

func NewMemory(cfg Config) *Service

NewMemory builds a memory service from cfg.

func (*Service) ProcessFrame

func (s *Service) ProcessFrame(ctx context.Context, f frames.Frame, dir processor.Direction) error

ProcessFrame retrieves and stores memory around the LLM context, forwarding every frame untouched.

Jump to

Keyboard shortcuts

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