Spaces:
Sleeping
Sleeping
| from pydantic_settings import BaseSettings, SettingsConfigDict | |
| from pydantic import field_validator | |
| from typing import List, Union | |
| import os | |
| from dotenv import load_dotenv | |
| load_dotenv() | |
| class Settings(BaseSettings): | |
| model_config = SettingsConfigDict( | |
| env_file=".env", | |
| case_sensitive=True, | |
| extra="ignore" | |
| ) | |
| PINECONE_API_KEY: str = "" | |
| PINECONE_INDEX: str = "mentorme-mentors" | |
| PINECONE_ENVIRONMENT: str = "us-east-1-aws" | |
| PINECONE_DIMENSION: int = 1024 | |
| HOST: str = "0.0.0.0" | |
| PORT: int = int(os.getenv("PORT", "7860")) | |
| DEBUG: bool = False | |
| EMBEDDING_MODEL_NAME: str = "AITeamVN/Vietnamese_Embedding" | |
| USE_FP16: bool = True | |
| RECOMMENDATION_TOP_K: int = 30 | |
| RECOMMENDATION_RERANK_K: int = 15 | |
| RECOMMENDATION_FINAL_COUNT: int = 6 | |
| SEMANTIC_WEIGHT: float = 1.0 | |
| RULE_BASED_WEIGHT: float = 0.0 | |
| def CORS_ORIGINS(self) -> List[str]: | |
| cors_str = os.getenv("CORS_ORIGINS", "*") | |
| if cors_str == "*": | |
| return ["*"] | |
| return [origin.strip() for origin in cors_str.split(",") if origin.strip()] | |
| def parse_bool(cls, v: Union[str, bool]) -> bool: | |
| if isinstance(v, str): | |
| return v.lower() in ("true", "1", "yes", "on") | |
| return bool(v) | |
| def parse_int(cls, v: Union[str, int]) -> int: | |
| if isinstance(v, str): | |
| return int(v) | |
| return v | |
| def parse_float(cls, v: Union[str, float]) -> float: | |
| if isinstance(v, str): | |
| return float(v) | |
| return v | |
| _settings: Settings = None | |
| def get_settings() -> Settings: | |
| global _settings | |
| if _settings is None: | |
| _settings = Settings() | |
| return _settings | |