config

package
v1.40.1 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultBaseURL    = "http://localhost:11434/v1"
	DefaultModel      = "qwen3"
	DefaultLLMTimeout = 5 * time.Second
	DefaultCacheTTL   = 30 * 24 * time.Hour // 30 days

)

Variables

This section is empty.

Functions

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 ParseDuration added in v1.39.0

func ParseDuration(s string) (time.Duration, error)

ParseDuration parses a duration string. It extends Go's time.ParseDuration with support for a "d" (day) suffix, and treats bare integers as seconds.

func Path

func Path() string

Path returns the expected config file path (XDG_CONFIG_HOME/micasa/config.toml).

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

func ParseByteSize(s string) (ByteSize, error)

ParseByteSize parses a size string like "50 MiB", "1.5 GiB", or "1024". A bare integer is interpreted as bytes.

func (ByteSize) Bytes added in v1.39.0

func (b ByteSize) Bytes() uint64

Bytes returns the size as uint64.

func (*ByteSize) UnmarshalTOML added in v1.39.0

func (b *ByteSize) UnmarshalTOML(v any) error

UnmarshalTOML implements toml.Unmarshaler for ByteSize, accepting both TOML integers (bytes) and strings ("50 MiB").

type Config

type Config struct {
	LLM       LLM       `toml:"llm"`
	Documents Documents `toml:"documents"`

	// 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

func Load() (Config, error)

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

func LoadFromPath(path string) (Config, error)

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

	// CacheTTL is the preferred cache lifetime setting. Accepts unitized
	// strings ("30d", "720h") or bare integers (seconds). Default: 30d.
	CacheTTL *Duration `toml:"cache_ttl,omitempty"`

	// CacheTTLDays is deprecated; use CacheTTL instead. Kept for backward
	// compatibility. Bare integer interpreted as days.
	CacheTTLDays *int `toml:"cache_ttl_days,omitempty"`
}

Documents holds settings for document attachments.

func (Documents) CacheTTLDuration added in v1.39.0

func (d Documents) CacheTTLDuration() time.Duration

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

type Duration struct{ time.Duration }

Duration wraps time.Duration with parsing support for day-suffixed strings ("30d") and bare integers (interpreted as seconds).

func (*Duration) UnmarshalTOML added in v1.39.0

func (d *Duration) UnmarshalTOML(v any) error

UnmarshalTOML implements toml.Unmarshaler for Duration, accepting TOML integers (seconds) and strings ("30d", "720h").

type LLM

type LLM struct {
	// BaseURL is the root of an OpenAI-compatible API.
	// The client appends /chat/completions, /models, etc.
	// Default: http://localhost:11434/v1 (Ollama)
	BaseURL string `toml:"base_url"`

	// Model is the model identifier passed in chat requests.
	// Default: qwen3
	Model string `toml:"model"`

	// ExtraContext is custom text appended to all system prompts.
	// Useful for domain-specific details: house style, currency, location, etc.
	// Optional; defaults to empty.
	ExtraContext string `toml:"extra_context"`

	// Timeout is the maximum time to wait for quick LLM server operations
	// (ping, model listing, auto-detect). Go duration string, e.g. "5s",
	// "10s", "500ms". Default: "5s".
	Timeout string `toml:"timeout"`
}

LLM holds settings for the local LLM inference backend.

func (LLM) TimeoutDuration added in v1.32.0

func (l LLM) TimeoutDuration() time.Duration

TimeoutDuration returns the parsed LLM timeout, falling back to DefaultLLMTimeout if the value is empty or unparseable.

Jump to

Keyboard shortcuts

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