common

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AgentOptions

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

AgentOptions builds shared agent options: runtime, LLM, retriever mode, and system prompt. backendLabel is shown in the agent name/description (e.g. "weaviate" or "pgvector").

func ModeHint

func ModeHint(mode agent.RetrieverMode) string

ModeHint returns a short phrase describing how the current mode uses retrievers.

func OpenAIEmbedFunc

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

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

func ParseRetrieverMode

func ParseRetrieverMode(raw string) (agent.RetrieverMode, error)

ParseRetrieverMode maps env text to agent.RetrieverMode.

func ValidateEmbeddingConfig

func ValidateEmbeddingConfig(settings *Settings) error

ValidateEmbeddingConfig ensures pgvector can call an OpenAI-compatible embeddings API. Requires EMBEDDING_OPENAI_APIKEY (separate from chat LLM_APIKEY).

Types

type Settings

type Settings struct {
	// RetrieverMode is agentic, prefetch, or hybrid (see agent.WithRetrieverMode).
	RetrieverMode agent.RetrieverMode

	// Weaviate
	WeaviateHost          string
	WeaviateScheme        string
	WeaviateClass         string
	WeaviateRetrieverName string
	WeaviateContentField  string
	WeaviateSourceField   string
	WeaviateTopK          int
	WeaviateMinScore      float64

	// PostgreSQL / pgvector
	PGDSN            string
	PGTable          string
	PGContentCol     string
	PGSourceCol      string
	PGEmbeddingCol   string
	PGRetrieverName  string
	PGTopK           int
	PGMinScore       float64
	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 retriever 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