Documentation
¶
Overview ¶
Package config provides configuration loading and defaults for the laplaced bot.
Index ¶
- Constants
- func DefaultConfigBytes() []byte
- type AgentConfig
- type AgentsConfig
- type ArchivistAgentConfig
- type ArtifactsConfig
- type BotConfig
- type Config
- type EmbeddingConfig
- type ExtractorAgentConfig
- type MemoryConfig
- type OpenRouterConfig
- type PriceTier
- type RAGConfig
- func (c *RAGConfig) GetChunkDuration() time.Duration
- func (c *RAGConfig) GetConsolidationThreshold() float64
- func (c *RAGConfig) GetMaxChunkSize() int
- func (c *RAGConfig) GetMaxMergedSizeChars() int
- func (c *RAGConfig) GetMinSafetyThreshold() float64
- func (c *RAGConfig) GetRecentTopicsInContext() int
- func (c *RAGConfig) GetRetrievedTopicsCount() int
- func (c *RAGConfig) GetSplitThreshold() int
- type RerankerAgentConfig
- type RerankerTypeConfig
- type SearchConfig
- type ToolConfig
Constants ¶
const ( // Retrieval thresholds DefaultMinSafetyThreshold = 0.1 // Relaxed for recall - minimum cosine similarity for vector search DefaultConsolidationThreshold = 0.75 // Strict for dedup - minimum similarity for topic merge // Session formatting limits (for reranker context) DefaultMaxSessionMessages = 10 // Recent messages to show reranker DefaultMaxCharsPerMessage = 500 // Truncate long messages for reranker // Topic retrieval limits DefaultRetrievedTopicsCount = 10 // Max topics to retrieve without reranker // Consolidation DefaultMaxMergedSizeChars = 50000 // 50K chars max for merged topics DefaultMergeGapThreshold = 100 // Max message gap for merge candidate // Background loop intervals DefaultFactExtractionInterval = 1 * time.Minute // Check for topics needing fact extraction DefaultConsolidationInterval = 10 * time.Minute // Check for topics needing consolidation DefaultChunkProcessingTimeout = 10 * time.Minute // Timeout for processing a single chunk DefaultBackfillInterval = 1 * time.Minute // Background processing check interval // Chunking DefaultMaxChunkSize = 400 // Max messages per chunk before forced split // Memory DefaultFactDefaultImportance = 50 // Default importance for facts without explicit importance // Search DefaultPeopleSimilarityThreshold = 0.3 // Minimum similarity for people vector search DefaultPeopleMaxResults = 5 // Max results for people vector search )
const DefaultChunkInterval = 1 * time.Hour
DefaultChunkInterval is the default inactivity period before a session becomes a topic.
const DefaultRecentTopicsInContext = 3
DefaultRecentTopicsInContext is the default number of recent topics to show in context.
const DefaultSplitThreshold = 25000
DefaultSplitThreshold is the default character threshold for splitting large topics.
Variables ¶
This section is empty.
Functions ¶
func DefaultConfigBytes ¶
func DefaultConfigBytes() []byte
DefaultConfigBytes returns the raw embedded default configuration. Useful for generating example config files.
Types ¶
type AgentConfig ¶ added in v0.4.7
AgentConfig defines configuration for a single agent.
func (*AgentConfig) GetModel ¶ added in v0.4.7
func (a *AgentConfig) GetModel(defaultModel string) string
GetModel returns the agent's model, falling back to default if not set.
type AgentsConfig ¶ added in v0.4.7
type AgentsConfig struct {
Default AgentConfig `yaml:"default"` // Default model for all agents
Chat AgentConfig `yaml:"chat"` // Main bot - talks to users
ChatModel string `yaml:"-" env:"LAPLACED_AGENTS_CHAT_MODEL"` // Override for chat agent model
Archivist ArchivistAgentConfig `yaml:"archivist"` // Extracts facts and people from conversations
Enricher AgentConfig `yaml:"enricher"` // Expands search queries
Reranker RerankerAgentConfig `yaml:"reranker"` // Filters and ranks RAG candidates
Splitter AgentConfig `yaml:"splitter"` // Splits large topics
Merger AgentConfig `yaml:"merger"` // Merges similar topics
Extractor ExtractorAgentConfig `yaml:"extractor"` // Extracts content from artifacts
}
AgentsConfig defines all agents in the system.
func (*AgentsConfig) GetChatModel ¶ added in v0.5.3
func (a *AgentsConfig) GetChatModel() string
GetChatModel returns the chat agent's model, applying env override if set.
type ArchivistAgentConfig ¶ added in v0.5.1
type ArchivistAgentConfig struct {
AgentConfig `yaml:",inline"`
ThinkingLevel string `yaml:"thinking_level" env:"LAPLACED_ARCHIVIST_THINKING_LEVEL"`
Timeout string `yaml:"timeout" env:"LAPLACED_ARCHIVIST_TIMEOUT"`
MaxToolCalls int `yaml:"max_tool_calls" env:"LAPLACED_ARCHIVIST_MAX_TOOL_CALLS"`
}
ArchivistAgentConfig extends AgentConfig with archivist-specific settings.
func (*ArchivistAgentConfig) GetModel ¶ added in v0.5.1
func (a *ArchivistAgentConfig) GetModel(defaultModel string) string
GetModel returns the archivist's model, falling back to default if not set.
type ArtifactsConfig ¶ added in v0.6.0
type ArtifactsConfig struct {
Enabled bool `yaml:"enabled" env:"LAPLACED_ARTIFACTS_ENABLED"`
StoragePath string `yaml:"storage_path" env:"LAPLACED_ARTIFACTS_STORAGE_PATH"`
AllowedTypes []string `yaml:"allowed_types"`
// Voice settings (about storage filtering, not extraction)
MinVoiceDurationSeconds int `yaml:"min_voice_duration_seconds" env:"LAPLACED_ARTIFACTS_MIN_VOICE_DURATION_SECONDS"` // 0 = save all, -1 = disable voice artifacts
}
ArtifactsConfig defines configuration for the artifacts system (v0.6.0). Processing settings moved to agents.extractor. RAG settings moved to rag and agents.reranker.artifacts.
type Config ¶
type Config struct {
Log struct {
Level string `yaml:"level" env:"LAPLACED_LOG_LEVEL"`
} `yaml:"log"`
Server struct {
ListenPort string `yaml:"listen_port" env:"LAPLACED_SERVER_PORT"`
DebugMode bool `yaml:"debug_mode" env:"LAPLACED_SERVER_DEBUG"`
Auth struct {
Enabled bool `yaml:"enabled" env:"LAPLACED_AUTH_ENABLED"`
Username string `yaml:"username" env:"LAPLACED_AUTH_USERNAME"`
Password string `yaml:"password" env:"LAPLACED_AUTH_PASSWORD"`
} `yaml:"auth"`
} `yaml:"server"`
Telegram struct {
Token string `yaml:"token" env:"LAPLACED_TELEGRAM_TOKEN"`
WebhookURL string `yaml:"webhook_url" env:"LAPLACED_TELEGRAM_WEBHOOK_URL"`
WebhookPath string // Auto-generated from token hash (not configurable)
WebhookSecret string // Auto-generated from token hash (not configurable)
ProxyURL string `yaml:"proxy_url" env:"LAPLACED_TELEGRAM_PROXY_URL"`
} `yaml:"telegram"`
OpenRouter OpenRouterConfig `yaml:"openrouter"`
Agents AgentsConfig `yaml:"agents"`
Embedding EmbeddingConfig `yaml:"embedding"`
RAG RAGConfig `yaml:"rag"`
Tools []ToolConfig `yaml:"tools"`
Bot BotConfig `yaml:"bot"`
Database struct {
Path string `yaml:"path" env:"LAPLACED_DATABASE_PATH"`
} `yaml:"database"`
Artifacts ArtifactsConfig `yaml:"artifacts"`
Memory MemoryConfig `yaml:"memory"`
Search SearchConfig `yaml:"search"`
}
func Load ¶
Load loads configuration from the specified file path. It first loads the embedded default configuration, then merges the user config on top. Finally, it overrides values with environment variables.
func LoadDefault ¶
LoadDefault loads the embedded default configuration.
func (*Config) Validate ¶ added in v0.2.1
Validate checks configuration for required fields and valid ranges.
Complexity: HIGH (CC=55) - validates many config fields with conditional checks Dependencies: none (pure validation) Side effects: none Error handling: Accumulates all validation errors before returning
Returns an error describing all validation failures.
type EmbeddingConfig ¶ added in v0.4.7
type EmbeddingConfig struct {
Model string `yaml:"model" env:"LAPLACED_EMBEDDING_MODEL"`
}
EmbeddingConfig defines embedding model settings.
type ExtractorAgentConfig ¶ added in v0.6.0
type ExtractorAgentConfig struct {
AgentConfig `yaml:",inline"` // Name, Model
// Processing settings (moved from ArtifactsConfig in v0.6.0)
MaxFileSizeMB int `yaml:"max_file_size_mb" env:"LAPLACED_EXTRACTOR_MAX_FILE_SIZE_MB"`
Timeout string `yaml:"timeout" env:"LAPLACED_EXTRACTOR_TIMEOUT"`
MaxRetries int `yaml:"max_retries" env:"LAPLACED_EXTRACTOR_MAX_RETRIES"`
PollingInterval string `yaml:"polling_interval" env:"LAPLACED_EXTRACTOR_POLLING_INTERVAL"`
MaxConcurrent int `yaml:"max_concurrent" env:"LAPLACED_EXTRACTOR_MAX_CONCURRENT"`
RecoveryThreshold string `yaml:"recovery_threshold" env:"LAPLACED_EXTRACTOR_RECOVERY_THRESHOLD"`
RecentMessageCount int `yaml:"recent_message_count" env:"LAPLACED_EXTRACTOR_RECENT_MESSAGE_COUNT"` // Number of recent session messages to include in artifact context (0 = disable)
}
ExtractorAgentConfig defines configuration for the Extractor agent (v0.6.0). Processing settings were moved from ArtifactsConfig to keep agent-related config together.
func (*ExtractorAgentConfig) GetModel ¶ added in v0.6.0
func (e *ExtractorAgentConfig) GetModel(defaultModel string) string
GetModel returns the extractor's model, falling back to default if not set.
func (*ExtractorAgentConfig) GetPollingInterval ¶ added in v0.6.0
func (e *ExtractorAgentConfig) GetPollingInterval() time.Duration
GetPollingInterval returns the interval for polling pending artifacts. Defaults to 30 seconds if not configured.
func (*ExtractorAgentConfig) GetRecoveryThreshold ¶ added in v0.6.0
func (e *ExtractorAgentConfig) GetRecoveryThreshold() time.Duration
GetRecoveryThreshold returns the threshold for recovering zombie artifact states. Defaults to 10 minutes if not configured.
func (*ExtractorAgentConfig) GetTimeout ¶ added in v0.6.0
func (e *ExtractorAgentConfig) GetTimeout() time.Duration
GetTimeout returns the timeout for artifact processing. Defaults to 2 minutes if not configured.
type MemoryConfig ¶ added in v0.6.1
type MemoryConfig struct {
FactDefaultImportance int `yaml:"fact_default_importance" env:"LAPLACED_MEMORY_FACT_DEFAULT_IMPORTANCE"`
}
MemoryConfig defines configuration for memory operations.
func (*MemoryConfig) GetFactDefaultImportance ¶ added in v0.6.1
func (c *MemoryConfig) GetFactDefaultImportance() int
GetFactDefaultImportance returns the default importance for facts without explicit importance. Falls back to DefaultFactDefaultImportance (50) if not configured.
type OpenRouterConfig ¶
type OpenRouterConfig struct {
APIKey string `yaml:"api_key" env:"LAPLACED_OPENROUTER_API_KEY"`
ProxyURL string `yaml:"proxy_url" env:"LAPLACED_OPENROUTER_PROXY_URL"`
PDFParserEngine string `yaml:"pdf_parser_engine"`
RequestCost float64 `yaml:"request_cost"`
PriceTiers []PriceTier `yaml:"price_tiers"`
}
type RAGConfig ¶
type RAGConfig struct {
Enabled bool `yaml:"enabled" env:"LAPLACED_RAG_ENABLED"`
MaxContextMessages int `yaml:"max_context_messages"`
MaxProfileFacts int `yaml:"max_profile_facts"`
RetrievedMessagesCount int `yaml:"retrieved_messages_count"`
RetrievedTopicsCount int `yaml:"retrieved_topics_count"`
SimilarityThreshold float64 `yaml:"similarity_threshold"`
ConsolidationSimilarityThreshold float64 `yaml:"consolidation_similarity_threshold"`
MinSafetyThreshold float64 `yaml:"min_safety_threshold"`
MaxChunkSize int `yaml:"max_chunk_size"`
BackfillBatchSize int `yaml:"backfill_batch_size"`
BackfillInterval string `yaml:"backfill_interval"`
ChunkInterval string `yaml:"chunk_interval"`
MaxMergedSizeChars int `yaml:"max_merged_size_chars"`
SplitThresholdChars int `yaml:"split_threshold_chars"`
RecentTopicsInContext int `yaml:"recent_topics_in_context"`
}
func (*RAGConfig) GetChunkDuration ¶ added in v0.4.6
GetChunkDuration returns the parsed chunk interval duration. Falls back to DefaultChunkInterval if not configured or invalid.
func (*RAGConfig) GetConsolidationThreshold ¶ added in v0.6.1
GetConsolidationThreshold returns the minimum similarity for topic consolidation. Falls back to DefaultConsolidationThreshold (0.75) if not configured. This strict threshold ensures we only merge very similar topics.
func (*RAGConfig) GetMaxChunkSize ¶ added in v0.6.1
GetMaxChunkSize returns the max messages per chunk before forced split. Falls back to DefaultMaxChunkSize (400) if not configured.
func (*RAGConfig) GetMaxMergedSizeChars ¶ added in v0.6.1
GetMaxMergedSizeChars returns the max character count for merged topics. Falls back to DefaultMaxMergedSizeChars (50000) if not configured.
func (*RAGConfig) GetMinSafetyThreshold ¶ added in v0.6.1
GetMinSafetyThreshold returns the minimum cosine similarity for vector search. Falls back to DefaultMinSafetyThreshold (0.1) if not configured. This relaxed threshold prioritizes recall over precision.
func (*RAGConfig) GetRecentTopicsInContext ¶ added in v0.4.6
GetRecentTopicsInContext returns the number of recent topics to include in context. Falls back to DefaultRecentTopicsInContext if not configured. Returns 0 to disable.
func (*RAGConfig) GetRetrievedTopicsCount ¶ added in v0.6.1
GetRetrievedTopicsCount returns the max topics to retrieve without reranker. Falls back to DefaultRetrievedTopicsCount (10) if not configured.
func (*RAGConfig) GetSplitThreshold ¶ added in v0.4.6
GetSplitThreshold returns the threshold for splitting large topics. Falls back to DefaultSplitThreshold if not configured.
type RerankerAgentConfig ¶ added in v0.4.7
type RerankerAgentConfig struct {
AgentConfig `yaml:",inline"`
Enabled bool `yaml:"enabled" env:"LAPLACED_RERANKER_ENABLED"`
Timeout string `yaml:"timeout" env:"LAPLACED_RERANKER_TIMEOUT"`
TurnTimeout string `yaml:"turn_timeout" env:"LAPLACED_RERANKER_TURN_TIMEOUT"`
MaxToolCalls int `yaml:"max_tool_calls" env:"LAPLACED_RERANKER_MAX_TOOL_CALLS"`
ThinkingLevel string `yaml:"thinking_level" env:"LAPLACED_RERANKER_THINKING_LEVEL"`
TargetContextChars int `yaml:"target_context_chars" env:"LAPLACED_RERANKER_TARGET_CONTEXT_CHARS"`
// Per-type limits (v0.6.0)
Topics RerankerTypeConfig `yaml:"topics"`
People RerankerTypeConfig `yaml:"people"`
Artifacts RerankerTypeConfig `yaml:"artifacts"`
// Legacy fields (deprecated, kept for migration)
Candidates int `yaml:"candidates" env:"LAPLACED_RERANKER_CANDIDATES"`
MaxTopics int `yaml:"max_topics" env:"LAPLACED_RERANKER_MAX_TOPICS"`
MaxPeople int `yaml:"max_people" env:"LAPLACED_RERANKER_MAX_PEOPLE"`
}
RerankerAgentConfig extends AgentConfig with reranker-specific settings.
func (*RerankerAgentConfig) GetModel ¶ added in v0.4.7
func (r *RerankerAgentConfig) GetModel(defaultModel string) string
GetModel returns the reranker's model, falling back to default if not set.
type RerankerTypeConfig ¶ added in v0.6.0
type RerankerTypeConfig struct {
CandidatesLimit int `yaml:"candidates_limit" env:"LAPLACED_RERANKER_TOPICS_CANDIDATES_LIMIT"`
Max int `yaml:"max" env:"LAPLACED_RERANKER_TOPICS_MAX"`
MaxContextBytes int `yaml:"max_context_bytes,omitempty" env:"LAPLACED_RERANKER_TOPICS_MAX_CONTEXT_BYTES"` // For artifacts only (v0.6.0)
}
RerankerTypeConfig defines per-type reranker limits (v0.6.0). RerankerTypeConfig defines per-type reranker limits (v0.6.0).
type SearchConfig ¶ added in v0.6.1
type SearchConfig struct {
PeopleSimilarityThreshold float64 `yaml:"people_similarity_threshold" env:"LAPLACED_SEARCH_PEOPLE_SIMILARITY_THRESHOLD"`
PeopleMaxResults int `yaml:"people_max_results" env:"LAPLACED_SEARCH_PEOPLE_MAX_RESULTS"`
}
SearchConfig defines configuration for search operations.
func (*SearchConfig) GetPeopleMaxResults ¶ added in v0.6.1
func (c *SearchConfig) GetPeopleMaxResults() int
GetPeopleMaxResults returns the max results for people vector search. Falls back to DefaultPeopleMaxResults (5) if not configured.
func (*SearchConfig) GetPeopleSimilarityThreshold ¶ added in v0.6.1
func (c *SearchConfig) GetPeopleSimilarityThreshold() float64
GetPeopleSimilarityThreshold returns the minimum similarity for people vector search. Falls back to DefaultPeopleSimilarityThreshold (0.3) if not configured.