memory

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2026 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func VectorLiteral

func VectorLiteral(v []float32) string

VectorLiteral converts a vector to the pgvector literal format.

Types

type Embedder

type Embedder interface {
	Embed(ctx context.Context, text string) ([]float32, error)
}

Embedder produces vector embeddings from text.

type InMemoryStore

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

InMemoryStore is a small process-local Store implementation for SDK clients that do not need durable storage. Search uses simple substring keyword matching, not vector similarity — for true semantic search, plug in a Store backed by a vector database.

func NewInMemoryStore

func NewInMemoryStore() *InMemoryStore

NewInMemoryStore returns an empty in-memory memory store.

func (*InMemoryStore) Delete

func (s *InMemoryStore) Delete(_ context.Context, namespace string, id uuid.UUID) error

func (*InMemoryStore) List

func (s *InMemoryStore) List(_ context.Context, namespace string, tags []string, limit int) ([]Memory, error)

func (*InMemoryStore) Search

func (s *InMemoryStore) Search(_ context.Context, namespace, query string, tags []string, limit int) ([]Memory, error)

func (*InMemoryStore) Store

func (s *InMemoryStore) Store(_ context.Context, namespace, content string, tags []string, sourceRun string, metadata json.RawMessage) (*Memory, error)

type Memory

type Memory struct {
	ID         uuid.UUID       `json:"id"`
	Namespace  string          `json:"namespace"`
	Content    string          `json:"content"`
	Tags       []string        `json:"tags"`
	SourceRun  string          `json:"source_run"`
	Metadata   json.RawMessage `json:"metadata"`
	Similarity float64         `json:"similarity,omitempty"`
	CreatedAt  time.Time       `json:"created_at"`
}

Memory represents a single stored memory entry.

type NoopEmbedder

type NoopEmbedder struct {
	Dimension int
}

NoopEmbedder returns all-zero embeddings and is useful for local examples.

func (*NoopEmbedder) Embed

func (e *NoopEmbedder) Embed(_ context.Context, _ string) ([]float32, error)

type OpenAIEmbedder

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

OpenAIEmbedder embeds text through the OpenAI embeddings API.

func NewOpenAIEmbedder

func NewOpenAIEmbedder(auth *openai.OpenAIAuthSession, baseURL string, model string) *OpenAIEmbedder

func (*OpenAIEmbedder) Embed

func (e *OpenAIEmbedder) Embed(ctx context.Context, text string) ([]float32, error)

func (*OpenAIEmbedder) SetHTTPClient

func (e *OpenAIEmbedder) SetHTTPClient(client *http.Client)

SetHTTPClient overrides the HTTP client, mainly for tests.

type Store

type Store interface {
	Store(ctx context.Context, namespace, content string, tags []string, sourceRun string, metadata json.RawMessage) (*Memory, error)
	Search(ctx context.Context, namespace, query string, tags []string, limit int) ([]Memory, error)
	List(ctx context.Context, namespace string, tags []string, limit int) ([]Memory, error)
	Delete(ctx context.Context, namespace string, id uuid.UUID) error
}

Store persists and retrieves semantic memories.

Jump to

Keyboard shortcuts

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