| """ |
| Configuration settings loaded from environment variables |
| """ |
| import os |
| from pydantic_settings import BaseSettings |
| from functools import lru_cache |
|
|
|
|
| |
| def find_env_file(): |
| """Find .env file in app, backend, or project root directory""" |
| app_dir = os.path.dirname(os.path.abspath(__file__)) |
| backend_dir = os.path.dirname(app_dir) |
| project_root_dir = os.path.dirname(backend_dir) |
|
|
| |
| if os.path.exists(os.path.join(app_dir, ".env")): |
| return os.path.join(app_dir, ".env") |
|
|
| |
| if os.path.exists(os.path.join(backend_dir, ".env")): |
| return os.path.join(backend_dir, ".env") |
|
|
| |
| if os.path.exists(os.path.join(project_root_dir, ".env")): |
| return os.path.join(project_root_dir, ".env") |
| |
| return ".env" |
|
|
|
|
| class Settings(BaseSettings): |
| |
| database_url: str = "postgresql://agentsociety:dev_password@localhost:5433/agentsociety_db" |
| |
| |
| redis_url: str = "redis://localhost:6379/0" |
| |
| |
| mqtt_broker_host: str = "localhost" |
| mqtt_broker_port: int = 1883 |
| mqtt_transport: str = "tcp" |
| mqtt_path: str = "" |
| |
| |
| chroma_host: str = "localhost" |
| chroma_port: int = 8000 |
| chroma_ssl: bool = False |
| |
| |
| aws_access_key_id: str = "" |
| aws_secret_access_key: str = "" |
| aws_s3_bucket: str = "agentsociety-videos-dev" |
| aws_region: str = "ap-south-1" |
| |
| |
| gemini_api_key: str = "" |
| gemini_api_keys: str = "" |
| |
| |
| qwen_api_url: str = "https://vish85521-doc.hf.space/api/generate" |
| qwen_model_name: str = "qwen3.5:397b-cloud" |
| |
| |
| jwt_secret: str = "change_this_to_a_random_32_character_string" |
| jwt_algorithm: str = "HS256" |
| jwt_expiry_hours: int = 24 |
| |
| |
| default_num_agents: int = 10 |
| default_simulation_days: int = 5 |
| |
| |
| upload_dir: str = "uploads" |
| |
| class Config: |
| env_file = find_env_file() |
| env_file_encoding = "utf-8" |
|
|
|
|
| @lru_cache() |
| def get_settings() -> Settings: |
| return Settings() |
|
|
|
|