windlass.core.config¶
config
¶
Configuration and settings.
Windlass reads configuration from four places, later sources winning:
- Built-in defaults.
- A config file (
windlass.toml/.json/.yaml), when present. - Environment variables — both
WINDLASS_*and the conventional provider variables (OPENAI_API_KEY,ANTHROPIC_API_KEY, ...). - Explicit keyword arguments passed to a builder.
Nothing is required to get started: with no configuration at all the
dependency-free fake LLM, hash embeddings and memory vector store
give you a working pipeline for tests and demos.
Example
from windlass import configure, settings _ = configure(default_llm="fake", request_timeout=30.0) settings().default_llm 'fake'
RetryConfig
¶
Bases: BaseSettings
Retry policy applied to every provider call.
Attributes:
| Name | Type | Description |
|---|---|---|
attempts |
int
|
Total tries including the first. |
initial_delay |
float
|
Seconds before the first retry. |
max_delay |
float
|
Ceiling for the exponential backoff. |
multiplier |
float
|
Backoff growth factor. |
jitter |
float
|
Random fraction (0-1) added to each delay to avoid thundering herds when many workers retry at once. |
Example
RetryConfig(attempts=5).max_delay 30.0
CacheConfig
¶
Bases: BaseSettings
Response caching policy.
Attributes:
| Name | Type | Description |
|---|---|---|
enabled |
bool
|
Master switch. Off by default — caching a non-deterministic model is a decision, not a default. |
backend |
Literal['memory', 'disk']
|
|
ttl |
float | None
|
Seconds an entry stays fresh. |
max_size |
int
|
Entry ceiling for the in-memory backend. |
directory |
Path
|
Where the disk backend stores its data. |
WindlassSettings
¶
Bases: BaseSettings
Process-wide defaults and credentials.
Every field can be set with an environment variable. Provider keys accept
both the Windlass-prefixed name and the vendor's conventional name, so an
existing OPENAI_API_KEY in your shell just works.
Attributes:
| Name | Type | Description |
|---|---|---|
default_llm |
str
|
Provider used when a builder does not name one. |
default_model |
str
|
Model id used when a builder does not name one. |
default_embedding |
str
|
Embedding provider used by RAG builders. |
default_vectordb |
str
|
Vector store used by RAG builders. |
default_chunker |
str
|
Chunking strategy used by RAG builders. |
default_retriever |
str
|
Retrieval strategy used by RAG builders. |
temperature |
float
|
Default sampling temperature. |
max_tokens |
int | None
|
Default completion ceiling; |
request_timeout |
float
|
Per-request timeout in seconds. |
max_concurrency |
int
|
Ceiling on in-flight provider calls for batch work. |
batch_size |
int
|
Default batch size for embedding and indexing. |
openai_api_key |
SecretStr | None
|
Credential for OpenAI-compatible endpoints. |
openai_base_url |
str | None
|
Override for proxies and Azure-style gateways. |
anthropic_api_key |
SecretStr | None
|
Credential for Anthropic. |
google_api_key |
SecretStr | None
|
Credential for Gemini. |
groq_api_key |
SecretStr | None
|
Credential for Groq. |
huggingface_api_key |
SecretStr | None
|
Token for the HuggingFace Inference API. |
ollama_base_url |
str
|
Where the local Ollama daemon listens. |
pinecone_api_key |
SecretStr | None
|
Credential for Pinecone. |
langsmith_api_key |
SecretStr | None
|
Credential for LangSmith tracing. |
langfuse_public_key |
SecretStr | None
|
Public key for Langfuse. |
langfuse_secret_key |
SecretStr | None
|
Secret key for Langfuse. |
langfuse_host |
str
|
Langfuse endpoint. |
telemetry |
bool
|
Whether Windlass may emit anonymous usage counters. Off by default; Windlass ships no telemetry backend, the flag exists so downstream distributions can honour it. |
strict_plugins |
bool
|
Fail loudly when a third-party plugin cannot load. |
retry |
RetryConfig
|
Retry policy. |
cache |
CacheConfig
|
Cache policy. |
Example
s = WindlassSettings(default_llm="anthropic", temperature=0.0) s.default_llm, s.temperature ('anthropic', 0.0)
secret
¶
Return a credential's plaintext value, or None when unset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Attribute name, e.g. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
The secret value, or |
Raises:
| Type | Description |
|---|---|
ConfigurationError
|
If |
Source code in src\windlass\core\config.py
require_secret
¶
Return a credential or raise a clear authentication error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Attribute name holding the credential. |
required |
provider
|
str
|
Provider name for the error message. |
required |
env_var
|
str
|
The environment variable a user would normally set. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The secret value. |
Raises:
| Type | Description |
|---|---|
AuthenticationError
|
When the credential is missing. |
Source code in src\windlass\core\config.py
masked
¶
Return settings as a dict with every secret replaced by '***'.
Safe to log or print. Used by windlass config.
Source code in src\windlass\core\config.py
settings
¶
Return the process-wide settings, constructing them on first use.
Returns:
| Type | Description |
|---|---|
WindlassSettings
|
The active :class: |
Example
isinstance(settings().request_timeout, float) True
Source code in src\windlass\core\config.py
load_config_file
¶
Load a Windlass config file into a plain dict.
Supported formats are TOML (stdlib), JSON (stdlib) and YAML (requires
pyyaml). A [windlass] / windlass: top-level table is unwrapped so
the file can also live inside a shared config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to the config file. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The parsed mapping, ready to pass to :class: |
Raises:
| Type | Description |
|---|---|
ConfigurationError
|
For a missing file, an unknown extension, a parse error, or a non-mapping document. |
Example
import tempfile, pathlib p = pathlib.Path(tempfile.mkdtemp()) / "windlass.json" _ = p.write_text('{"windlass": {"default_llm": "fake"}}') load_config_file(p)
Source code in src\windlass\core\config.py
configure
¶
Update the process-wide settings.
Values are merged onto the current settings, so partial updates are fine.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**overrides
|
Any
|
Any field of :class: |
{}
|
Returns:
| Type | Description |
|---|---|
WindlassSettings
|
The new settings object. |
Raises:
| Type | Description |
|---|---|
ConfigurationError
|
If an override is unknown or fails validation. |
Example
configure(temperature=0.0, retry={"attempts": 5}).retry.attempts 5 reset_settings()
Source code in src\windlass\core\config.py
reset_settings
¶
Discard cached settings so the next :func:settings call re-reads the env.
Primarily a test helper.