praval.config
Typed configuration loading for Praval applications.
Configuration is read without creating runtime resources. Values are merged in
this order: defaults, praval.toml, environment variables, then explicit API
overrides.
Functions
|
Find the nearest |
|
Return the cached v0.8.2-compatible observability configuration. |
|
Load and validate Praval configuration with documented precedence. |
|
Clear compatibility configuration state for tests. |
Classes
|
Named agent defaults layered over a model profile. |
|
Application resource identity. |
|
Named provider-neutral embedding profile. |
|
Evaluation orchestration configuration. |
|
One evaluation quality gate. |
|
Evaluator-agent or direct-model safety and budget policy. |
|
Configured Praval profiles used only by optional RAGAS metrics. |
|
Named evaluation-store settings. |
|
Offline or CI evaluation suite. |
|
Optional local-only diagnostic trace retention. |
|
Named foundation-model profile. |
|
OTLP transport and batching settings. |
|
Observability signal and privacy configuration. |
|
Sampled online evaluation worker settings. |
|
PostgreSQL evaluation-store secret reference. |
|
Complete schema-versioned Praval application configuration. |
|
Resolved agent and model settings after precedence is applied. |
|
Local and CI evaluation-store location. |
- class praval.config.AgentProfileConfig(**data)[source]
Bases:
_ConfigModelNamed agent defaults layered over a model profile.
- Parameters:
model (str | None)
system_message (str | None)
tools (tuple[str, ...])
memory_enabled (bool)
memory_namespace (str | None)
max_tool_rounds (int)
- model: str | None
- system_message: str | None
- tools: tuple[str, ...]
- memory_enabled: bool
- memory_namespace: str | None
- max_tool_rounds: int
- validate_memory_namespace()[source]
Require a stable namespace whenever agent memory is enabled.
- Return type:
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class praval.config.AppConfig(**data)[source]
Bases:
_ConfigModelApplication resource identity.
- Parameters:
service_name (str)
service_version (str | None)
deployment_environment (str | None)
- service_name: str
- service_version: str | None
- deployment_environment: str | None
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class praval.config.EmbeddingProfileConfig(**data)[source]
Bases:
_ConfigModelNamed provider-neutral embedding profile.
- Parameters:
provider (str)
model (str)
dimensions (int | None)
base_url (str | None)
api_key_env (str | None)
- provider: str
- model: str
- dimensions: int | None
- base_url: str | None
- api_key_env: str | None
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class praval.config.EvalConfig(**data)[source]
Bases:
_ConfigModelEvaluation orchestration configuration.
- Parameters:
enabled (bool)
store (Literal['sqlite', 'postgres'])
offline_concurrency (int)
online (OnlineEvalConfig)
stores (EvalStoresConfig)
ragas (EvalRagasConfig | None)
judges (dict[str, EvalJudgeConfig])
suites (dict[str, EvalSuiteConfig])
- enabled: bool
- store: Literal['sqlite', 'postgres']
- offline_concurrency: int
- online: OnlineEvalConfig
- stores: EvalStoresConfig
- ragas: EvalRagasConfig | None
- judges: dict[str, EvalJudgeConfig]
- suites: dict[str, EvalSuiteConfig]
- validate_store()[source]
Require PostgreSQL configuration when that store is selected.
- Return type:
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class praval.config.EvalGateConfig(**data)[source]
Bases:
_ConfigModelOne evaluation quality gate.
- Parameters:
gate_id (str | None)
metric (str)
aggregation (Literal['mean', 'minimum', 'maximum', 'percentile', 'count', 'pass_rate'])
operator (Literal['>=', '>', '<=', '<', '=='])
threshold (float)
required (bool)
percentile (float | None)
baseline_max_regression (float | None)
- gate_id: str | None
- metric: str
- aggregation: Literal['mean', 'minimum', 'maximum', 'percentile', 'count', 'pass_rate']
- operator: Literal['>=', '>', '<=', '<', '==']
- threshold: float
- required: bool
- percentile: float | None
- baseline_max_regression: float | None
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class praval.config.EvalJudgeConfig(**data)[source]
Bases:
_ConfigModelEvaluator-agent or direct-model safety and budget policy.
- Parameters:
agent (str | None)
model (str | None)
timeout_seconds (float)
max_attempts (int)
allow_self_evaluation (bool)
allowed_tools (tuple[str, ...])
tool_policy (Literal['evaluation_safe', 'read_only'])
allow_side_effects (bool)
hitl_mode (Literal['suspend', 'fail'])
max_input_tokens (int)
max_cost_usd (float)
rubric (str)
rubric_version (str)
judge_version (str)
- agent: str | None
- model: str | None
- timeout_seconds: float
- max_attempts: int
- allow_self_evaluation: bool
- allowed_tools: tuple[str, ...]
- tool_policy: Literal['evaluation_safe', 'read_only']
- allow_side_effects: bool
- hitl_mode: Literal['suspend', 'fail']
- max_input_tokens: int
- max_cost_usd: float
- rubric: str
- rubric_version: str
- judge_version: str
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class praval.config.EvalRagasConfig(**data)[source]
Bases:
_ConfigModelConfigured Praval profiles used only by optional RAGAS metrics.
- Parameters:
model (str | None)
embedding (str | None)
timeout_seconds (float)
strict_tool_order (bool)
- model: str | None
- embedding: str | None
- timeout_seconds: float
- strict_tool_order: bool
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class praval.config.EvalStoresConfig(**data)[source]
Bases:
_ConfigModelNamed evaluation-store settings.
- Parameters:
sqlite (SQLiteEvalStoreConfig)
postgres (PostgresEvalStoreConfig | None)
- sqlite: SQLiteEvalStoreConfig
- postgres: PostgresEvalStoreConfig | None
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class praval.config.EvalSuiteConfig(**data)[source]
Bases:
_ConfigModelOffline or CI evaluation suite.
- Parameters:
dataset (str)
target (str)
judges (tuple[str, ...])
metrics (tuple[str, ...])
gates (tuple[EvalGateConfig, ...])
- dataset: str
- target: str
- judges: tuple[str, ...]
- metrics: tuple[str, ...]
- gates: tuple[EvalGateConfig, ...]
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class praval.config.LocalObservabilityConfig(**data)[source]
Bases:
_ConfigModelOptional local-only diagnostic trace retention.
- Parameters:
enabled (bool)
path (str)
max_traces (int)
max_age_days (int)
- enabled: bool
- path: str
- max_traces: int
- max_age_days: int
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class praval.config.ModelProfileConfig(**data)[source]
Bases:
_ConfigModelNamed foundation-model profile.
- Parameters:
provider (str)
model (str)
temperature (float | None)
max_output_tokens (int | None)
- provider: str
- model: str
- temperature: float | None
- max_output_tokens: int | None
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class praval.config.ObservabilityConfig(**data)[source]
Bases:
_ConfigModelObservability signal and privacy configuration.
The deprecated
sample_rate,otlp_endpoint, andstorage_pathinputs remain accepted for the v0.8.2 migration window.- Parameters:
enabled (bool)
capture_content (bool)
content_allowlist (tuple[str, ...])
sampling (Literal['always_on', 'always_off', 'parentbased_traceidratio'])
sample_ratio (float)
flush_timeout_millis (int)
otlp (OTLPConfig)
local (LocalObservabilityConfig)
- enabled: bool
- capture_content: bool
- content_allowlist: tuple[str, ...]
- sampling: Literal['always_on', 'always_off', 'parentbased_traceidratio']
- sample_ratio: float
- flush_timeout_millis: int
- otlp: OTLPConfig
- local: LocalObservabilityConfig
- classmethod map_legacy_fields(value)[source]
Map supported v0.8.2 field names to the typed nested schema.
- Return type:
Any- Parameters:
value (Any)
- property sample_rate: float
Return the deprecated sampling field.
- property otlp_endpoint: str | None
Return the deprecated flat OTLP endpoint.
- property storage_path: str
Return the deprecated expanded local path.
- classmethod from_env()[source]
Load supported legacy observability environment variables.
- Return type:
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class praval.config.OnlineEvalConfig(**data)[source]
Bases:
_ConfigModelSampled online evaluation worker settings.
- Parameters:
enabled (bool)
sample_ratio (float)
queue_capacity (int)
workers (int)
max_attempts (int)
max_enqueue_attempts (int)
lease_seconds (float)
job_timeout_seconds (float)
poll_interval_seconds (float)
retry_backoff_seconds (float)
shutdown_timeout_seconds (float)
max_subject_bytes (int)
- enabled: bool
- sample_ratio: float
- queue_capacity: int
- workers: int
- max_attempts: int
- max_enqueue_attempts: int
- lease_seconds: float
- job_timeout_seconds: float
- poll_interval_seconds: float
- retry_backoff_seconds: float
- shutdown_timeout_seconds: float
- max_subject_bytes: int
- validate_worker_timing()[source]
Keep leases longer than the maximum active processor call.
- Return type:
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class praval.config.OTLPConfig(**data)[source]
Bases:
_ConfigModelOTLP transport and batching settings.
- Parameters:
endpoint (str | None)
protocol (Literal['http/protobuf', 'grpc'])
traces (bool)
metrics (bool)
logs (bool)
headers_env (str | None)
max_queue_size (int)
max_export_batch_size (int)
schedule_delay_millis (int)
export_timeout_millis (int)
metric_export_interval_millis (int)
- endpoint: str | None
- protocol: Literal['http/protobuf', 'grpc']
- traces: bool
- metrics: bool
- logs: bool
- headers_env: str | None
- max_queue_size: int
- max_export_batch_size: int
- schedule_delay_millis: int
- export_timeout_millis: int
- metric_export_interval_millis: int
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class praval.config.PostgresEvalStoreConfig(**data)[source]
Bases:
_ConfigModelPostgreSQL evaluation-store secret reference.
- Parameters:
dsn_env (str)
- dsn_env: str
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class praval.config.PravalConfig(**data)[source]
Bases:
_ConfigModelComplete schema-versioned Praval application configuration.
- Parameters:
schema_version (Literal[1])
app (AppConfig)
models (dict[str, ModelProfileConfig])
embeddings (dict[str, EmbeddingProfileConfig])
agents (dict[str, AgentProfileConfig])
observability (ObservabilityConfig)
eval (EvalConfig)
- schema_version: Literal[1]
- models: dict[str, ModelProfileConfig]
- embeddings: dict[str, EmbeddingProfileConfig]
- agents: dict[str, AgentProfileConfig]
- observability: ObservabilityConfig
- eval: EvalConfig
- validate_references()[source]
Validate cross-section references before runtime work starts.
- Return type:
- resolve_agent_profile(name, overrides=None)[source]
Resolve an agent over its named model and explicit overrides.
- Return type:
- Parameters:
name (str)
overrides (Mapping[str, Any] | None)
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class praval.config.ResolvedAgentConfig(**data)[source]
Bases:
_ConfigModelResolved agent and model settings after precedence is applied.
- Parameters:
name (str)
provider (str)
model (str)
temperature (float | None)
max_output_tokens (int | None)
system_message (str | None)
tools (tuple[str, ...])
memory_enabled (bool)
memory_namespace (str | None)
max_tool_rounds (int)
- name: str
- provider: str
- model: str
- temperature: float | None
- max_output_tokens: int | None
- system_message: str | None
- tools: tuple[str, ...]
- memory_enabled: bool
- memory_namespace: str | None
- max_tool_rounds: int
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class praval.config.SQLiteEvalStoreConfig(**data)[source]
Bases:
_ConfigModelLocal and CI evaluation-store location.
- Parameters:
path (str)
- path: str
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- praval.config.discover_config_path(start=None)[source]
Find the nearest
praval.tomlwithout reading user-home defaults.- Return type:
Path|None- Parameters:
start (Path | None)