config

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package config provides YAML-based configuration for tfai. Configuration is loaded with a layered precedence: defaults → YAML file → env vars. Environment variables always win, so existing workflows are unaffected.

File search order:

  1. --config CLI flag (explicit path)
  2. TFAI_CONFIG environment variable
  3. ~/.tfai/config.yaml
  4. ./tfai.yaml

If no file is found the system runs entirely from env vars (backwards compatible).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(explicitPath string, log *slog.Logger) (string, error)

Load reads a YAML config file and applies non-empty values as environment variables. Existing env vars are never overwritten (env always wins). Returns the path that was loaded, or empty string if no file was found.

Types

type AzureConfig

type AzureConfig struct {
	// APIKey is the Azure OpenAI API key. Prefer env var AZURE_OPENAI_API_KEY.
	APIKey string `yaml:"api_key"`
	// Endpoint is the Azure OpenAI resource endpoint.
	Endpoint string `yaml:"endpoint"`
	// Deployment is the Azure OpenAI deployment name.
	Deployment string `yaml:"deployment"`
	// APIVersion is the Azure OpenAI API version.
	APIVersion string `yaml:"api_version"`
}

AzureConfig holds Azure OpenAI provider settings.

type BedrockConfig

type BedrockConfig struct {
	// Region is the AWS region for Bedrock.
	Region string `yaml:"region"`
	// ModelID is the Bedrock model identifier.
	ModelID string `yaml:"model_id"`
}

BedrockConfig holds AWS Bedrock provider settings.

type Config

type Config struct {
	// Model configures the LLM chat model provider.
	Model ModelConfig `yaml:"model"`

	// Embedding configures the embedding provider for RAG.
	Embedding EmbeddingConfig `yaml:"embedding"`

	// Qdrant configures the Qdrant vector store connection.
	Qdrant QdrantConfig `yaml:"qdrant"`

	// Server configures the HTTP server.
	Server ServerConfig `yaml:"server"`

	// Logging configures structured logging.
	Logging LoggingConfig `yaml:"logging"`

	// History configures conversation history persistence.
	History HistoryConfig `yaml:"history"`

	// Tracing configures Langfuse tracing integration.
	Tracing TracingConfig `yaml:"tracing"`
}

Config is the top-level YAML configuration structure. Field names use yaml tags that mirror the env var naming (lowercase, underscored).

type EmbeddingConfig

type EmbeddingConfig struct {
	// Provider selects the embedding backend (ollama, openai, azure).
	Provider string `yaml:"provider"`
	// Model is the embedding model name.
	Model string `yaml:"model"`
	// Dimensions overrides the embedding vector size.
	Dimensions int `yaml:"dimensions"`
	// APIKey is the embedding API key. Prefer env var EMBEDDING_API_KEY.
	APIKey string `yaml:"api_key"`
	// Endpoint is the embedding API endpoint.
	Endpoint string `yaml:"endpoint"`
}

EmbeddingConfig holds embedding provider settings for RAG.

type GeminiConfig

type GeminiConfig struct {
	// APIKey is the Google API key. Prefer env var GOOGLE_API_KEY.
	APIKey string `yaml:"api_key"`
	// Model is the Gemini model name.
	Model string `yaml:"model"`
}

GeminiConfig holds Google Gemini provider settings.

type HistoryConfig

type HistoryConfig struct {
	// DBPath is the SQLite database path. Set to "disabled" to disable.
	DBPath string `yaml:"db_path"`
}

HistoryConfig holds conversation history settings.

type LoggingConfig

type LoggingConfig struct {
	// Level is the minimum log level: debug, info, warn, error.
	Level string `yaml:"level"`
	// Format is the log output format: json, text.
	Format string `yaml:"format"`
}

LoggingConfig holds structured logging settings.

type ModelConfig

type ModelConfig struct {
	// Provider selects the backend: ollama, openai, azure, bedrock, gemini.
	Provider string `yaml:"provider"`

	// MaxTokens is the maximum number of tokens in the response.
	MaxTokens int `yaml:"max_tokens"`

	// Temperature controls response randomness (0.0–1.0).
	Temperature float32 `yaml:"temperature"`

	// Ollama holds Ollama-specific settings.
	Ollama OllamaConfig `yaml:"ollama"`

	// OpenAI holds OpenAI-specific settings.
	OpenAI OpenAIConfig `yaml:"openai"`

	// Azure holds Azure OpenAI-specific settings.
	Azure AzureConfig `yaml:"azure"`

	// Bedrock holds AWS Bedrock-specific settings.
	Bedrock BedrockConfig `yaml:"bedrock"`

	// Gemini holds Google Gemini-specific settings.
	Gemini GeminiConfig `yaml:"gemini"`
}

ModelConfig holds LLM chat model settings.

type OllamaConfig

type OllamaConfig struct {
	// Host is the Ollama API endpoint.
	Host string `yaml:"host"`
	// Model is the Ollama model name.
	Model string `yaml:"model"`
}

OllamaConfig holds Ollama provider settings.

type OpenAIConfig

type OpenAIConfig struct {
	// APIKey is the OpenAI API key. Prefer env var OPENAI_API_KEY.
	APIKey string `yaml:"api_key"`
	// Model is the OpenAI model name.
	Model string `yaml:"model"`
}

OpenAIConfig holds OpenAI provider settings.

type QdrantConfig

type QdrantConfig struct {
	// Host is the Qdrant server hostname.
	Host string `yaml:"host"`
	// Port is the Qdrant gRPC port.
	Port int `yaml:"port"`
	// Collection is the Qdrant collection name.
	Collection string `yaml:"collection"`
	// APIKey is the Qdrant API key. Prefer env var QDRANT_API_KEY.
	APIKey string `yaml:"api_key"`
	// TLS enables TLS for the Qdrant connection.
	TLS bool `yaml:"tls"`
}

QdrantConfig holds Qdrant vector store settings.

type ServerConfig

type ServerConfig struct {
	// Host is the bind address.
	Host string `yaml:"host"`
	// Port is the TCP port.
	Port int `yaml:"port"`
	// APIKey is the Bearer token for API authentication. Prefer env var TFAI_API_KEY.
	APIKey string `yaml:"api_key"`
}

ServerConfig holds HTTP server settings.

type TracingConfig

type TracingConfig struct {
	// PublicKey is the Langfuse public key. Prefer env var LANGFUSE_PUBLIC_KEY.
	PublicKey string `yaml:"public_key"`
	// SecretKey is the Langfuse secret key. Prefer env var LANGFUSE_SECRET_KEY.
	SecretKey string `yaml:"secret_key"`
	// Host is the Langfuse API host.
	Host string `yaml:"host"`
}

TracingConfig holds Langfuse tracing settings.

Jump to

Keyboard shortcuts

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