ysharma HF Staff commited on
Commit
fc657fc
·
verified ·
1 Parent(s): d9e41f8

Create config.py

Browse files
Files changed (1) hide show
  1. config.py +112 -0
config.py ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Configuration module for Universal MCP Client
3
+ """
4
+ import os
5
+ from dataclasses import dataclass
6
+ from typing import Optional
7
+ import logging
8
+
9
+ # Set up enhanced logging
10
+ logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
11
+ logger = logging.getLogger(__name__)
12
+
13
+ @dataclass
14
+ class MCPServerConfig:
15
+ """Configuration for an MCP server connection"""
16
+ name: str
17
+ url: str
18
+ description: str
19
+ space_id: Optional[str] = None
20
+
21
+ class AppConfig:
22
+ """Application configuration settings"""
23
+
24
+ # API Configuration
25
+ ANTHROPIC_API_KEY = os.getenv("ANTHROPIC_API_KEY")
26
+
27
+ # Model Configuration
28
+ CLAUDE_MODEL = "claude-sonnet-4-20250514"
29
+ MAX_TOKENS = 2048
30
+
31
+ # MCP Configuration
32
+ MCP_BETA_VERSION = "mcp-client-2025-04-04"
33
+ MCP_TIMEOUT_SECONDS = 20.0
34
+
35
+ # UI Configuration
36
+ GRADIO_THEME = "citrus"
37
+ DEBUG_MODE = True
38
+
39
+ # File Support
40
+ SUPPORTED_IMAGE_EXTENSIONS = ['.png', '.jpg', '.jpeg', '.gif', '.webp']
41
+ SUPPORTED_AUDIO_EXTENSIONS = ['.mp3', '.wav', '.ogg', '.m4a', '.flac']
42
+ SUPPORTED_VIDEO_EXTENSIONS = ['.mp4', '.avi', '.mov']
43
+ SUPPORTED_DOCUMENT_EXTENSIONS = ['.pdf', '.txt', '.docx']
44
+
45
+ @classmethod
46
+ def get_all_media_extensions(cls):
47
+ """Get all supported media file extensions"""
48
+ return (cls.SUPPORTED_IMAGE_EXTENSIONS +
49
+ cls.SUPPORTED_AUDIO_EXTENSIONS +
50
+ cls.SUPPORTED_VIDEO_EXTENSIONS)
51
+
52
+ @classmethod
53
+ def is_image_file(cls, file_path: str) -> bool:
54
+ """Check if file is an image"""
55
+ return any(ext in file_path.lower() for ext in cls.SUPPORTED_IMAGE_EXTENSIONS)
56
+
57
+ @classmethod
58
+ def is_audio_file(cls, file_path: str) -> bool:
59
+ """Check if file is an audio file"""
60
+ return any(ext in file_path.lower() for ext in cls.SUPPORTED_AUDIO_EXTENSIONS)
61
+
62
+ @classmethod
63
+ def is_video_file(cls, file_path: str) -> bool:
64
+ """Check if file is a video file"""
65
+ return any(ext in file_path.lower() for ext in cls.SUPPORTED_VIDEO_EXTENSIONS)
66
+
67
+ @classmethod
68
+ def is_media_file(cls, file_path: str) -> bool:
69
+ """Check if file is any supported media type"""
70
+ return any(ext in file_path.lower() for ext in cls.get_all_media_extensions())
71
+
72
+ # Check for dependencies
73
+ try:
74
+ import httpx
75
+ HTTPX_AVAILABLE = True
76
+ except ImportError:
77
+ HTTPX_AVAILABLE = False
78
+ logger.warning("httpx not available - file upload functionality limited")
79
+
80
+ # CSS Configuration
81
+ CUSTOM_CSS = """
82
+ /* Hide Gradio footer */
83
+ footer {
84
+ display: none !important;
85
+ }
86
+
87
+ /* Make chatbot expand to fill available space */
88
+ .gradio-container {
89
+ height: 100vh !important;
90
+ }
91
+
92
+ /* Ensure proper flex layout */
93
+ .main-content {
94
+ display: flex;
95
+ flex-direction: column;
96
+ height: 100%;
97
+ }
98
+
99
+ /* Input area stays at bottom with minimal padding */
100
+ .input-area {
101
+ margin-top: auto;
102
+ padding-top: 0.25rem !important;
103
+ padding-bottom: 0 !important;
104
+ margin-bottom: 0 !important;
105
+ }
106
+
107
+ /* Reduce padding around chatbot */
108
+ .chatbot {
109
+ margin-bottom: 0 !important;
110
+ padding-bottom: 0 !important;
111
+ }
112
+ """