config

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

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 BotConfig

type BotConfig struct {
	Language          string  `yaml:"language" env:"LAPLACED_BOT_LANGUAGE"`
	BotName           string  `yaml:"bot_name" env:"LAPLACED_BOT_NAME"`
	AllowedUserIDs    []int64 `yaml:"allowed_user_ids" env:"LAPLACED_ALLOWED_USER_IDS"`
	SystemPrompt      string  `yaml:"system_prompt"`       // Deprecated: moved to i18n
	SystemPromptExtra string  `yaml:"system_prompt_extra"` // New
	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"`
		ProxyURL   string `yaml:"proxy_url" env:"LAPLACED_TELEGRAM_PROXY_URL"`
	} `yaml:"telegram"`
	OpenRouter OpenRouterConfig `yaml:"openrouter"`
	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.

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"`
	Model           string      `yaml:"model" env:"LAPLACED_OPENROUTER_MODEL"`
	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"`
	EmbeddingModel                   string  `yaml:"embedding_model"`
	SummaryModel                     string  `yaml:"summary_model"`
	QueryModel                       string  `yaml:"query_model"`
	MaxContextMessages               int     `yaml:"max_context_messages"`
	RetrievedMessagesCount           int     `yaml:"retrieved_messages_count"`
	RetrievedTopicsCount             int     `yaml:"retrieved_topics_count"`
	SimilarityThreshold              float64 `yaml:"similarity_threshold"`
	ConsolidationSimilarityThreshold float64 `yaml:"consolidation_similarity_threshold"` // New
	MinSafetyThreshold               float64 `yaml:"min_safety_threshold"`               // New
	MaxChunkSize                     int     `yaml:"max_chunk_size"`                     // New
	BackfillBatchSize                int     `yaml:"backfill_batch_size"`
	BackfillInterval                 string  `yaml:"backfill_interval"`
	TopicModel                       string  `yaml:"topic_model"`
	ChunkInterval                    string  `yaml:"chunk_interval"`
	TopicExtractionPrompt            string  `yaml:"topic_extraction_prompt"` // Deprecated: moved to i18n
	EnrichmentPrompt                 string  `yaml:"enrichment_prompt"`       // Deprecated: moved to i18n
}

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