Configuration API
pretok.config.PretokConfig
Bases: BaseModel
Root configuration for pretok.
Source code in src/pretok/config/schema.py
pretok.config.PipelineConfig
Bases: BaseModel
Configuration for the core pipeline.
Source code in src/pretok/config/schema.py
pretok.config.DetectionConfig
Bases: BaseModel
Configuration for language detection.
Source code in src/pretok/config/schema.py
pretok.config.TranslationConfig
Bases: BaseModel
Configuration for translation engines.
Source code in src/pretok/config/schema.py
pretok.config.LLMTranslatorConfig
Bases: BaseModel
Configuration for LLM-based translator (OpenAI-compatible APIs).
Source code in src/pretok/config/schema.py
pretok.config.CacheConfig
Bases: BaseModel
Configuration for caching.
Source code in src/pretok/config/schema.py
pretok.config.SegmentConfig
Bases: BaseModel
Configuration for segment processing.
Source code in src/pretok/config/schema.py
pretok.config.load_config(path=None, *, config_dict=None, auto_discover=True)
Load and validate pretok configuration.
Configuration is loaded with the following hierarchy (later overrides earlier): 1. Built-in defaults 2. Configuration file (if found/specified) 3. Runtime config_dict overrides
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path | None
|
Path to configuration file (optional) |
None
|
config_dict
|
dict[str, Any] | None
|
Runtime configuration overrides |
None
|
auto_discover
|
bool
|
Whether to auto-discover config file if path not specified |
True
|
Returns:
| Type | Description |
|---|---|
PretokConfig
|
Validated PretokConfig instance |
Raises:
| Type | Description |
|---|---|
ConfigurationError
|
If configuration is invalid |
Source code in src/pretok/config/loader.py
pretok.config.ConfigurationError
Bases: Exception
Raised when configuration is invalid.