config

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package config loads and validates the andino-kb YAML configuration.

Decoding is strict: unknown fields are errors, so a typo in a pipeline definition fails at startup instead of silently indexing nothing. ${VAR} references are expanded from the environment before parsing; unset variables expand to the empty string.

Index

Constants

View Source
const ManagedSourceName = "managed"

ManagedSourceName is the implicit source name for agent-written documents in writable knowledge bases.

Variables

This section is empty.

Functions

func BearerToken added in v0.4.0

func BearerToken(header string) (string, bool)

BearerToken extracts the token from an Authorization header. ok is false when the header is absent or does not carry the "Bearer " prefix.

Types

type APIKey

type APIKey struct {
	Key   string `yaml:"key"`
	Scope string `yaml:"scope"`
}

APIKey grants access to the REST and MCP APIs. Scope "read" allows search and reads; "readwrite" additionally allows store/delete on writable KBs, over both REST and MCP.

type Backend

type Backend struct {
	Name    string `yaml:"name"`
	BaseURL string `yaml:"base_url"`
	APIKey  string `yaml:"api_key"`
}

type ChatModel added in v0.2.0

type ChatModel struct {
	Name      string `yaml:"name"`
	Backend   string `yaml:"backend"`
	Model     string `yaml:"model"`
	MaxTokens int    `yaml:"max_tokens"`
	// ExtraBody is merged into the /v1/chat/completions request body.
	// Needed e.g. to disable reasoning on thinking-first models
	// (llama.cpp/vLLM: chat_template_kwargs: {enable_thinking: false}),
	// whose reasoning otherwise consumes max_tokens and returns empty
	// content.
	ExtraBody map[string]any `yaml:"extra_body"`
}

ChatModel is a chat-completions model used for index-time work such as contextual retrieval.

type Chunking

type Chunking struct {
	Strategy      string `yaml:"strategy"`
	MaxTokens     int    `yaml:"max_tokens"`
	OverlapTokens int    `yaml:"overlap_tokens"`
}

type Config

type Config struct {
	Server         Server          `yaml:"server"`
	Storage        Storage         `yaml:"storage"`
	Inference      Inference       `yaml:"inference"`
	Defaults       Defaults        `yaml:"defaults"`
	KnowledgeBases []KnowledgeBase `yaml:"knowledge_bases"`
}

func Load

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

Load reads, expands, parses and validates a config file.

func (*Config) ChatModelByName added in v0.3.0

func (c *Config) ChatModelByName(name string) (ChatModel, Backend, error)

ChatModelByName resolves a chat model reference to its definition and backend.

func (*Config) EmbeddingModelFor

func (c *Config) EmbeddingModelFor(kb *KnowledgeBase) (EmbeddingModel, Backend, error)

EmbeddingModelFor resolves a KB's embedding model definition.

func (*Config) Validate

func (c *Config) Validate() error

type Contextual added in v0.2.0

type Contextual struct {
	Enabled bool   `yaml:"enabled"`
	Model   string `yaml:"model"` // ref into inference.chat_models
}

Contextual enables contextual retrieval for a knowledge base: an LLM generates a short situating context per chunk at index time, which is embedded and BM25-indexed alongside the text.

type Defaults

type Defaults struct {
	Chunking       Chunking `yaml:"chunking"`
	EmbeddingModel string   `yaml:"embedding_model"`
	RerankModel    string   `yaml:"rerank_model"`
	OCR            *OCR     `yaml:"ocr"`
}

type EmbeddingModel

type EmbeddingModel struct {
	Name       string `yaml:"name"`
	Backend    string `yaml:"backend"`
	Model      string `yaml:"model"`
	Dimensions int    `yaml:"dimensions"`
	BatchSize  int    `yaml:"batch_size"`
	MaxRetries int    `yaml:"max_retries"`
}

type Inference

type Inference struct {
	Backends        []Backend        `yaml:"backends"`
	EmbeddingModels []EmbeddingModel `yaml:"embedding_models"`
	RerankModels    []RerankModel    `yaml:"rerank_models"`
	ChatModels      []ChatModel      `yaml:"chat_models"`
}

type KnowledgeBase

type KnowledgeBase struct {
	Name           string    `yaml:"name"`
	Description    string    `yaml:"description"`
	Writable       bool      `yaml:"writable"`
	Sources        []Source  `yaml:"sources"`
	Chunking       *Chunking `yaml:"chunking"`
	EmbeddingModel string    `yaml:"embedding_model"`
	RerankModel    string    `yaml:"rerank_model"`
	// RerankDefault decides whether searches rerank when no per-request
	// override is given: "on" (default) or "off". With "off" the reranker
	// stays available to requests that ask for rerank: true.
	RerankDefault string      `yaml:"rerank_default"`
	Contextual    *Contextual `yaml:"contextual"`
	OCR           *OCR        `yaml:"ocr"`
}

type OCR added in v0.3.0

type OCR struct {
	Enabled bool   `yaml:"enabled"`
	Model   string `yaml:"model"` // ref into inference.chat_models (must be vision-capable)
}

OCR enables transcription of scanned PDF pages through a vision-capable chat model at index time.

type RerankModel

type RerankModel struct {
	Name    string `yaml:"name"`
	Backend string `yaml:"backend"`
	Model   string `yaml:"model"`
}

type Server

type Server struct {
	Bind    string   `yaml:"bind"`
	DataDir string   `yaml:"data_dir"`
	APIKeys []APIKey `yaml:"api_keys"`
	// OpsRequireAuth gates /metrics and the per-KB detail of /readyz behind a
	// key. Nil means "follow api_keys": on when keys are configured, off when
	// they are not. /healthz is always open.
	OpsRequireAuth *bool  `yaml:"ops_require_auth"`
	LogLevel       string `yaml:"log_level"`
	LogFormat      string `yaml:"log_format"`
}

func (*Server) AuthorizeOps added in v0.4.0

func (s *Server) AuthorizeOps(header string) bool

AuthorizeOps reports whether an Authorization header may see ops detail.

func (*Server) LookupKey added in v0.4.0

func (s *Server) LookupKey(token string) (APIKey, bool)

LookupKey resolves a bearer token to its configured key. The comparison is constant-time and the loop never breaks early, so neither the value of a key nor its position in the list leaks through timing.

type Source

type Source struct {
	Name string `yaml:"name"`
	Type string `yaml:"type"` // localdir | git | s3

	// localdir
	Path       string   `yaml:"path"`
	Include    []string `yaml:"include"`
	Exclude    []string `yaml:"exclude"`
	Watch      bool     `yaml:"watch"`
	DebounceMS int      `yaml:"debounce_ms"`

	// git
	URL          string        `yaml:"url"`
	Branch       string        `yaml:"branch"`
	Paths        []string      `yaml:"paths"` // also used by s3
	PollInterval time.Duration `yaml:"poll_interval"`
	TokenEnv     string        `yaml:"token_env"`

	// s3
	Bucket    string `yaml:"bucket"`
	Prefix    string `yaml:"prefix"`
	Region    string `yaml:"region"`
	Endpoint  string `yaml:"endpoint"`   // custom endpoint for MinIO/compatible
	PathStyle bool   `yaml:"path_style"` // path-style addressing (MinIO)
}

Source is a single ingestion pipeline. Type-specific fields are flat; the validator enforces which apply to which type.

type Storage

type Storage struct {
	Provider string         `yaml:"provider"`
	Options  map[string]any `yaml:"options"`
}

Jump to

Keyboard shortcuts

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