Spaces:
Sleeping
Sleeping
File size: 1,811 Bytes
71fdb6d 9995fd4 71fdb6d 8ac4c8f 71fdb6d 8ac4c8f 71fdb6d 9995fd4 8ac4c8f 9995fd4 8ac4c8f 9995fd4 8ac4c8f 9995fd4 8ac4c8f 9995fd4 d3528b2 9995fd4 8ac4c8f 71fdb6d 8ac4c8f 71fdb6d 8ac4c8f 71fdb6d |
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 |
from pydantic_settings import BaseSettings
from typing import Optional, Dict, Any, List
import os
from functools import lru_cache
from dotenv import load_dotenv
load_dotenv()
class Settings(BaseSettings):
"""
Application settings loaded from environment variables or .env file
"""
# API keys
GROQ_API_KEY: str = os.getenv("GROQ_API_KEY", "")
# LLM settings
MODEL_NAME: str = "qwen-2.5-32b"
MAX_TOKENS: int = 2048
TEMPERATURE: float = 0.5
FALLBACK_TEMPERATURE: float = 0.7
GRAMMAR_CORRECTION_TEMPERATURE: float = 0.3
# SQLite settings
SQLITE_DB_PATH: str = os.getenv("SQLITE_DB_PATH", "profiles.db")
# Service settings
API_HOST: str = os.getenv("API_HOST", "0.0.0.0") # Changed from localhost to 0.0.0.0
API_PORT: int = int(os.getenv("API_PORT", "8000"))
# External-facing URL for API (this should be set in production)
EXTERNAL_API_URL: str = os.getenv("EXTERNAL_API_URL", "")
# API URL - will use external URL if provided, otherwise build from host/port
API_URL: str = os.getenv("API_URL", EXTERNAL_API_URL or f"http://{API_HOST}:{API_PORT}")
PORTFOLIO_URL:str ="https://iportfo.netlify.app"
# Allowed origins for CORS
ALLOWED_ORIGINS: List[str] = ["*"]
# Streamlit settings
STREAMLIT_PORT: int = int(os.getenv("STREAMLIT_SERVER_PORT", "8501"))
# Application settings
CACHE_SIZE: int = 100
CHUNK_SIZE: int = 1000
DEBUG: bool = os.getenv("DEBUG", "").lower() == "true"
# File settings
TEMP_FILE_DIR: str = os.getenv("TEMP_FILE_DIR", "./")
class Config:
env_file = ".env"
case_sensitive = True
@lru_cache()
def get_settings() -> Settings:
"""
Get cached settings instance
"""
return Settings() |