Documentation
¶
Index ¶
- func GenerateInputSchema[T any]() map[string]any
- func NewForgetTool[T any](store *Store[T], opts ...Option) tool.Tool
- func NewRecallTool[T any](store *Store[T], opts ...Option) tool.Tool
- func NewRememberTool[T any](store *Store[T], opts ...Option) tool.Tool
- func NewUpdateTool[T any](store *Store[T], opts ...Option) tool.Tool
- type Option
- type RecallOption
- func WithFieldEquals(column string, value any) RecallOption
- func WithFieldGT(column string, value any) RecallOption
- func WithFieldIn(column string, values any) RecallOption
- func WithFieldLT(column string, value any) RecallOption
- func WithMinSimilarity(threshold float64) RecallOption
- func WithOrderBy(column string, dir SortDir) RecallOption
- func WithRawFilter(sql string, args ...any) RecallOption
- func WithTimeAfter(column string, t time.Time) RecallOption
- func WithTimeBefore(column string, t time.Time) RecallOption
- type SortDir
- type Store
- func (s *Store[T]) Close()
- func (s *Store[T]) Forget(ctx context.Context, identifier, id string) error
- func (s *Store[T]) ForgetAll(ctx context.Context, identifier string) error
- func (s *Store[T]) Recall(ctx context.Context, identifier string, query string, limit int, ...) ([]memory.Entry[T], error)
- func (s *Store[T]) Remember(ctx context.Context, identifier string, value T) error
- func (s *Store[T]) Update(ctx context.Context, identifier, id string, value T) error
- type StoreOption
- type ToolOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateInputSchema ¶ added in v0.31.0
GenerateInputSchema produces a JSON Schema for the LLM tool input, excluding fields tagged with pk, identifier, or noinput.
func NewForgetTool ¶ added in v0.35.0
NewForgetTool creates a tool that removes a single entry by ID.
func NewRecallTool ¶ added in v0.31.0
NewRecallTool creates a tool that retrieves values from a Store. RecallOptions passed here apply as default filters to every call.
func NewRememberTool ¶ added in v0.31.0
NewRememberTool creates a tool that stores values into a Store.
Types ¶
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option configures NewRememberTool or NewRecallTool. Both ToolOption and RecallOption satisfy this interface, so you can pass them interchangeably.
type RecallOption ¶ added in v0.31.0
type RecallOption func(*recallConfig)
RecallOption configures filtering and sorting for Recall queries.
func WithFieldEquals ¶ added in v0.31.0
func WithFieldEquals(column string, value any) RecallOption
WithFieldEquals adds a WHERE column = value filter.
func WithFieldGT ¶ added in v0.31.0
func WithFieldGT(column string, value any) RecallOption
WithFieldGT adds a WHERE column > value filter.
func WithFieldIn ¶ added in v0.31.0
func WithFieldIn(column string, values any) RecallOption
WithFieldIn adds a WHERE column = ANY($n) filter for slice values. The values slice is passed directly to pgx — use a typed slice (e.g. []string) for correct encoding.
func WithFieldLT ¶ added in v0.31.0
func WithFieldLT(column string, value any) RecallOption
WithFieldLT adds a WHERE column < value filter.
func WithMinSimilarity ¶ added in v0.31.0
func WithMinSimilarity(threshold float64) RecallOption
WithMinSimilarity sets a minimum similarity threshold. Only results with similarity >= this value are returned. This filters by vector distance before applying the limit.
func WithOrderBy ¶ added in v0.31.0
func WithOrderBy(column string, dir SortDir) RecallOption
WithOrderBy adds an ORDER BY clause. Multiple calls append additional sort keys. Vector similarity is always the primary sort unless overridden by explicit ordering.
func WithRawFilter ¶ added in v0.31.0
func WithRawFilter(sql string, args ...any) RecallOption
WithRawFilter adds a raw SQL WHERE clause with parameterized arguments. Use ? as placeholder — they'll be renumbered to $N automatically.
func WithTimeAfter ¶ added in v0.31.0
func WithTimeAfter(column string, t time.Time) RecallOption
WithTimeAfter adds a WHERE column > timestamp filter.
func WithTimeBefore ¶ added in v0.31.0
func WithTimeBefore(column string, t time.Time) RecallOption
WithTimeBefore adds a WHERE column < timestamp filter.
func (RecallOption) IsRecallOption ¶ added in v0.34.0
func (RecallOption) IsRecallOption()
type SortDir ¶ added in v0.31.0
type SortDir string
SortDir is the sort direction for ORDER BY clauses.
type Store ¶ added in v0.24.0
type Store[T any] struct { // contains filtered or unexported fields }
Store is a PostgreSQL memory store that maps Go struct fields to table columns using `db` struct tags. The table must be created by the caller.
func NewStore ¶ added in v0.31.0
func NewStore[T any](pool *pgxpool.Pool, embedder agent.Embedder, dim int, opts ...StoreOption) (*Store[T], error)
NewStore creates a Store for the given struct type T.
func (*Store[T]) Close ¶ added in v0.24.0
func (s *Store[T]) Close()
Close closes the underlying connection pool.
func (*Store[T]) Forget ¶ added in v0.31.0
Forget removes a single entry by its primary key, scoped to the identifier.
func (*Store[T]) ForgetAll ¶ added in v0.31.0
ForgetAll removes all stored entries for the given identifier.
func (*Store[T]) Recall ¶ added in v0.24.0
func (s *Store[T]) Recall(ctx context.Context, identifier string, query string, limit int, opts ...memory.RecallOption) ([]memory.Entry[T], error)
Recall retrieves values by semantic similarity, scoped to the identifier.
type StoreOption ¶ added in v0.24.0
type StoreOption func(*storeConfig)
StoreOption configures a Store.
func WithDistanceMetric ¶ added in v0.24.0
func WithDistanceMetric(metric string) StoreOption
WithDistanceMetric sets the distance metric for vector queries. Supported: "cosine" (default), "l2", "inner_product".
func WithEmbeddingColumn ¶ added in v0.31.0
func WithEmbeddingColumn(name string) StoreOption
WithEmbeddingColumn sets the name of the vector embedding column. Default: "embedding".
func WithTableName ¶
func WithTableName(name string) StoreOption
WithTableName sets the table name. Default: inferred from struct name (lowercased + "s").
type ToolOption ¶ added in v0.31.0
type ToolOption func(*toolConfig)
ToolOption configures tool metadata (name, description).
func WithToolDescription ¶ added in v0.31.0
func WithToolDescription(desc string) ToolOption
WithToolDescription sets the tool description.
func WithToolName ¶ added in v0.31.0
func WithToolName(name string) ToolOption
WithToolName sets the tool name. Default: "remember" / "recall".