Spaces:
Runtime error
Runtime error
File size: 1,874 Bytes
64566ca 307cacc ce323cf 307cacc 64566ca 307cacc 64566ca 307cacc 23f9974 64566ca ec5cc7e 64566ca da7efbb 64566ca ec5cc7e 64566ca da7efbb 64566ca 23f9974 64566ca 307cacc 64566ca 5639669 64566ca 307cacc 23f9974 306043c da7efbb 64566ca 306043c 307cacc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
from pydantic import Field, MongoDsn, NonNegativeFloat, NonNegativeInt, PositiveInt, SecretStr
from pydantic_settings import BaseSettings, SettingsConfigDict
from typing import Literal, Optional
class Settings(BaseSettings): # TODO: Strong guarantees of validity, because garbage in = garbage out, and settings flow into all the nooks and crannies
"""
Application settings loaded from environment variables.
"""
# Application Configuration
DEBUG: bool = False
# Logging Configuration
LOG_LEVEL: Literal["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"] = Field(default_factory=lambda data: "DEBUG" if data.get("DEBUG", False) else "INFO")
LOG_FORMAT: Literal["text", "json"] = "json"
# API Configuration
API_HOST: str = "0.0.0.0"
API_PORT: int = 8000
# APScheduler Configuration
SCHEDULER_TIMEZONE: Optional[str] = "UTC"
# Slack Configuration
SLACK_USER_TOKEN: Optional[SecretStr] = None
SLACK_BOT_TOKEN: SecretStr
SLACK_SIGNING_SECRET: Optional[SecretStr] = None
SLACK_APP_TOKEN: SecretStr
# Vectorization Configuration
EMBEDDING_MODEL: str
VECTOR_DIMENSION: PositiveInt
CHUNK_SIZE: PositiveInt
CHUNK_OVERLAP: NonNegativeInt
TOP_K_MATCHES: PositiveInt
# MongoDB Configuration
MONGODB_URI: SecretStr # TODO: Contemplate switching to MongoDsn type for the main URL, and separate out the credentials to SecretStr variables.
MONGODB_NAME: str
SCORE_THRESHOLD: NonNegativeFloat
# Hugging Face Configuration
HF_API_TOKEN: Optional[SecretStr] = None
# OpenAI Configuration
OPENAI_API_KEY: SecretStr
CHAT_MODEL: str
MAX_TOKENS: PositiveInt
TEMPERATURE: NonNegativeFloat
SYSTEM_PROMPT: str
model_config = SettingsConfigDict(
env_file=".env",
env_file_encoding="utf-8",
case_sensitive=True,
)
|