a65249fa44
Implement pydantic-settings based configuration with environment variable support and structlog integration for JSON/console output modes.
60 lines
1.6 KiB
Python
60 lines
1.6 KiB
Python
"""Configuration management using pydantic-settings."""
|
|
|
|
from pathlib import Path
|
|
from typing import Literal
|
|
|
|
from pydantic import Field
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class VeritextSettings(BaseSettings):
|
|
"""Configuration settings for Veritext."""
|
|
|
|
model_config = SettingsConfigDict(
|
|
env_prefix="VERITEXT_",
|
|
env_file=".env",
|
|
env_file_encoding="utf-8",
|
|
extra="ignore",
|
|
)
|
|
|
|
# Logging settings
|
|
log_level: Literal["DEBUG", "INFO", "WARNING", "ERROR"] = Field(
|
|
default="INFO",
|
|
description="Logging level",
|
|
)
|
|
log_format: Literal["console", "json"] = Field(
|
|
default="console",
|
|
description="Log output format",
|
|
)
|
|
|
|
# Benchmark settings
|
|
benchmark_storage_path: Path = Field(
|
|
default=Path("benchmarks"),
|
|
description="Path to benchmark storage directory",
|
|
)
|
|
|
|
# Tokenisation defaults
|
|
tokeniser_lowercase: bool = Field(
|
|
default=True,
|
|
description="Whether to lowercase tokens by default",
|
|
)
|
|
tokeniser_remove_punctuation: bool = Field(
|
|
default=True,
|
|
description="Whether to remove punctuation by default",
|
|
)
|
|
|
|
# Semantic similarity settings (when available)
|
|
semantic_model: str = Field(
|
|
default="all-MiniLM-L6-v2",
|
|
description="Default sentence-transformers model",
|
|
)
|
|
semantic_cache_embeddings: bool = Field(
|
|
default=True,
|
|
description="Whether to cache embeddings",
|
|
)
|
|
|
|
|
|
def get_settings() -> VeritextSettings:
|
|
"""Get the current settings instance."""
|
|
return VeritextSettings()
|