memory

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: Apache-2.0 Imports: 7 Imported by: 9

Documentation

Overview

Package memory defines the entities to interact with agent memory (long-term knowledge).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	// Content contains the main content of the memory.
	Content *genai.Content
	// Author of the memory.
	Author string
	// Timestamp shows when the original content of this memory happened.
	// This string will be forwarded to LLM. Preferred format is ISO 8601 format.
	Timestamp time.Time
}

Entry represents a single memory entry.

type SearchRequest

type SearchRequest struct {
	Query   string
	UserID  string
	AppName string
}

SearchRequest represents a request for memory search.

type SearchResponse

type SearchResponse struct {
	Memories []Entry
}

SearchResponse represents the response from a memory search.

type Service

type Service interface {
	// AddSession adds a session to the memory service.
	//
	// A session can be added multiple times during its lifetime.
	AddSession(ctx context.Context, s session.Session) error
	// Search returns memory entries relevant to the given query.
	// Empty slice is returned if there are no matches.
	Search(ctx context.Context, req *SearchRequest) (*SearchResponse, error)
}

Service is a definition of the memory service.

The service ingests sessions into memory so that it can be used for user queries across user-scoped sessions.

func InMemoryService

func InMemoryService() Service

InMemoryService returns a new in-memory implementation of the memory service. Thread-safe.

Jump to

Keyboard shortcuts

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