memory

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package memory persists AI conversations and assembles context windows.

Index

Constants

View Source
const DefaultTitle = "New conversation"

DefaultTitle marks an untitled conversation; auto-titling only replaces it.

Variables

This section is empty.

Functions

func TitleFrom

func TitleFrom(msg string) string

TitleFrom derives a short fallback title from a message.

Types

type MessagePage

type MessagePage struct {
	Messages    []models.AIMessage `json:"messages"`
	LoadedCount int                `json:"loadedCount"`
	TotalCount  int                `json:"totalCount"`
	HasMore     bool               `json:"hasMore"`
}

MessagePage is one UI window of conversation messages.

type Store

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

Store is the conversation persistence and context-assembly surface.

func New

New wires the conversation and message repos.

func (*Store) AppendAssistant

func (s *Store) AppendAssistant(ctx context.Context, convID, content, reasoning string, calls []models.AIToolCallRecord, truncated bool) error

AppendAssistant stores a finalized assistant message.

func (*Store) AppendUser

func (s *Store) AppendUser(ctx context.Context, convID, content string) error

AppendUser stores a user message.

func (*Store) Create

func (s *Store) Create(ctx context.Context, ownerID, connID, providerID, model string) (models.AIConversation, error)

Create starts a new conversation owned by the user on a connection.

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, ownerID, id string) error

Delete removes an owned conversation and its messages.

func (*Store) Get

func (s *Store) Get(ctx context.Context, ownerID, id string) (models.AIConversation, error)

Get returns an owned conversation (others are hidden as not-found).

func (*Store) History

func (s *Store) History(ctx context.Context, convID string, tokenBudget int) (summary string, msgs []engine.Message, err error)

History returns compacted older turns plus recent messages within tokenBudget.

func (*Store) List

func (s *Store) List(ctx context.Context, ownerID, connID string) ([]models.AIConversation, error)

List returns the user's conversations for a connection (newest first).

func (*Store) MessageCount

func (s *Store) MessageCount(ctx context.Context, convID string) int

MessageCount returns how many messages a conversation has.

func (*Store) Messages

func (s *Store) Messages(ctx context.Context, ownerID, id string) ([]models.AIMessage, error)

Messages returns a conversation's full ordered message history.

func (*Store) MessagesPage

func (s *Store) MessagesPage(ctx context.Context, ownerID, convID string, limit, loadedCount int) (MessagePage, error)

MessagesPage returns one page of an owned conversation's history.

func (*Store) Rename

func (s *Store) Rename(ctx context.Context, ownerID, id, title string) (models.AIConversation, error)

Rename sets a user-provided title (clearing the auto-titled flag).

func (*Store) SetAutoTitle

func (s *Store) SetAutoTitle(ctx context.Context, convID, title string)

SetAutoTitle sets a system-generated title, leaving a user-set title untouched.

Jump to

Keyboard shortcuts

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