Spaces:
Runtime error
Runtime error
File size: 2,931 Bytes
3da2136 64566ca 307cacc c21d29c 307cacc 3da2136 307cacc c21d29c 3da2136 23f9974 3da2136 64566ca da7efbb 64566ca 23f9974 64566ca c21d29c 307cacc 64566ca 5639669 64566ca 307cacc 6deb275 23f9974 306043c da7efbb 64566ca 306043c 6deb275 c5fe6f5 6deb275 059c10d af0a2bd 059c10d 307cacc c21d29c 307cacc c21d29c |
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 69 70 71 72 73 74 75 76 77 |
from loguru import logger
from pydantic import Field, MongoDsn, NonNegativeFloat, NonNegativeInt, PositiveInt, SecretStr
from pydantic_settings import BaseSettings, SettingsConfigDict
from types import MappingProxyType
from typing import Literal, Mapping, Optional, Self
class Settings(BaseSettings):
"""
Application settings loaded from environment variables.
"""
def __init__(self: Self, **data) -> None:
super().__init__(**data)
logger.debug("Created {}", self.__class__.__name__)
if self.__pydantic_extra__:
logger.warning("Extra unrecognized environment variables were provided: {}", ", ".join(self.__pydantic_extra__))
# Logging Configuration ― not actually used to configure Loguru, but defined to prevent warnings about “unknown” environment variables
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"
# APScheduler Configuration
SCHEDULER_TIMEZONE: Optional[str] = "UTC"
# Slack Configuration
SLACK_BOT_TOKEN: SecretStr
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 # TODO: Currently, this is unused.
# OpenAI Configuration
OPENAI_API_KEY: SecretStr
CHAT_MODEL: str
MAX_TOKENS: PositiveInt
TEMPERATURE: NonNegativeFloat
SYSTEM_PROMPT: str
# Google Drive Configuration
GOOGLE_DRIVE_ROOT_ID: str
GOOGLE_PROJECT_ID: str
GOOGLE_PRIVATE_KEY_ID: SecretStr
GOOGLE_PRIVATE_KEY: SecretStr
GOOGLE_CLIENT_ID: str
GOOGLE_CLIENT_EMAIL: str
GOOGLE_AUTH_URI: str = "https://accounts.google.com/o/oauth2/auth"
GOOGLE_TOKEN_URI: str = "https://oauth2.googleapis.com/token"
GOOGLE_AUTH_PROVIDER_CERT_URL: str = "https://www.googleapis.com/oauth2/v1/certs"
GOOGLE_CLIENT_CERT_URL: str = "https://www.googleapis.com/robot/v1/metadata/x509/ctp-slack-bot-714%40voltaic-reducer-294821.iam.gserviceaccount.com"
GOOGLE_UNIVERSE_DOMAIN: str = "googleapis.com"
# File Monitoring Configuration
FILE_MONITOR_ROOT_PATH: str = ""
model_config = SettingsConfigDict(
env_file=".env",
env_file_encoding="utf-8",
case_sensitive=True,
extra="allow",
frozen=True
)
def get_extra_environment_variables(self: Self) -> Mapping[str, str]:
return MappingProxyType(self.__pydantic_extra__)
|