ibuilder / config.py
Soufianesejjari's picture
Update API URL in main function to use PORTFOLIO_URL for profile access
d3528b2
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()