Spaces:
Sleeping
Sleeping
| """ | |
| Configuration module for Universal MCP Client | |
| """ | |
| import os | |
| from dataclasses import dataclass | |
| from typing import Optional | |
| import logging | |
| # Set up enhanced logging | |
| logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') | |
| logger = logging.getLogger(__name__) | |
| class MCPServerConfig: | |
| """Configuration for an MCP server connection""" | |
| name: str | |
| url: str | |
| description: str | |
| space_id: Optional[str] = None | |
| class AppConfig: | |
| """Application configuration settings""" | |
| # API Configuration | |
| ANTHROPIC_API_KEY = os.getenv("ANTHROPIC_API_KEY") | |
| # Model Configuration | |
| CLAUDE_MODEL = "claude-sonnet-4-20250514" | |
| MAX_TOKENS = 2048 | |
| # MCP Configuration | |
| MCP_BETA_VERSION = "mcp-client-2025-04-04" | |
| MCP_TIMEOUT_SECONDS = 20.0 | |
| # UI Configuration | |
| GRADIO_THEME = "citrus" | |
| DEBUG_MODE = True | |
| # File Support | |
| SUPPORTED_IMAGE_EXTENSIONS = ['.png', '.jpg', '.jpeg', '.gif', '.webp'] | |
| SUPPORTED_AUDIO_EXTENSIONS = ['.mp3', '.wav', '.ogg', '.m4a', '.flac'] | |
| SUPPORTED_VIDEO_EXTENSIONS = ['.mp4', '.avi', '.mov'] | |
| SUPPORTED_DOCUMENT_EXTENSIONS = ['.pdf', '.txt', '.docx'] | |
| def get_all_media_extensions(cls): | |
| """Get all supported media file extensions""" | |
| return (cls.SUPPORTED_IMAGE_EXTENSIONS + | |
| cls.SUPPORTED_AUDIO_EXTENSIONS + | |
| cls.SUPPORTED_VIDEO_EXTENSIONS) | |
| def is_image_file(cls, file_path: str) -> bool: | |
| """Check if file is an image""" | |
| return any(ext in file_path.lower() for ext in cls.SUPPORTED_IMAGE_EXTENSIONS) | |
| def is_audio_file(cls, file_path: str) -> bool: | |
| """Check if file is an audio file""" | |
| return any(ext in file_path.lower() for ext in cls.SUPPORTED_AUDIO_EXTENSIONS) | |
| def is_video_file(cls, file_path: str) -> bool: | |
| """Check if file is a video file""" | |
| return any(ext in file_path.lower() for ext in cls.SUPPORTED_VIDEO_EXTENSIONS) | |
| def is_media_file(cls, file_path: str) -> bool: | |
| """Check if file is any supported media type""" | |
| return any(ext in file_path.lower() for ext in cls.get_all_media_extensions()) | |
| # Check for dependencies | |
| try: | |
| import httpx | |
| HTTPX_AVAILABLE = True | |
| except ImportError: | |
| HTTPX_AVAILABLE = False | |
| logger.warning("httpx not available - file upload functionality limited") | |
| # CSS Configuration | |
| CUSTOM_CSS = """ | |
| /* Hide Gradio footer */ | |
| footer { | |
| display: none !important; | |
| } | |
| /* Make chatbot expand to fill available space */ | |
| .gradio-container { | |
| height: 100vh !important; | |
| } | |
| /* Ensure proper flex layout */ | |
| .main-content { | |
| display: flex; | |
| flex-direction: column; | |
| height: 100%; | |
| } | |
| /* Input area stays at bottom with minimal padding */ | |
| .input-area { | |
| margin-top: auto; | |
| padding-top: 0.25rem !important; | |
| padding-bottom: 0 !important; | |
| margin-bottom: 0 !important; | |
| } | |
| /* Reduce padding around chatbot */ | |
| .chatbot { | |
| margin-bottom: 0 !important; | |
| padding-bottom: 0 !important; | |
| } | |
| """ |