config

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultChunkInterval = 1 * time.Hour

DefaultChunkInterval is the default inactivity period before a session becomes a topic.

View Source
const DefaultRecentTopicsInContext = 3

DefaultRecentTopicsInContext is the default number of recent topics to show in context.

View Source
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

type AgentConfig struct {
	Name  string `yaml:"name"`
	Model string `yaml:"model"`
}

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
}

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 BotConfig

type BotConfig struct {
	Language          string  `yaml:"language" env:"LAPLACED_BOT_LANGUAGE"`
	AllowedUserIDs    []int64 `yaml:"allowed_user_ids" env:"LAPLACED_ALLOWED_USER_IDS"`
	SystemPromptExtra string  `yaml:"system_prompt_extra"`
	TurnWaitDuration  string  `yaml:"turn_wait_duration"`
}

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"`
	Yandex YandexConfig `yaml:"yandex"`
}

func Load

func Load(path string) (*Config, error)

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

func LoadDefault() (*Config, error)

LoadDefault loads the embedded default configuration.

func (*Config) Validate added in v0.2.1

func (c *Config) Validate() error

Validate checks configuration for required fields and valid ranges. 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 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 PriceTier

type PriceTier struct {
	UpToTokens     int     `yaml:"up_to_tokens"`
	PromptCost     float64 `yaml:"prompt_cost"`
	CompletionCost float64 `yaml:"completion_cost"`
}

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

func (c *RAGConfig) GetChunkDuration() time.Duration

GetChunkDuration returns the parsed chunk interval duration. Falls back to DefaultChunkInterval if not configured or invalid.

func (*RAGConfig) GetRecentTopicsInContext added in v0.4.6

func (c *RAGConfig) GetRecentTopicsInContext() int

GetRecentTopicsInContext returns the number of recent topics to include in context. Falls back to DefaultRecentTopicsInContext if not configured. Returns 0 to disable.

func (*RAGConfig) GetSplitThreshold added in v0.4.6

func (c *RAGConfig) GetSplitThreshold() int

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"`
	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"`
	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"`
}

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 ToolConfig

type ToolConfig struct {
	Name                 string `yaml:"name"`
	Model                string `yaml:"model"`
	Description          string `yaml:"description"`
	ParameterDescription string `yaml:"parameter_description"`
}

type YandexConfig

type YandexConfig struct {
	Enabled     bool   `yaml:"enabled" env:"LAPLACED_YANDEX_ENABLED"`
	APIKey      string `yaml:"api_key" env:"LAPLACED_YANDEX_API_KEY"`
	FolderID    string `yaml:"folder_id" env:"LAPLACED_YANDEX_FOLDER_ID"`
	Language    string `yaml:"language"`
	AudioFormat string `yaml:"audio_format"`
	SampleRate  string `yaml:"sample_rate"`
}

Jump to

Keyboard shortcuts

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