Spaces:
Runtime error
Runtime error
File size: 1,865 Bytes
307cacc 23f9974 307cacc 23f9974 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 57 58 59 60 61 62 63 64 65 66 67 68 |
from functools import lru_cache
from typing import Literal, Optional
from pydantic import Field, SecretStr, validator
from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
"""
Application settings loaded from environment variables.
"""
# API Configuration
API_HOST: str = "0.0.0.0"
API_PORT: int = 8000
DEBUG: bool = False
# Vectorization Configuration
EMBEDDING_MODEL: str = "text-embedding-3-small"
VECTOR_DIMENSION: int = 1536
CHUNK_SIZE: int = 1000
CHUNK_OVERLAP: int = 200
TOP_K_MATCHES: int = 5
# MongoDB Configuration
MONGODB_URI: Optional[SecretStr] = None # TODO: Remove optionality
MONGODB_DB_NAME: str = "ctp_slack_bot"
# Slack Configuration
SLACK_BOT_TOKEN: Optional[SecretStr] = None # TODO: Remove optionality
SLACK_SIGNING_SECRET: Optional[SecretStr] = None # TODO: Remove optionality
SLACK_APP_TOKEN: Optional[SecretStr] = None
# Hugging Face Configuration
HF_API_TOKEN: Optional[SecretStr] = None
# Logging Configuration
LOG_LEVEL: Literal["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"] = "INFO"
LOG_FORMAT: Literal["text", "json"] = "json"
# APScheduler Configuration
SCHEDULER_TIMEZONE: str = "UTC"
@validator("MONGODB_URI")
def validate_mongodb_uri(cls, v):
"""Validate MongoDB URI format"""
#if not v.get_secret_value().startswith("mongodb"):
# raise ValueError("MONGODB_URI must be a valid MongoDB connection string")
return v
model_config = SettingsConfigDict(
env_file=".env",
env_file_encoding="utf-8",
case_sensitive=True,
)
@lru_cache
def get_settings() -> Settings:
"""
Get cached settings instance.
"""
return Settings()
settings = get_settings()
|