Documentation
¶
Index ¶
- Constants
- func EnvVars() map[string]string
- func ExampleTOML() string
- func FormatDuration(d time.Duration) string
- func Keys() []string
- func ParseDuration(s string) (time.Duration, error)
- func Path() string
- type ByteSize
- type Config
- type Documents
- type Duration
- type Extraction
- type LLM
- type LLMChatOverride
- type LLMExtractionOverride
- type Locale
- type ResolvedLLM
Constants ¶
const ( DefaultBaseURL = "http://localhost:11434" DefaultModel = "qwen3" DefaultProvider = "ollama" DefaultLLMTimeout = 5 * time.Minute DefaultLLMExtractionTimeout = DefaultLLMTimeout DefaultCacheTTL = 30 * 24 * time.Hour // 30 days DefaultMaxExtractPages = 0 DefaultTextTimeout = 30 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func EnvVars ¶ added in v1.46.0
EnvVars returns a mapping from environment variable names to their dot-delimited config keys, derived from the `env` struct tags.
func ExampleTOML ¶
func ExampleTOML() string
ExampleTOML returns a commented config file suitable for writing as a starter config. Not written automatically -- offered to the user on demand.
func FormatDuration ¶ added in v1.64.0
FormatDuration formats a duration in a human-friendly way, using day notation for whole-day multiples.
func Keys ¶ added in v1.46.0
func Keys() []string
Keys returns the sorted list of valid dot-delimited config key names by reflecting on the Config struct's TOML tags.
func ParseDuration ¶ added in v1.39.0
ParseDuration parses a duration string. It extends Go's time.ParseDuration with support for a "d" (day) suffix, and treats bare integers as seconds.
Types ¶
type ByteSize ¶ added in v1.39.0
type ByteSize uint64
ByteSize represents a size in bytes, parseable from unitized strings like "50 MiB" or bare integers (interpreted as bytes).
func ParseByteSize ¶ added in v1.39.0
ParseByteSize parses a size string like "50 MiB", "1.5 GiB", or "1024". A bare integer is interpreted as bytes.
func (ByteSize) MarshalText ¶ added in v1.64.0
MarshalText implements encoding.TextMarshaler, producing human-readable IEC notation like "50 MiB".
func (*ByteSize) UnmarshalTOML ¶ added in v1.39.0
UnmarshalTOML implements toml.Unmarshaler for ByteSize, accepting both TOML integers (bytes) and strings ("50 MiB").
type Config ¶
type Config struct {
LLM LLM `toml:"llm" doc:"LLM provider, model, and connection settings."`
Documents Documents `toml:"documents" doc:"Document attachment limits and caching."`
Extraction Extraction `` /* 133-byte string literal not displayed */
Locale Locale `toml:"locale" doc:"Locale and currency settings."`
// Warnings collects non-fatal messages (e.g. deprecations) during load.
// Not serialized; the caller decides how to display them.
Warnings []string `toml:"-"`
}
Config is the top-level application configuration, loaded from a TOML file.
func Load ¶
Load reads the TOML config file from the default path if it exists, falls back to defaults for any unset fields, and applies environment variable overrides last.
func LoadFromPath ¶
LoadFromPath reads the TOML config file at the given path if it exists, falls back to defaults for any unset fields, and applies environment variable overrides last.
type Documents ¶ added in v1.27.0
type Documents struct {
// MaxFileSize is the largest file that can be imported as a document
// attachment. Accepts unitized strings ("50 MiB") or bare integers
// (bytes). Default: 50 MiB.
MaxFileSize ByteSize `toml:"max_file_size" env:"MICASA_MAX_DOCUMENT_SIZE"`
// CacheTTL is the preferred cache lifetime setting. Accepts unitized
// strings ("30d", "720h") or bare integers (seconds). Default: 30d.
CacheTTL *Duration `toml:"cache_ttl,omitempty" env:"MICASA_CACHE_TTL"`
// CacheTTLDays is deprecated; use CacheTTL instead. Kept for backward
// compatibility. Bare integer interpreted as days.
CacheTTLDays *int `toml:"cache_ttl_days,omitempty" env:"MICASA_CACHE_TTL_DAYS"`
}
Documents holds settings for document attachments.
func (Documents) CacheTTLDuration ¶ added in v1.39.0
CacheTTLDuration returns the resolved cache TTL as a time.Duration. CacheTTL takes precedence over CacheTTLDays. Returns 0 to disable.
type Duration ¶ added in v1.39.0
Duration wraps time.Duration with parsing support for day-suffixed strings ("30d") and bare integers (interpreted as seconds).
func (Duration) MarshalText ¶ added in v1.64.0
MarshalText implements encoding.TextMarshaler, using day notation for whole-day multiples (e.g. "30d") and Go duration syntax otherwise.
func (*Duration) UnmarshalTOML ¶ added in v1.39.0
UnmarshalTOML implements toml.Unmarshaler for Duration, accepting TOML integers (seconds) and strings ("30d", "720h").
type Extraction ¶ added in v1.45.0
type Extraction struct {
// Model overrides llm.model for extraction. Extraction wants a small,
// fast model optimized for structured JSON output. Defaults to the
// chat model if empty.
Model string `toml:"model" env:"MICASA_EXTRACTION_MODEL"`
// MaxExtractPages is the maximum number of pages for async extraction of scanned
// documents. 0 means no limit (all pages). Default: 0.
MaxExtractPages int `toml:"max_extract_pages" env:"MICASA_MAX_EXTRACT_PAGES"`
// Enabled controls whether LLM-powered extraction runs when a document
// is uploaded. When disabled, no structured data is extracted -- OCR and
// pdftotext are internal pipeline steps, not standalone features. Default: true.
Enabled *bool `toml:"enabled,omitempty" env:"MICASA_EXTRACTION_ENABLED"`
// TextTimeout is the maximum time to wait for pdftotext. Go duration
// string, e.g. "30s", "1m". Default: "30s".
TextTimeout string `toml:"text_timeout" env:"MICASA_TEXT_TIMEOUT"`
// LLMTimeout is the maximum time to wait for the LLM extraction
// inference step. Go duration string, e.g. "5m", "90s". Default: "5m".
LLMTimeout string `toml:"llm_timeout" env:"MICASA_EXTRACTION_LLM_TIMEOUT"`
// Thinking controls the model's reasoning effort level for extraction.
// Supported values: none, low, medium, high, auto.
// Empty string = don't send (server default). Default: empty.
Thinking string `toml:"thinking,omitempty" env:"MICASA_EXTRACTION_THINKING"`
}
Extraction holds settings for the document extraction pipeline (LLM-powered structured pre-fill).
func (Extraction) IsEnabled ¶ added in v1.45.0
func (e Extraction) IsEnabled() bool
IsEnabled returns whether LLM extraction is enabled. Defaults to true when the field is unset.
func (Extraction) LLMTimeoutDuration ¶ added in v1.63.0
func (e Extraction) LLMTimeoutDuration() time.Duration
LLMTimeoutDuration returns the parsed LLM extraction timeout, falling back to DefaultLLMExtractionTimeout if the value is empty or unparseable.
func (Extraction) ResolvedModel ¶ added in v1.45.0
func (e Extraction) ResolvedModel(chatModel string) string
ResolvedModel returns the extraction model, falling back to the given chat model if no extraction-specific model is configured.
func (Extraction) TextTimeoutDuration ¶ added in v1.45.0
func (e Extraction) TextTimeoutDuration() time.Duration
TextTimeoutDuration returns the parsed text extraction timeout, falling back to DefaultTextTimeout if the value is empty or unparseable.
func (Extraction) ThinkingLevel ¶ added in v1.58.0
func (e Extraction) ThinkingLevel() string
ThinkingLevel returns the reasoning effort string for extraction. Returns empty string when unset (server default).
type LLM ¶
type LLM struct {
// Provider selects which LLM provider to use. Supported values:
// ollama, anthropic, openai, openrouter, deepseek, gemini, groq,
// mistral, llamacpp, llamafile. Auto-detected when empty.
Provider string `toml:"provider" env:"MICASA_LLM_PROVIDER"`
// BaseURL is the base URL for the provider's API.
// Default varies by provider (e.g. http://localhost:11434 for Ollama).
// No /v1 suffix needed -- the provider handles path construction.
BaseURL string `toml:"base_url" env:"MICASA_LLM_BASE_URL"`
// Model is the model identifier passed in chat requests.
// Default: qwen3
Model string `toml:"model" env:"MICASA_LLM_MODEL"`
// APIKey is the authentication credential. Required for cloud
// providers (Anthropic, OpenAI, OpenRouter, etc.). Leave empty for local
// servers like Ollama that don't require authentication.
APIKey string `toml:"api_key" env:"MICASA_LLM_API_KEY"` //nolint:gosec // config field, not a hardcoded credential
// ExtraContext is custom text appended to all system prompts.
// Useful for domain-specific details: house style, location, etc.
// Currency is handled by [locale] section. Optional; defaults to empty.
ExtraContext string `toml:"extra_context" env:"MICASA_LLM_EXTRA_CONTEXT"`
// Timeout is the maximum time for a single LLM response (including
// streaming). Go duration string, e.g. "5m", "10m". Default: "5m".
// Quick operations (ping, model listing) use a shorter fixed deadline.
Timeout string `toml:"timeout" env:"MICASA_LLM_TIMEOUT"`
// Thinking controls the model's reasoning effort level. Supported values:
// none, low, medium, high, auto. Empty string = don't send (server default).
Thinking string `toml:"thinking,omitempty" env:"MICASA_LLM_THINKING"`
// Chat holds per-pipeline overrides for the chat (NL-to-SQL) pipeline.
// Non-empty fields take precedence over the base values above.
Chat LLMChatOverride `toml:"chat" doc:"Per-pipeline LLM overrides for chat. Inherits from [llm]."`
// Extraction holds per-pipeline overrides for the document extraction
// pipeline. Non-empty fields take precedence over the base values above.
Extraction LLMExtractionOverride `toml:"extraction" doc:"Per-pipeline LLM overrides for extraction. Inherits from [llm]."`
}
LLM holds settings for the LLM inference backend.
func (LLM) ChatConfig ¶ added in v1.62.0
func (l LLM) ChatConfig() ResolvedLLM
ChatConfig returns the fully-resolved LLM configuration for the chat pipeline. Fields from [llm.chat] override the base [llm] values.
func (LLM) ExtractionConfig ¶ added in v1.62.0
func (l LLM) ExtractionConfig() ResolvedLLM
ExtractionConfig returns the fully-resolved LLM configuration for the extraction pipeline. Fields from [llm.extraction] override the base [llm] values.
func (LLM) TimeoutDuration ¶ added in v1.32.0
TimeoutDuration returns the parsed LLM timeout, falling back to DefaultLLMTimeout if the value is empty or unparseable.
type LLMChatOverride ¶ added in v1.62.0
type LLMChatOverride struct {
Provider string `toml:"provider" env:"MICASA_LLM_CHAT_PROVIDER"`
BaseURL string `toml:"base_url" env:"MICASA_LLM_CHAT_BASE_URL"`
Model string `toml:"model" env:"MICASA_LLM_CHAT_MODEL"`
APIKey string `toml:"api_key" env:"MICASA_LLM_CHAT_API_KEY"` //nolint:gosec // config field, not a hardcoded credential
Timeout string `toml:"timeout" env:"MICASA_LLM_CHAT_TIMEOUT"`
Thinking string `toml:"thinking,omitempty" env:"MICASA_LLM_CHAT_THINKING"`
}
LLMChatOverride holds optional per-pipeline overrides for the chat pipeline. Empty fields inherit from the parent [llm] section.
type LLMExtractionOverride ¶ added in v1.62.0
type LLMExtractionOverride struct {
Provider string `toml:"provider" env:"MICASA_LLM_EXTRACTION_PROVIDER"`
BaseURL string `toml:"base_url" env:"MICASA_LLM_EXTRACTION_BASE_URL"`
Model string `toml:"model" env:"MICASA_LLM_EXTRACTION_MODEL"`
APIKey string `toml:"api_key" env:"MICASA_LLM_EXTRACTION_API_KEY"` //nolint:gosec // config field, not a hardcoded credential
Timeout string `toml:"timeout" env:"MICASA_LLM_EXTRACTION_TIMEOUT"`
Thinking string `toml:"thinking,omitempty" env:"MICASA_LLM_EXTRACTION_THINKING"`
}
LLMExtractionOverride holds optional per-pipeline overrides for the extraction pipeline. Empty fields inherit from the parent [llm] section.
type Locale ¶ added in v1.56.0
type Locale struct {
// Currency is the ISO 4217 code (e.g. "USD", "EUR", "GBP").
// Used as the default when the database has no currency set yet.
Currency string `toml:"currency" env:"MICASA_CURRENCY"`
}
Locale holds locale-related settings.
type ResolvedLLM ¶ added in v1.62.0
type ResolvedLLM struct {
Provider string
BaseURL string
Model string
APIKey string //nolint:gosec // resolved config field, not a hardcoded credential
ExtraContext string
Timeout time.Duration
Thinking string
}
ResolvedLLM is a fully-resolved LLM configuration for a single pipeline. All fields are populated -- no empty-means-inherit semantics.