config

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package config defines the amoxtli workspace configuration file (.amoxtli/config.yaml): parsing, environment variable interpolation and validation. The mapping of each field to the library API lives in internal/cli/runtime.

Index

Constants

View Source
const Template = `` /* 2356-byte string literal not displayed */

Template is the commented configuration written by "amoxtli init". It must stay loadable as-is (comments are not expanded, see ExpandEnv).

Variables

View Source
var SupportedProviders = []string{"openai", "openrouter", "mistral"}

SupportedProviders lists the llm.chat / llm.embeddings providers the CLI can wire. All share provider.CommonOptions (model, base_url, api_key).

Functions

func ExpandEnv

func ExpandEnv(s string, lookup func(string) (string, bool)) (string, error)

ExpandEnv expands $VAR and ${VAR} references in s using lookup, supporting the ${VAR:-default} fallback syntax and $$ as a literal dollar escape. A reference to an undefined variable without a default is an error (fail fast rather than silently injecting an empty secret).

Full-line comments (lines whose first non-blank character is '#') are left untouched, so configuration examples in comments are not expanded.

Types

type ClientConfig

type ClientConfig struct {
	Provider string `yaml:"provider"`
	BaseURL  string `yaml:"base_url"`
	Model    string `yaml:"model"`
	APIKey   string `yaml:"api_key"`
}

type Config

type Config struct {
	Version   int             `yaml:"version"`
	Store     StoreConfig     `yaml:"store"`
	Index     IndexConfig     `yaml:"index"`
	LLM       LLMConfig       `yaml:"llm"`
	Retrieval RetrievalConfig `yaml:"retrieval"`
	Converter ConverterConfig `yaml:"converter"`
	Indexing  IndexingConfig  `yaml:"indexing"`
}

func Default

func Default() *Config

Default returns the configuration used when a field is absent from the file; zero numeric values defer to the library defaults.

func Load

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

Load reads, expands and validates the configuration file at path. Variable references are resolved against the process environment, then against an optional .env file sitting next to the configuration file.

func Parse

func Parse(raw string, lookup func(string) (string, bool)) (*Config, error)

Parse expands and decodes a raw configuration document, then validates it. Unknown fields are rejected to catch typos early.

func (*Config) HasChat

func (c *Config) HasChat() bool

HasChat reports whether a chat completion client is configured.

func (*Config) HasEmbeddings

func (c *Config) HasEmbeddings() bool

HasEmbeddings reports whether an embeddings client is configured.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks cross-field constraints and rejects combinations that would fail later with an obscure error.

func (*Config) VectorEnabled

func (c *Config) VectorEnabled() bool

VectorEnabled resolves the vector index toggle against the presence of an embeddings client.

type ConverterConfig

type ConverterConfig struct {
	Pandoc      PandocConfig         `yaml:"pandoc"`
	LibreOffice LibreOfficeConfig    `yaml:"libreoffice"`
	GenAI       GenAIConverterConfig `yaml:"genai"`
}

type DecompositionConfig

type DecompositionConfig struct {
	Enabled       bool `yaml:"enabled"`
	MaxSubQueries int  `yaml:"max_sub_queries"`
}

type FulltextIndexConfig

type FulltextIndexConfig struct {
	Enabled bool    `yaml:"enabled"`
	Path    string  `yaml:"path"`
	Weight  float64 `yaml:"weight"`
}

type GenAIConverterConfig

type GenAIConverterConfig struct {
	// Enabled turns on the GenAI (OCR/LLM) converter. It is opt-in: a DSN and
	// at least one extension are required.
	Enabled bool `yaml:"enabled"`
	// DSN selects the extraction backend, e.g. mistral://?apiKey=${MISTRAL_API_KEY}
	// or marker://host:port.
	DSN string `yaml:"dsn"`
	// Extensions are routed to this converter (e.g. .pdf, .png, .jpg).
	Extensions []string `yaml:"extensions"`
}

type IndexConfig

type IndexConfig struct {
	Fulltext FulltextIndexConfig `yaml:"fulltext"`
	Vector   VectorIndexConfig   `yaml:"vector"`
}

type IndexingConfig

type IndexingConfig struct {
	MaxWordsPerSection int  `yaml:"max_words_per_section"`
	TaskParallelism    int  `yaml:"task_parallelism"`
	PersistentTasks    bool `yaml:"persistent_tasks"`
}

type IterativeConfig

type IterativeConfig struct {
	Enabled   bool `yaml:"enabled"`
	MaxRounds int  `yaml:"max_rounds"`
}

type LLMConfig

type LLMConfig struct {
	Chat       *ClientConfig `yaml:"chat"`
	Embeddings *ClientConfig `yaml:"embeddings"`
}

type LibreOfficeConfig

type LibreOfficeConfig struct {
	// Enabled accepts true, false or "auto"; auto enables the LibreOffice
	// converter when both the libreoffice and pandoc binaries are found. It
	// supersedes the standalone pandoc converter, adding .doc support.
	Enabled Toggle `yaml:"enabled"`
}

type PandocConfig

type PandocConfig struct {
	// Enabled accepts true, false or "auto"; auto enables the pandoc
	// converter when the binary is found in the PATH.
	Enabled Toggle `yaml:"enabled"`
}

type RetrievalConfig

type RetrievalConfig struct {
	Reranking         bool                `yaml:"reranking"`
	GroundingCheck    bool                `yaml:"grounding_check"`
	GroundingFailOpen bool                `yaml:"grounding_fail_open"`
	Iterative         IterativeConfig     `yaml:"iterative"`
	Decomposition     DecompositionConfig `yaml:"decomposition"`
}

type StoreConfig

type StoreConfig struct {
	// Driver selects the document store backend; only "sqlite" is supported
	// for now ("postgres" is planned).
	Driver string `yaml:"driver"`
	// DSN is the store location, relative to the .amoxtli directory.
	DSN string `yaml:"dsn"`
}

type Toggle

type Toggle string

Toggle is a tri-state flag accepting true, false or "auto" in YAML.

const (
	ToggleAuto  Toggle = "auto"
	ToggleTrue  Toggle = "true"
	ToggleFalse Toggle = "false"
)

func (Toggle) Resolve

func (t Toggle) Resolve(auto bool) bool

Resolve returns the boolean value of the toggle, falling back to auto when the toggle is "auto" (or unset).

func (*Toggle) UnmarshalYAML

func (t *Toggle) UnmarshalYAML(node *yaml.Node) error

type VectorIndexConfig

type VectorIndexConfig struct {
	// Enabled accepts true, false or "auto"; auto enables the vector index
	// when an embeddings client is configured.
	Enabled    Toggle  `yaml:"enabled"`
	Path       string  `yaml:"path"`
	Weight     float64 `yaml:"weight"`
	VectorSize int     `yaml:"vector_size"`
	MaxWords   int     `yaml:"max_words"`
}

Jump to

Keyboard shortcuts

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