Spaces:
Runtime error
Runtime error
| """ | |
| System Configuration | |
| ------------------ | |
| Central configuration for the Agentic System including: | |
| 1. Local Model Settings | |
| 2. Team Settings | |
| 3. System Parameters | |
| 4. Resource Limits | |
| 5. Free API Configurations | |
| """ | |
| import os | |
| from typing import Dict, Any | |
| from pathlib import Path | |
| from dotenv import load_dotenv | |
| # Load environment variables | |
| load_dotenv() | |
| class SystemConfig: | |
| """System-wide configuration.""" | |
| # Base Paths | |
| BASE_DIR = Path(__file__).parent.absolute() | |
| CACHE_DIR = BASE_DIR / "cache" | |
| LOG_DIR = BASE_DIR / "logs" | |
| DATA_DIR = BASE_DIR / "data" | |
| MODEL_DIR = BASE_DIR / "models" | |
| # System Parameters | |
| DEBUG_MODE = os.getenv("DEBUG_MODE", "False").lower() == "true" | |
| LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO") | |
| MAX_WORKERS = int(os.getenv("MAX_WORKERS", "4")) | |
| ASYNC_TIMEOUT = int(os.getenv("ASYNC_TIMEOUT", "30")) | |
| # Local Model Configurations | |
| MODEL_CONFIG = { | |
| "quick_coder": { | |
| "name": "tugstugi/Qwen2.5-Coder-0.5B-QwQ-draft", | |
| "type": "transformers", | |
| "description": "Fast code completion and simple tasks", | |
| "temperature": 0.2, | |
| "max_tokens": 1000, | |
| "timeout": 30 | |
| }, | |
| "deep_coder": { | |
| "name": "YorkieOH10/deepseek-coder-6.7B-kexer-Q8_0-GGUF", | |
| "type": "gguf", | |
| "description": "Complex code generation and refactoring", | |
| "temperature": 0.3, | |
| "max_tokens": 2000, | |
| "timeout": 45 | |
| }, | |
| "text_gen": { | |
| "name": "Orenguteng/Llama-3-8B-Lexi-Uncensored", | |
| "type": "transformers", | |
| "description": "General text generation and reasoning", | |
| "temperature": 0.7, | |
| "max_tokens": 1500, | |
| "timeout": 40 | |
| }, | |
| "workflow": { | |
| "name": "deepseek-ai/JanusFlow-1.3B", | |
| "type": "transformers", | |
| "description": "Task planning and workflow management", | |
| "temperature": 0.5, | |
| "max_tokens": 1000, | |
| "timeout": 30 | |
| } | |
| } | |
| # Team Configurations | |
| TEAM_CONFIG = { | |
| "coders": { | |
| "min_agents": 3, | |
| "max_agents": 7, | |
| "capabilities": [ | |
| "full_stack_development", | |
| "cloud_architecture", | |
| "ai_ml", | |
| "blockchain", | |
| "mobile_development" | |
| ], | |
| "resource_limits": { | |
| "cpu_percent": 80, | |
| "memory_mb": 4096, | |
| "gpu_memory_mb": 2048 | |
| } | |
| }, | |
| "business": { | |
| "min_agents": 2, | |
| "max_agents": 5, | |
| "capabilities": [ | |
| "market_analysis", | |
| "business_strategy", | |
| "digital_transformation", | |
| "startup_innovation", | |
| "product_management" | |
| ], | |
| "resource_limits": { | |
| "cpu_percent": 60, | |
| "memory_mb": 2048, | |
| "api_calls_per_minute": 100 | |
| } | |
| }, | |
| "research": { | |
| "min_agents": 2, | |
| "max_agents": 6, | |
| "capabilities": [ | |
| "deep_research", | |
| "data_analysis", | |
| "trend_forecasting", | |
| "competitive_analysis", | |
| "technology_assessment" | |
| ], | |
| "resource_limits": { | |
| "cpu_percent": 70, | |
| "memory_mb": 3072, | |
| "api_calls_per_minute": 150 | |
| } | |
| }, | |
| "traders": { | |
| "min_agents": 2, | |
| "max_agents": 5, | |
| "capabilities": [ | |
| "crypto_trading", | |
| "sports_betting", | |
| "risk_management", | |
| "market_timing", | |
| "portfolio_optimization" | |
| ], | |
| "resource_limits": { | |
| "cpu_percent": 60, | |
| "memory_mb": 2048, | |
| "api_calls_per_minute": 200 | |
| } | |
| } | |
| } | |
| # Resource Management | |
| RESOURCE_LIMITS = { | |
| "total_cpu_percent": 90, | |
| "total_memory_mb": 8192, | |
| "total_gpu_memory_mb": 4096, | |
| "max_api_calls_per_minute": 500, | |
| "max_concurrent_tasks": 20 | |
| } | |
| # Collaboration Settings | |
| COLLABORATION_CONFIG = { | |
| "min_confidence_threshold": 0.6, | |
| "max_team_size": 10, | |
| "max_concurrent_objectives": 5, | |
| "objective_timeout_minutes": 60, | |
| "team_sync_interval_seconds": 30 | |
| } | |
| # Error Recovery | |
| ERROR_RECOVERY = { | |
| "max_retries": 3, | |
| "retry_delay_seconds": 5, | |
| "error_threshold": 0.2, | |
| "recovery_timeout": 300 | |
| } | |
| # Monitoring | |
| MONITORING = { | |
| "metrics_interval_seconds": 60, | |
| "health_check_interval": 30, | |
| "performance_log_retention_days": 7, | |
| "alert_threshold": { | |
| "cpu": 85, | |
| "memory": 90, | |
| "error_rate": 0.1 | |
| } | |
| } | |
| # Free API Configurations (No API Keys Required) | |
| API_CONFIG = { | |
| "search": { | |
| "duckduckgo": { | |
| "base_url": "https://api.duckduckgo.com", | |
| "rate_limit": 100, | |
| "requires_auth": False, | |
| "method": "GET" | |
| }, | |
| "wikipedia": { | |
| "base_url": "https://en.wikipedia.org/w/api.php", | |
| "rate_limit": 200, | |
| "requires_auth": False, | |
| "method": "GET" | |
| }, | |
| "arxiv": { | |
| "base_url": "http://export.arxiv.org/api/query", | |
| "rate_limit": 60, | |
| "requires_auth": False, | |
| "method": "GET" | |
| }, | |
| "crossref": { | |
| "base_url": "https://api.crossref.org/works", | |
| "rate_limit": 50, | |
| "requires_auth": False, | |
| "method": "GET" | |
| }, | |
| "unpaywall": { | |
| "base_url": "https://api.unpaywall.org/v2", | |
| "rate_limit": 100, | |
| "requires_auth": False, | |
| "method": "GET" | |
| } | |
| }, | |
| "crypto": { | |
| "coincap": { | |
| "base_url": "https://api.coincap.io/v2", | |
| "rate_limit": 200, | |
| "requires_auth": False, | |
| "method": "GET", | |
| "endpoints": { | |
| "assets": "/assets", | |
| "rates": "/rates", | |
| "markets": "/markets" | |
| } | |
| }, | |
| "blockchair": { | |
| "base_url": "https://api.blockchair.com", | |
| "rate_limit": 30, | |
| "requires_auth": False, | |
| "method": "GET" | |
| } | |
| }, | |
| "news": { | |
| "wikinews": { | |
| "base_url": "https://en.wikinews.org/w/api.php", | |
| "rate_limit": 200, | |
| "requires_auth": False, | |
| "method": "GET" | |
| }, | |
| "reddit": { | |
| "base_url": "https://www.reddit.com/r/news/.json", | |
| "rate_limit": 60, | |
| "requires_auth": False, | |
| "method": "GET" | |
| }, | |
| "hackernews": { | |
| "base_url": "https://hacker-news.firebaseio.com/v0", | |
| "rate_limit": 100, | |
| "requires_auth": False, | |
| "method": "GET" | |
| } | |
| }, | |
| "market_data": { | |
| "yahoo_finance": { | |
| "base_url": "https://query1.finance.yahoo.com/v8/finance", | |
| "rate_limit": 100, | |
| "requires_auth": False, | |
| "method": "GET" | |
| }, | |
| "marketstack_free": { | |
| "base_url": "https://api.marketstack.com/v1", | |
| "rate_limit": 100, | |
| "requires_auth": False, | |
| "method": "GET" | |
| } | |
| }, | |
| "sports": { | |
| "football_data": { | |
| "base_url": "https://www.football-data.org/v4", | |
| "rate_limit": 10, | |
| "requires_auth": False, | |
| "method": "GET", | |
| "free_endpoints": [ | |
| "/competitions", | |
| "/matches" | |
| ] | |
| }, | |
| "nhl": { | |
| "base_url": "https://statsapi.web.nhl.com/api/v1", | |
| "rate_limit": 50, | |
| "requires_auth": False, | |
| "method": "GET" | |
| }, | |
| "mlb": { | |
| "base_url": "https://statsapi.mlb.com/api/v1", | |
| "rate_limit": 50, | |
| "requires_auth": False, | |
| "method": "GET" | |
| } | |
| }, | |
| "web_scraping": { | |
| "web_archive": { | |
| "base_url": "https://archive.org/wayback/available", | |
| "rate_limit": 40, | |
| "requires_auth": False, | |
| "method": "GET" | |
| }, | |
| "metahtml": { | |
| "base_url": "https://html.spec.whatwg.org/multipage", | |
| "rate_limit": 30, | |
| "requires_auth": False, | |
| "method": "GET" | |
| } | |
| } | |
| } | |
| def get_team_config(cls, team_name: str) -> Dict[str, Any]: | |
| """Get configuration for a specific team.""" | |
| return cls.TEAM_CONFIG.get(team_name, {}) | |
| def get_model_config(cls, model_type: str) -> Dict[str, Any]: | |
| """Get configuration for a specific model type.""" | |
| return cls.MODEL_CONFIG.get(model_type, {}) | |
| def get_api_config(cls, api_name: str) -> Dict[str, Any]: | |
| """Get configuration for a specific API.""" | |
| for category in cls.API_CONFIG.values(): | |
| if api_name in category: | |
| return category[api_name] | |
| return {} | |