Skip to content

Commit b701610

Browse files
wangxingjun778luyanlocal
authored
Update mcp pipeline and refactor mcp module (#620)
Co-authored-by: luyan <luyan@U-V61TJ94D-2208.local> Co-authored-by: local <suluyan.sly@alibaba-inc.com>
1 parent 5aabfc0 commit b701610

File tree

9 files changed

+1048
-151
lines changed

9 files changed

+1048
-151
lines changed

examples/mcp_apps/web_generator.py

Lines changed: 53 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from modelscope_agent.agents.agent_with_mcp import AgentWithMCP # NOQA
2-
31
import os
42

3+
from modelscope_agent.agents.agent_with_mcp import AgentWithMCP # NOQA
4+
55

66
def test_web_gen():
77

@@ -23,36 +23,74 @@ def test_web_gen():
2323
}
2424
}
2525

26-
default_system = (
27-
'You are an assistant which helps me to finish a complex job. Tools may be given to you '
28-
'and you must choose some of them one per round to finish my request.')
29-
3026
llm_config = {
31-
'model': 'Qwen/Qwen2.5-72B-Instruct',
27+
'model':
28+
'Qwen/Qwen3-235B-A22B', # Qwen/Qwen3-235B-A22B, Qwen/Qwen2.5-72B-Instruct
3229
'model_server': 'https://api-inference.modelscope.cn/v1/',
3330
'api_key': os.getenv('MODELSCOPE_API_KEY')
3431
}
3532

33+
# ONLY FOR TEST
34+
function_list = [{
35+
'mcpServers': {
36+
'amap-maps': {
37+
'type': 'sse',
38+
'url': 'https://mcp.api-inference.modelscope.cn/sse/xxx'
39+
},
40+
'MiniMax-MCP': {
41+
'type': 'sse',
42+
'url': 'https://mcp.api-inference.modelscope.cn/sse/xxx'
43+
},
44+
'web-search': {
45+
'command': 'npx',
46+
'args': ['-y', 'tavily-mcp@0.1.4'],
47+
'env': {
48+
'TAVILY_API_KEY': ''
49+
},
50+
'disabled': False,
51+
'autoApprove': []
52+
},
53+
'edgeone-pages-mcp-server': {
54+
'command': 'npx',
55+
'args': ['edgeone-pages-mcp']
56+
},
57+
'notebook': None,
58+
}
59+
}]
60+
3661
bot = AgentWithMCP(
37-
mcp=mcp_servers, llm=llm_config, instruction=default_system)
62+
function_list=function_list,
63+
mcp=mcp_servers,
64+
llm=llm_config,
65+
)
3866

3967
# Construct requests
4068
messages = [{
41-
'role': 'system',
42-
'content': default_system
43-
}, {
4469
'role': 'user',
45-
'content': '上周日几号?那天北京天气情况如何'
70+
# 'content': '上周日几号?那天北京天气情况如何'
71+
'content': '做一个图文并茂的绘本故事,部署成一个网页。'
4672
}]
4773

74+
kwargs = {}
75+
kwargs.update({
76+
'stream': True,
77+
'max_tokens': 16384,
78+
'extra_body': {
79+
'enable_thinking': False
80+
}
81+
})
82+
4883
response = bot.run(
4984
messages=messages,
50-
stream=True,
51-
seed=None,
85+
**kwargs,
5286
)
5387

5488
for chunk in response:
55-
print(chunk)
89+
print('\n')
90+
print('-' * 100)
91+
print(f'>>chunk: {chunk}')
92+
print('+' * 100)
93+
print('\n')
5694

5795

5896
if __name__ == '__main__':

0 commit comments

Comments
 (0)