postgres

package module
v0.70.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateInputSchema added in v0.31.0

func GenerateInputSchema[T any]() map[string]any

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

func NewForgetTool[T any](
	store *Store[T],
	opts ...Option,
) tool.Tool

NewForgetTool creates a tool that removes a single entry by ID.

func NewRecallTool added in v0.31.0

func NewRecallTool[T any](
	store *Store[T],
	opts ...Option,
) tool.Tool

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

func NewRememberTool[T any](
	store *Store[T],
	opts ...Option,
) tool.Tool

NewRememberTool creates a tool that stores values into a Store.

func NewUpdateTool added in v0.35.0

func NewUpdateTool[T any](
	store *Store[T],
	opts ...Option,
) tool.Tool

NewUpdateTool creates a tool that updates an existing entry by ID.

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.

const (
	Asc  SortDir = "ASC"
	Desc SortDir = "DESC"
)

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

func (s *Store[T]) Forget(ctx context.Context, identifier, id string) error

Forget removes a single entry by its primary key, scoped to the identifier.

func (*Store[T]) ForgetAll added in v0.31.0

func (s *Store[T]) ForgetAll(ctx context.Context, identifier string) error

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.

func (*Store[T]) Remember added in v0.24.0

func (s *Store[T]) Remember(ctx context.Context, identifier string, value T) error

Remember stores a value for the given identifier.

func (*Store[T]) Update added in v0.35.0

func (s *Store[T]) Update(ctx context.Context, identifier, id string, value T) error

Update replaces an existing entry by primary key, re-embedding the content.

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".

Jump to

Keyboard shortcuts

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