Documentation
¶
Overview ¶
Package weaviate provides a interfaces.Memory implementation backed by Weaviate.
Expected class schema (vectorizer should target the text field):
{
"class": "AgentMemory",
"vectorizer": "text2vec-...",
"properties": [
{"name": "text", "dataType": ["text"]},
{"name": "kind", "dataType": ["text"]},
{"name": "user_id", "dataType": ["text"]},
{"name": "tenant_id", "dataType": ["text"]},
{"name": "agent_id", "dataType": ["text"]},
{"name": "scope_tags", "dataType": ["text[]"]},
{"name": "metadata", "dataType": ["text"]},
{"name": "expires_at", "dataType": ["date"]},
{"name": "created_at", "dataType": ["date"]},
{"name": "updated_at", "dataType": ["date"]}
]
}
Index ¶
- Constants
- type Memory
- func (m *Memory) Clear(ctx context.Context, scope interfaces.MemoryScope) error
- func (m *Memory) Load(ctx context.Context, scope interfaces.MemoryScope, query string, ...) ([]interfaces.MemoryEntry, error)
- func (m *Memory) Store(ctx context.Context, scope interfaces.MemoryScope, ...) (string, error)
- type Option
- func WithClassName(className string) Option
- func WithClient(c *client.Client) Option
- func WithDefaultLimit(limit int) Option
- func WithDefaultMinScore(minScore float32) Option
- func WithHost(host string) Option
- func WithLogLevel(logLevel string) Option
- func WithLogger(l logger.Logger) Option
- func WithScheme(scheme string) Option
- func WithTenant(tenant string) Option
- func WithTextField(textField string) Option
Constants ¶
const ( DefaultClassName = "AgentMemory" DefaultTextField = "text" PropKind = "kind" PropMetadata = "metadata" PropScopeTags = "scope_tags" PropExpiresAt = "expires_at" PropCreatedAt = "created_at" PropUpdatedAt = "updated_at" PropUserID = memory.ScopeKeyUserID PropTenantID = memory.ScopeKeyTenantID PropAgentID = memory.ScopeKeyAgentID )
Default Weaviate class and property names for Memory.
const DefaultLoadLimit = 10
DefaultLoadLimit is the maximum memories returned when interfaces.WithLoadLimit is zero or negative.
const DefaultMinScore float32 = 0.35
DefaultMinScore is the default nearText certainty when interfaces.WithMinScore is zero.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Memory ¶
type Memory struct {
// contains filtered or unexported fields
}
Memory stores and recalls agent memories in a Weaviate class.
func NewMemory ¶
NewMemory builds a Weaviate-backed interfaces.Memory. When WithClient is omitted, host is required.
func (*Memory) Clear ¶
func (m *Memory) Clear(ctx context.Context, scope interfaces.MemoryScope) error
Clear removes all memories matching scope.
func (*Memory) Load ¶
func (m *Memory) Load(ctx context.Context, scope interfaces.MemoryScope, query string, opts ...interfaces.LoadMemoryOption) ([]interfaces.MemoryEntry, error)
Load recalls memories within scope. Non-empty query uses nearText; empty query lists by updated_at.
func (*Memory) Store ¶
func (m *Memory) Store(ctx context.Context, scope interfaces.MemoryScope, record interfaces.MemoryRecord, opts ...interfaces.StoreMemoryOption) (string, error)
Store persists a memory in scope and returns its ID.
type Option ¶
type Option func(*Memory)
Option configures Memory.
func WithClassName ¶
WithClassName sets the Weaviate class name. Defaults to DefaultClassName.
func WithDefaultLimit ¶
WithDefaultLimit sets the load limit when callers omit interfaces.WithLoadLimit.
func WithDefaultMinScore ¶
WithDefaultMinScore sets the nearText certainty when callers omit interfaces.WithMinScore.
func WithHost ¶
WithHost sets the Weaviate host (required when WithClient is omitted).
func WithLogLevel ¶
WithLogLevel sets the log level when no logger is provided.
func WithScheme ¶
WithScheme sets the Weaviate scheme. Defaults to types.DefaultScheme.
func WithTenant ¶
WithTenant sets the Weaviate multi-tenancy tenant for all operations.
func WithTextField ¶
WithTextField sets the property used for memory text and vectorization. Defaults to DefaultTextField.