common

package
v0.2.4 Latest Latest
Warning

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

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

Documentation

Overview

Package common holds shared configuration and agent options for the agent_with_memory examples.

Index

Constants

View Source
const (
	// DefaultStorePrompt is run 1 in the two-turn demo.
	DefaultStorePrompt = "Remember for all future runs: I prefer concise answers. Persist this preference to long-term memory before you reply."

	// DefaultRecallPrompt is run 2 in the two-turn demo.
	DefaultRecallPrompt = "What answer style do I prefer?"
)

Variables

This section is empty.

Functions

func AgentOptions

func AgentOptions(
	cfg *excfg.Config,
	llmClient interfaces.LLMClient,
	log logger.Logger,
	settings *Settings,
	memCfg memory.Config,
	backendLabel string,
) []agent.Option

AgentOptions builds shared agent options: runtime, LLM, memory, and system prompt.

func MemoryConfig

func MemoryConfig(store interfaces.Memory, settings *Settings, mode memory.StoreMode) memory.Config

MemoryConfig builds memory.Config from settings, backend, and store mode.

func OpenAIEmbedFunc

func OpenAIEmbedFunc(settings *Settings) (pgmem.EmbedFunc, error)

OpenAIEmbedFunc returns a pgmem.EmbedFunc that calls an OpenAI-compatible embeddings API.

func ParseStoreMode

func ParseStoreMode(raw string) (memory.StoreMode, error)

ParseStoreMode reads MEMORY_STORE_MODE (always | ondemand). Empty defaults to ondemand.

func RunAgent

func RunAgent(ctx context.Context, a *agent.Agent, userID, label, prompt string) *agent.AgentRunResult

RunAgent executes one prompt and prints the assistant reply plus optional footers.

func RunFromArgs

func RunFromArgs(ctx context.Context, a *agent.Agent, userID string, storeMode memory.StoreMode)

RunFromArgs runs the two-turn store/recall demo when no CLI args are given; otherwise a single custom prompt.

func ScopedContext

func ScopedContext(ctx context.Context, userID string) context.Context

ScopedContext attaches the demo user id for memory scope resolution.

func StoreModeHint

func StoreModeHint(mode memory.StoreMode) string

StoreModeHint returns a one-line demo hint for the configured store mode.

func ValidateEmbeddingConfig

func ValidateEmbeddingConfig(settings *Settings) error

ValidateEmbeddingConfig ensures pgvector can call an OpenAI-compatible embeddings API.

Types

type Settings

type Settings struct {
	UserID         string
	StoreMode      memory.StoreMode
	RecallEnabled  bool
	RecallLimit    int
	RecallMinScore float32

	// Weaviate
	WeaviateHost        string
	WeaviateScheme      string
	WeaviateClass       string
	WeaviateMemoryClass string

	// PostgreSQL / pgvector
	PGDSN            string
	PGMemoryTable    string
	PGEmbeddingCol   string
	EmbeddingModel   string
	EmbeddingBaseURL string
	EmbeddingAPIKey  string
}

Settings holds env-driven values shared by the weaviate and pgvector example entry points.

func LoadSettings

func LoadSettings() (*Settings, error)

LoadSettings reads memory example env vars. LLM and Temporal vars come from examples/config.LoadFromEnv.

Jump to

Keyboard shortcuts

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