Skip to content

Commit dc83fa4

Browse files
authored
Feat/webui code genesis (#843)
1 parent 0b4f010 commit dc83fa4

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ include README.md
22
include LICENSE
33
include requirements.txt
44
recursive-include requirements *.txt
5+
recursive-include ms_agent/ *.yaml
56

67
# Include projects
78
recursive-include projects *

webui/backend/agent_runner.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,30 @@ def _build_command(self, query: str) -> list:
237237
if llm_config.get('api_key'):
238238
provider = llm_config.get('provider', 'modelscope')
239239
if provider == 'modelscope':
240-
cmd.extend(['--modelscope_api_key', llm_config['api_key']])
240+
cmd.extend(
241+
['--llm.modelscope_api_key', llm_config['api_key']])
242+
# Set llm.service to modelscope to ensure the correct service is used
243+
cmd.extend(['--llm.service', 'modelscope'])
244+
# Pass base_url if set by user
245+
if llm_config.get('base_url'):
246+
cmd.extend([
247+
'--llm.modelscope_base_url', llm_config['base_url']
248+
])
249+
# Pass model if set by user
250+
if llm_config.get('model'):
251+
cmd.extend(['--llm.model', llm_config['model']])
252+
# Pass temperature if set by user (in generation_config)
253+
if llm_config.get('temperature') is not None:
254+
cmd.extend([
255+
'--generation_config.temperature',
256+
str(llm_config['temperature'])
257+
])
258+
# Pass max_tokens if set by user (in generation_config)
259+
if llm_config.get('max_tokens'):
260+
cmd.extend([
261+
'--generation_config.max_tokens',
262+
str(llm_config['max_tokens'])
263+
])
241264
elif provider == 'openai':
242265
cmd.extend(['--llm.openai_api_key', llm_config['api_key']])
243266
# Set llm.service to openai to ensure the correct service is used

webui/backend/websocket_handler.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,19 +144,19 @@ async def start_agent(session_id: str, data: Dict[str, Any],
144144
# For chat mode, use default chat agent config
145145
if session_type == 'chat':
146146
# Create a virtual project for chat mode using the default agent.yaml
147+
import ms_agent
147148
from pathlib import Path
148-
# Find ms_agent path relative to this file (webui/backend -> ms_agent)
149-
backend_dir = Path(__file__).parent
150-
ms_agent_path = backend_dir.parent.parent / 'ms_agent'
151-
chat_config_path = ms_agent_path / 'agent' / 'agent.yaml'
149+
# Get ms_agent package installation path
150+
ms_agent_package_path = Path(ms_agent.__file__).parent
151+
chat_config_path = ms_agent_package_path / 'agent' / 'agent.yaml'
152152

153153
project = {
154154
'id': '__chat__',
155155
'name': 'Chat Assistant',
156156
'display_name': 'Chat Assistant',
157157
'description': 'Default chat mode',
158158
'type': 'agent',
159-
'path': str(ms_agent_path / 'agent'),
159+
'path': str(ms_agent_package_path / 'agent'),
160160
'config_file': str(chat_config_path),
161161
'has_readme': False,
162162
'supports_workflow_switch': False

0 commit comments

Comments
 (0)