Spaces:
Paused
Paused
Download app/core/config.py from tianyajum/python-agent: direct link, hf CLI and curl.
- Browser
- Download file 1.92 kB
-
https://huggingface.co/spaces/tianyajum/python-agent/resolve/main/app/core/config.py
- Command line
-
hf download hf://spaces/tianyajum/python-agent/app/core/config.py
-
curl -L -o config.py https://huggingface.co/spaces/tianyajum/python-agent/resolve/main/app/core/config.py
1.92 kB
| import os | |
| from functools import lru_cache | |
| class Config: | |
| """Base configuration.""" | |
| APP_ENV = os.getenv("APP_ENV", "development") | |
| # Server | |
| HOST = os.getenv("HOST", "127.0.0.1") | |
| PORT = int(os.getenv("PORT", 8181)) | |
| # Nacos | |
| NACOS_SERVER_ADDR = os.getenv("NACOS_SERVER_ADDR", "127.0.0.1:8848") | |
| NACOS_NAMESPACE = os.getenv("NACOS_NAMESPACE", "public") | |
| NACOS_USERNAME = os.getenv("NACOS_USERNAME", "") | |
| NACOS_PASSWORD = os.getenv("NACOS_PASSWORD", "") | |
| SERVICE_NAME = os.getenv("SERVICE_NAME", "python-agent") | |
| # MCP Clients | |
| MCP_BRAVE_PATH = os.getenv("MCP_BRAVE_PATH") # Optional override | |
| NACOS_GATEWAY_SERVICE_NAME = os.getenv("NACOS_GATEWAY_SERVICE_NAME", "gateway") | |
| # Database | |
| PG_HOST = os.getenv("PG_HOST", "localhost") | |
| PG_PORT = int(os.getenv("PG_PORT", 5432)) | |
| PG_USER = os.getenv("PG_USER", "postgres") | |
| PG_PASSWORD = os.getenv("PG_PASSWORD", "postgres") | |
| PG_DB = os.getenv("PG_DB", "postgres") | |
| DB_URI = f"postgresql://{PG_USER}:{PG_PASSWORD}@{PG_HOST}:{PG_PORT}/{PG_DB}" | |
| DB_ASYNC_URI = ( | |
| f"postgresql+psycopg://{PG_USER}:{PG_PASSWORD}@{PG_HOST}:{PG_PORT}/{PG_DB}" | |
| ) | |
| class DevelopmentConfig(Config): | |
| """Development configuration.""" | |
| DEBUG = True | |
| # In Dev, we might want to default to localhost if not specified, | |
| # but the user's current valid config points to an external Nacos. | |
| # We'll keep the external Nacos as default for now based on current working code. | |
| pass | |
| class ProductionConfig(Config): | |
| """Production configuration.""" | |
| DEBUG = False | |
| # Enforce stricter defaults or require env vars here if needed | |
| def get_settings(): | |
| env = os.getenv("APP_ENV", "development") | |
| if env == "production": | |
| return ProductionConfig() | |
| return DevelopmentConfig() | |
| settings = get_settings() | |