38 lines
1.3 KiB
Python
38 lines
1.3 KiB
Python
from pathlib import Path
|
|
|
|
from pydantic import Field, SecretStr, field_validator
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
model_config = SettingsConfigDict(env_file=".env", extra="ignore")
|
|
|
|
telegram_bot_token: SecretStr
|
|
deepseek_api_key: SecretStr
|
|
deepseek_base_url: str = "https://api.deepseek.com"
|
|
deepseek_model: str = "deepseek-chat"
|
|
database_url: str
|
|
repository_url: str = ""
|
|
repository_branch: str = "main"
|
|
repository_access_token: SecretStr | None = None
|
|
owner_telegram_id: int
|
|
project_group_id: int
|
|
bot_timezone: str = "Europe/Paris"
|
|
log_level: str = "INFO"
|
|
repository_path: Path = Path("data/repository")
|
|
max_repository_file_bytes: int = 250_000
|
|
max_attachment_bytes: int = 5_000_000
|
|
context_token_limit: int = 12_000
|
|
summary_trigger_tokens: int = 9_000
|
|
proactive_confidence_threshold: float = Field(default=0.86, ge=0, le=1)
|
|
proactive_cooldown_seconds: int = 120
|
|
|
|
@field_validator("repository_path", mode="before")
|
|
@classmethod
|
|
def expand_repository_path(cls, value: str | Path) -> Path:
|
|
return Path(value).resolve()
|
|
|
|
@property
|
|
def sync_database_url(self) -> str:
|
|
return self.database_url.replace("+asyncpg", "")
|