arterm-sedov commited on
Commit
f8fdd0d
Β·
1 Parent(s): ad7800b

Add centralized agent configuration and environment variable support

Browse files

- Introduced a new `agent_config.py` file to manage agent settings, including refresh intervals, language preferences, port settings, and debug options.
- Implemented environment variable support for overriding configuration values, enhancing flexibility for deployment.
- Updated the main application logic to utilize the new configuration system, allowing for easier management of settings.
- Added a new documentation file detailing the agent configuration structure and usage, providing guidance for users.
- Enhanced UI components to integrate with the new configuration, ensuring real-time updates and improved user experience.

.env.example CHANGED
@@ -20,5 +20,9 @@ GIGACHAT_TIMEOUT=30
20
  AGENT_PROVIDER=mistral
21
  ENABLE_VECTOR_SIMILARITY=false
22
  CMW_DEFAULT_LANGUAGE=ru
 
 
 
 
23
  # Unused
24
  # DEBUG_MODE=True
 
20
  AGENT_PROVIDER=mistral
21
  ENABLE_VECTOR_SIMILARITY=false
22
  CMW_DEFAULT_LANGUAGE=ru
23
+ CMW_DEFAULT_LANGUAGE=ru
24
+ CMW_DEFAULT_PORT=7860
25
+ CMW_DEBUG_MODE=false
26
+ CMW_VERBOSE_LOGGING=false
27
  # Unused
28
  # DEBUG_MODE=True
agent_ng/agent_config.py ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Agent Configuration
3
+ ==================
4
+
5
+ Central configuration file for the CMW Platform Agent.
6
+ Contains all configurable settings including refresh intervals, timeouts, and other parameters.
7
+ """
8
+
9
+ from dataclasses import dataclass
10
+ from typing import Dict, Any
11
+ import os
12
+
13
+ @dataclass
14
+ class RefreshIntervals:
15
+ """Auto-refresh intervals for different UI components"""
16
+ status: float = 2.0 # Status pane refresh interval (seconds)
17
+ logs: float = 3.0 # Logs pane refresh interval (seconds)
18
+ stats: float = 4.0 # Stats pane refresh interval (seconds)
19
+ progress: float = 2.0 # Progress pane refresh interval (seconds)
20
+
21
+ @dataclass
22
+ class AgentSettings:
23
+ """Main agent configuration settings"""
24
+ # Language settings
25
+ default_language: str = "ru"
26
+ supported_languages: list = None
27
+
28
+ # Port settings
29
+ default_port: int = 7860
30
+ auto_port_range: int = 10 # Number of ports to try when auto-finding
31
+
32
+ # UI settings
33
+ refresh_intervals: RefreshIntervals = None
34
+
35
+ # Agent settings
36
+ max_conversation_history: int = 50
37
+ max_tokens_per_request: int = 4000
38
+ request_timeout: float = 30.0
39
+
40
+ # Debug settings
41
+ debug_mode: bool = False
42
+ verbose_logging: bool = False
43
+
44
+ def __post_init__(self):
45
+ """Initialize default values after dataclass creation"""
46
+ if self.supported_languages is None:
47
+ self.supported_languages = ["en", "ru"]
48
+
49
+ if self.refresh_intervals is None:
50
+ self.refresh_intervals = RefreshIntervals()
51
+
52
+ class AgentConfig:
53
+ """Central configuration manager for the CMW Platform Agent"""
54
+
55
+ def __init__(self):
56
+ self.settings = AgentSettings()
57
+ self._load_from_environment()
58
+
59
+ def _load_from_environment(self):
60
+ """Load configuration from environment variables"""
61
+ # Language settings
62
+ if os.getenv('CMW_DEFAULT_LANGUAGE'):
63
+ self.settings.default_language = os.getenv('CMW_DEFAULT_LANGUAGE')
64
+
65
+ # Port settings
66
+ if os.getenv('CMW_DEFAULT_PORT'):
67
+ try:
68
+ self.settings.default_port = int(os.getenv('CMW_DEFAULT_PORT'))
69
+ except ValueError:
70
+ pass
71
+
72
+ # Debug settings
73
+ if os.getenv('CMW_DEBUG_MODE', '').lower() in ['true', '1', 'yes']:
74
+ self.settings.debug_mode = True
75
+
76
+ if os.getenv('CMW_VERBOSE_LOGGING', '').lower() in ['true', '1', 'yes']:
77
+ self.settings.verbose_logging = True
78
+
79
+ # Refresh intervals from environment
80
+ self._load_refresh_intervals_from_env()
81
+
82
+ def _load_refresh_intervals_from_env(self):
83
+ """Load refresh intervals from environment variables"""
84
+ # Note: All refresh intervals are internal application parameters
85
+ # They should be modified in the code, not via environment variables
86
+ # This method is kept for future extensibility but currently does nothing
87
+ pass
88
+
89
+ def get_refresh_intervals(self) -> RefreshIntervals:
90
+ """Get the current refresh intervals configuration"""
91
+ return self.settings.refresh_intervals
92
+
93
+ def get_language_settings(self) -> Dict[str, Any]:
94
+ """Get language-related settings"""
95
+ return {
96
+ 'default_language': self.settings.default_language,
97
+ 'supported_languages': self.settings.supported_languages
98
+ }
99
+
100
+ def get_port_settings(self) -> Dict[str, Any]:
101
+ """Get port-related settings"""
102
+ return {
103
+ 'default_port': self.settings.default_port,
104
+ 'auto_port_range': self.settings.auto_port_range
105
+ }
106
+
107
+ def get_agent_settings(self) -> Dict[str, Any]:
108
+ """Get agent-related settings"""
109
+ return {
110
+ 'max_conversation_history': self.settings.max_conversation_history,
111
+ 'max_tokens_per_request': self.settings.max_tokens_per_request,
112
+ 'request_timeout': self.settings.request_timeout
113
+ }
114
+
115
+ def get_debug_settings(self) -> Dict[str, Any]:
116
+ """Get debug-related settings"""
117
+ return {
118
+ 'debug_mode': self.settings.debug_mode,
119
+ 'verbose_logging': self.settings.verbose_logging
120
+ }
121
+
122
+ def update_setting(self, category: str, key: str, value: Any):
123
+ """Update a specific setting"""
124
+ if category == 'refresh_intervals':
125
+ if hasattr(self.settings.refresh_intervals, key):
126
+ setattr(self.settings.refresh_intervals, key, value)
127
+ elif hasattr(self.settings, key):
128
+ setattr(self.settings, key, value)
129
+
130
+ def print_config(self):
131
+ """Print current configuration"""
132
+ print("πŸ”§ Agent Configuration:")
133
+ print(f" Language: {self.settings.default_language}")
134
+ print(f" Port: {self.settings.default_port}")
135
+ print(f" Debug Mode: {self.settings.debug_mode}")
136
+ print(f" Refresh Intervals:")
137
+ print(f" Status: {self.settings.refresh_intervals.status}s")
138
+ print(f" Logs: {self.settings.refresh_intervals.logs}s")
139
+ print(f" Stats: {self.settings.refresh_intervals.stats}s")
140
+ print(f" Progress: {self.settings.refresh_intervals.progress}s")
141
+
142
+ # Global configuration instance
143
+ config = AgentConfig()
144
+
145
+ # Convenience functions for easy access
146
+ def get_refresh_intervals() -> RefreshIntervals:
147
+ """Get refresh intervals configuration"""
148
+ return config.get_refresh_intervals()
149
+
150
+ def get_language_settings() -> Dict[str, Any]:
151
+ """Get language settings"""
152
+ return config.get_language_settings()
153
+
154
+ def get_port_settings() -> Dict[str, Any]:
155
+ """Get port settings"""
156
+ return config.get_port_settings()
157
+
158
+ def get_agent_settings() -> Dict[str, Any]:
159
+ """Get agent settings"""
160
+ return config.get_agent_settings()
161
+
162
+ def get_debug_settings() -> Dict[str, Any]:
163
+ """Get debug settings"""
164
+ return config.get_debug_settings()
agent_ng/app_ng_modular.py CHANGED
@@ -26,6 +26,15 @@ from typing import List, Dict, Any, Optional, Tuple, AsyncGenerator
26
  import json
27
  import time
28
  from dataclasses import asdict
 
 
 
 
 
 
 
 
 
29
 
30
  # LangChain imports
31
  from langchain_core.messages import BaseMessage, HumanMessage, AIMessage
@@ -914,13 +923,23 @@ def main():
914
  parser = argparse.ArgumentParser(description='CMW Platform Agent')
915
  parser.add_argument('-en', '--english', action='store_true', help='Start in English')
916
  parser.add_argument('-ru', '--russian', action='store_true', help='Start in Russian')
917
- parser.add_argument('-p', '--port', type=int, default=7860, help='Port to run on (default: 7860)')
918
  parser.add_argument('--auto-port', action='store_true', help='Automatically find an available port')
 
919
  args = parser.parse_args()
920
 
921
- # Determine language from environment variable, command line, or default
922
- # Priority: Command line > Environment variable > Default (Russian)
923
- language = os.getenv('CMW_DEFAULT_LANGUAGE', 'ru') # Default to Russian
 
 
 
 
 
 
 
 
 
924
 
925
  if args.russian:
926
  language = "ru"
@@ -928,13 +947,15 @@ def main():
928
  language = "en"
929
 
930
  # Determine port
 
 
931
  if args.auto_port:
932
- port = find_available_port(args.port)
933
  if port is None:
934
- print(f"❌ Could not find an available port starting from {args.port}")
935
  sys.exit(1)
936
  else:
937
- port = args.port
938
 
939
  print(f"πŸš€ Starting LangChain-Native LLM Agent App with language detection...")
940
  print(f"🌐 Language: {language.upper()}")
 
26
  import json
27
  import time
28
  from dataclasses import asdict
29
+ # Import configuration with fallback for direct execution
30
+ try:
31
+ from agent_ng.agent_config import config, get_language_settings, get_port_settings
32
+ except ImportError:
33
+ # Fallback for direct execution
34
+ import sys
35
+ from pathlib import Path
36
+ sys.path.append(str(Path(__file__).parent))
37
+ from agent_config import config, get_language_settings, get_port_settings
38
 
39
  # LangChain imports
40
  from langchain_core.messages import BaseMessage, HumanMessage, AIMessage
 
923
  parser = argparse.ArgumentParser(description='CMW Platform Agent')
924
  parser.add_argument('-en', '--english', action='store_true', help='Start in English')
925
  parser.add_argument('-ru', '--russian', action='store_true', help='Start in Russian')
926
+ parser.add_argument('-p', '--port', type=int, default=None, help='Port to run on (overrides config)')
927
  parser.add_argument('--auto-port', action='store_true', help='Automatically find an available port')
928
+ parser.add_argument('--config', action='store_true', help='Show current configuration')
929
  args = parser.parse_args()
930
 
931
+ # Show configuration if requested
932
+ if args.config:
933
+ config.print_config()
934
+ return
935
+
936
+ # Get language settings from central config
937
+ language_settings = get_language_settings()
938
+ port_settings = get_port_settings()
939
+
940
+ # Determine language from command line, environment variable, or config default
941
+ # Priority: Command line > Environment variable > Config default
942
+ language = language_settings['default_language']
943
 
944
  if args.russian:
945
  language = "ru"
 
947
  language = "en"
948
 
949
  # Determine port
950
+ default_port = args.port if args.port is not None else port_settings['default_port']
951
+
952
  if args.auto_port:
953
+ port = find_available_port(default_port, port_settings['auto_port_range'])
954
  if port is None:
955
+ print(f"❌ Could not find an available port starting from {default_port}")
956
  sys.exit(1)
957
  else:
958
+ port = default_port
959
 
960
  print(f"πŸš€ Starting LangChain-Native LLM Agent App with language detection...")
961
  print(f"🌐 Language: {language.upper()}")
agent_ng/tabs/chat_tab.py CHANGED
@@ -143,6 +143,9 @@ class ChatTab:
143
  outputs=[self.components["chatbot"], self.components["msg"]]
144
  )
145
 
 
 
 
146
  # Quick action events (using local methods)
147
  self.components["quick_math_btn"].click(
148
  fn=self._quick_math,
@@ -176,6 +179,32 @@ class ChatTab:
176
 
177
  print("βœ… ChatTab: All event handlers connected successfully")
178
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
  def get_components(self) -> Dict[str, Any]:
180
  """Get all components created by this tab"""
181
  return self.components
 
143
  outputs=[self.components["chatbot"], self.components["msg"]]
144
  )
145
 
146
+ # Trigger UI updates after chat events
147
+ self._setup_chat_event_triggers()
148
+
149
  # Quick action events (using local methods)
150
  self.components["quick_math_btn"].click(
151
  fn=self._quick_math,
 
179
 
180
  print("βœ… ChatTab: All event handlers connected successfully")
181
 
182
+ def _setup_chat_event_triggers(self):
183
+ """Setup event triggers to update other UI components when chat events occur"""
184
+ # Get UI update handlers
185
+ trigger_ui_update = self.event_handlers.get("trigger_ui_update")
186
+
187
+ if trigger_ui_update:
188
+ # Trigger UI update after send button click
189
+ self.components["send_btn"].click(
190
+ fn=trigger_ui_update,
191
+ outputs=[] # No specific outputs, just triggers the update
192
+ )
193
+
194
+ # Trigger UI update after message submit
195
+ self.components["msg"].submit(
196
+ fn=trigger_ui_update,
197
+ outputs=[]
198
+ )
199
+
200
+ # Trigger UI update after clear button click
201
+ self.components["clear_btn"].click(
202
+ fn=trigger_ui_update,
203
+ outputs=[]
204
+ )
205
+
206
+ print("βœ… ChatTab: UI update triggers connected")
207
+
208
  def get_components(self) -> Dict[str, Any]:
209
  """Get all components created by this tab"""
210
  return self.components
agent_ng/ui_manager.py CHANGED
@@ -11,6 +11,15 @@ import gradio as gr
11
  from pathlib import Path
12
  from typing import Dict, Any, Callable, List, Tuple, Optional
13
  import os
 
 
 
 
 
 
 
 
 
14
 
15
  class UIManager:
16
  """Manages Gradio UI creation and configuration with i18n support"""
@@ -90,7 +99,7 @@ class UIManager:
90
  update_progress_handler = event_handlers.get("update_progress_display")
91
 
92
 
93
- # Load initial UI state once on startup - no timers to avoid queue issues
94
  if "status_display" in self.components and update_status_handler:
95
  demo.load(
96
  fn=update_status_handler,
@@ -115,7 +124,55 @@ class UIManager:
115
  fn=refresh_stats_handler,
116
  outputs=[self.components["stats_display"]]
117
  )
 
 
 
118
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  def get_components(self) -> Dict[str, Any]:
120
  """Get all components created by the UI manager"""
121
  return self.components
 
11
  from pathlib import Path
12
  from typing import Dict, Any, Callable, List, Tuple, Optional
13
  import os
14
+ # Import configuration with fallback for direct execution
15
+ try:
16
+ from agent_ng.agent_config import get_refresh_intervals
17
+ except ImportError:
18
+ # Fallback for direct execution
19
+ import sys
20
+ from pathlib import Path
21
+ sys.path.append(str(Path(__file__).parent))
22
+ from agent_config import get_refresh_intervals
23
 
24
  class UIManager:
25
  """Manages Gradio UI creation and configuration with i18n support"""
 
99
  update_progress_handler = event_handlers.get("update_progress_display")
100
 
101
 
102
+ # Load initial UI state once on startup
103
  if "status_display" in self.components and update_status_handler:
104
  demo.load(
105
  fn=update_status_handler,
 
124
  fn=refresh_stats_handler,
125
  outputs=[self.components["stats_display"]]
126
  )
127
+
128
+ # Setup auto-refresh timers for real-time updates
129
+ self._setup_auto_refresh_timers(demo, event_handlers)
130
 
131
+ def _setup_auto_refresh_timers(self, demo: gr.Blocks, event_handlers: Dict[str, Callable]):
132
+ """Setup auto-refresh timers for real-time updates"""
133
+ print("πŸ”„ Setting up auto-refresh timers...")
134
+
135
+ # Get refresh intervals from central configuration
136
+ intervals = get_refresh_intervals()
137
+
138
+ # Status updates
139
+ if "status_display" in self.components and event_handlers.get("update_status"):
140
+ status_timer = gr.Timer(intervals.status, active=True)
141
+ status_timer.tick(
142
+ fn=event_handlers["update_status"],
143
+ outputs=[self.components["status_display"]]
144
+ )
145
+ print(f"βœ… Status auto-refresh timer set ({intervals.status}s)")
146
+
147
+ # Logs updates
148
+ if "logs_display" in self.components and event_handlers.get("refresh_logs"):
149
+ logs_timer = gr.Timer(intervals.logs, active=True)
150
+ logs_timer.tick(
151
+ fn=event_handlers["refresh_logs"],
152
+ outputs=[self.components["logs_display"]]
153
+ )
154
+ print(f"βœ… Logs auto-refresh timer set ({intervals.logs}s)")
155
+
156
+ # Stats updates
157
+ if "stats_display" in self.components and event_handlers.get("refresh_stats"):
158
+ stats_timer = gr.Timer(intervals.stats, active=True)
159
+ stats_timer.tick(
160
+ fn=event_handlers["refresh_stats"],
161
+ outputs=[self.components["stats_display"]]
162
+ )
163
+ print(f"βœ… Stats auto-refresh timer set ({intervals.stats}s)")
164
+
165
+ # Progress updates (for visual feedback)
166
+ if "progress_display" in self.components and event_handlers.get("update_progress_display"):
167
+ progress_timer = gr.Timer(intervals.progress, active=True)
168
+ progress_timer.tick(
169
+ fn=event_handlers["update_progress_display"],
170
+ outputs=[self.components["progress_display"]]
171
+ )
172
+ print(f"βœ… Progress auto-refresh timer set ({intervals.progress}s)")
173
+
174
+ print("πŸ”„ Auto-refresh timers configured successfully")
175
+
176
  def get_components(self) -> Dict[str, Any]:
177
  """Get all components created by the UI manager"""
178
  return self.components
docs/AGENT_CONFIGURATION.md ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Agent Configuration
2
+
3
+ ## Overview
4
+
5
+ The CMW Platform Agent uses a central configuration system that allows you to customize various settings including refresh intervals, language preferences, port settings, and debug options.
6
+
7
+ ## Configuration File
8
+
9
+ The main configuration is located in `agent_ng/agent_config.py` and provides:
10
+
11
+ - **Centralized Settings**: All configurable parameters in one place
12
+ - **Environment Variable Support**: Override settings via environment variables
13
+ - **Type Safety**: Uses dataclasses for type-safe configuration
14
+ - **Easy Access**: Simple functions to get configuration values
15
+
16
+ ## Configuration Categories
17
+
18
+ ### 1. Refresh Intervals
19
+
20
+ Controls how often different UI components are updated:
21
+
22
+ ```python
23
+ @dataclass
24
+ class RefreshIntervals:
25
+ status: float = 2.0 # Status pane refresh interval (seconds)
26
+ logs: float = 3.0 # Logs pane refresh interval (seconds)
27
+ stats: float = 4.0 # Stats pane refresh interval (seconds)
28
+ progress: float = 2.0 # Progress pane refresh interval (seconds)
29
+ ```
30
+
31
+ ### 2. Language Settings
32
+
33
+ ```python
34
+ default_language: str = "ru" # Default language (ru/en)
35
+ supported_languages: list = ["en", "ru"] # Supported languages
36
+ ```
37
+
38
+ ### 3. Port Settings
39
+
40
+ ```python
41
+ default_port: int = 7860 # Default port
42
+ auto_port_range: int = 10 # Number of ports to try when auto-finding
43
+ ```
44
+
45
+ ### 4. Agent Settings
46
+
47
+ ```python
48
+ max_conversation_history: int = 50 # Max conversation history
49
+ max_tokens_per_request: int = 4000 # Max tokens per request
50
+ request_timeout: float = 30.0 # Request timeout in seconds
51
+ ```
52
+
53
+ ### 5. Debug Settings
54
+
55
+ ```python
56
+ debug_mode: bool = False # Enable debug mode
57
+ verbose_logging: bool = False # Enable verbose logging
58
+ ```
59
+
60
+ ## Environment Variables
61
+
62
+ You can override any configuration using environment variables:
63
+
64
+ ### Language Settings
65
+ ```bash
66
+ # Set default language
67
+ export CMW_DEFAULT_LANGUAGE="en" # or "ru"
68
+ ```
69
+
70
+ ### Port Settings
71
+ ```bash
72
+ # Set default port
73
+ export CMW_DEFAULT_PORT="7861"
74
+ ```
75
+
76
+ ### Refresh Intervals
77
+ ```bash
78
+ # Note: All refresh intervals are internal application parameters
79
+ # and should be modified in the code, not via environment variables
80
+ #
81
+ # To modify refresh intervals, edit agent_ng/agent_config.py:
82
+ # - Status: 2.0s (internal)
83
+ # - Logs: 3.0s (internal)
84
+ # - Stats: 4.0s (internal)
85
+ # - Progress: 2.0s (internal)
86
+ ```
87
+
88
+ ### Debug Settings
89
+ ```bash
90
+ # Enable debug mode
91
+ export CMW_DEBUG_MODE="true"
92
+ export CMW_VERBOSE_LOGGING="true"
93
+ ```
94
+
95
+ ## Command Line Usage
96
+
97
+ ### View Current Configuration
98
+ ```bash
99
+ python agent_ng/app_ng_modular.py --config
100
+ ```
101
+
102
+ ### Override Settings
103
+ ```bash
104
+ # Override port
105
+ python agent_ng/app_ng_modular.py --en -p 7861
106
+
107
+ # Use auto port finding
108
+ python agent_ng/app_ng_modular.py --ru --auto-port
109
+ ```
110
+
111
+ ## Programmatic Usage
112
+
113
+ ### Get Configuration Values
114
+ ```python
115
+ from agent_ng.agent_config import get_refresh_intervals, get_language_settings
116
+
117
+ # Get refresh intervals
118
+ intervals = get_refresh_intervals()
119
+ print(f"Status updates every {intervals.status} seconds")
120
+
121
+ # Get language settings
122
+ lang_settings = get_language_settings()
123
+ print(f"Default language: {lang_settings['default_language']}")
124
+ ```
125
+
126
+ ### Update Configuration
127
+ ```python
128
+ from agent_ng.agent_config import config
129
+
130
+ # Update refresh intervals
131
+ config.update_setting('refresh_intervals', 'status', 1.0) # 1 second
132
+ config.update_setting('refresh_intervals', 'logs', 2.0) # 2 seconds
133
+
134
+ # Update other settings
135
+ config.update_setting('agent_settings', 'max_tokens_per_request', 8000)
136
+ ```
137
+
138
+ ## Default Values
139
+
140
+ | Setting | Default Value | Description | Environment Configurable |
141
+ |---------|---------------|-------------|-------------------------|
142
+ | `status` | 2.0s | Status pane refresh interval | ❌ Internal only |
143
+ | `logs` | 3.0s | Logs pane refresh interval | ❌ Internal only |
144
+ | `stats` | 4.0s | Stats pane refresh interval | ❌ Internal only |
145
+ | `progress` | 2.0s | Progress pane refresh interval | ❌ Internal only |
146
+ | `default_language` | "ru" | Default language | βœ… `CMW_DEFAULT_LANGUAGE` |
147
+ | `default_port` | 7860 | Default port | βœ… `CMW_DEFAULT_PORT` |
148
+ | `auto_port_range` | 10 | Port range for auto-finding | ❌ Internal only |
149
+ | `max_conversation_history` | 50 | Max conversation history | ❌ Internal only |
150
+ | `max_tokens_per_request` | 4000 | Max tokens per request | ❌ Internal only |
151
+ | `request_timeout` | 30.0s | Request timeout | ❌ Internal only |
152
+ | `debug_mode` | False | Debug mode | βœ… `CMW_DEBUG_MODE` |
153
+ | `verbose_logging` | False | Verbose logging | βœ… `CMW_VERBOSE_LOGGING` |
154
+
155
+ ## Best Practices
156
+
157
+ 1. **Use Environment Variables**: For deployment and different environments
158
+ 2. **Keep Defaults Sensible**: Default values should work for most use cases
159
+ 3. **Document Changes**: When modifying defaults, update documentation
160
+ 4. **Test Configuration**: Always test configuration changes
161
+ 5. **Use Type Hints**: Configuration uses type hints for better IDE support
162
+
163
+ ## Troubleshooting
164
+
165
+ ### Configuration Not Loading
166
+ - Check that `agent_ng/agent_config.py` is properly imported
167
+ - Verify environment variable names are correct
168
+ - Check for typos in configuration keys
169
+
170
+ ### Refresh Intervals Not Working
171
+ - Ensure the UI Manager is using `get_refresh_intervals()`
172
+ - Check that timer components are properly created
173
+ - Verify event handlers are connected
174
+
175
+ ### Port Issues
176
+ - Check if port is already in use
177
+ - Use `--auto-port` flag for automatic port finding
178
+ - Verify port range settings
179
+
180
+ ## Future Enhancements
181
+
182
+ - **Configuration File**: Support for YAML/JSON configuration files
183
+ - **Hot Reload**: Reload configuration without restarting
184
+ - **Validation**: Configuration validation and error reporting
185
+ - **Profiles**: Different configuration profiles for different environments
186
+ - **UI Configuration**: Web-based configuration interface