Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add implementation for paper "A Multi-LLM Agent" #291

Merged
merged 136 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from 132 commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
9090538
update
wangyijunlyy Dec 2, 2023
3fce704
update
wangyijunlyy Dec 2, 2023
649c3ae
add style_repaint
wangyijunlyy Dec 12, 2023
3b48baf
恢复
wangyijunlyy Dec 12, 2023
5d73f22
恢复
wangyijunlyy Dec 12, 2023
9259188
解决合并冲突
wangyijunlyy Dec 12, 2023
e2c8a67
add style_repaint tool
wangyijunlyy Dec 12, 2023
c67430d
modify style_repaint
wangyijunlyy Dec 14, 2023
df77577
fix error
wangyijunlyy Dec 14, 2023
81ac82c
fix
wangyijunlyy Dec 14, 2023
cbe8236
fix rate limit
wangyijunlyy Dec 15, 2023
092a914
improve stability
wangyijunlyy Dec 15, 2023
b2ebd10
use dashscope to convert url
wangyijunlyy Dec 19, 2023
81866ff
update
wangyijunlyy Dec 19, 2023
a0cf87f
modify and better
wangyijunlyy Dec 19, 2023
6d29120
fix
wangyijunlyy Dec 19, 2023
f375ff0
refact framework: add base class for llm, tool, and agent
tuhahaha Jan 3, 2024
0d0dc8d
refact llm
tuhahaha Jan 4, 2024
31aeb30
refact llm for custom
tuhahaha Jan 4, 2024
4609cb2
add role_play agent
tuhahaha Jan 4, 2024
80cfa38
add unittest for role-play agent
tuhahaha Jan 4, 2024
b60db37
refactor/tool/image_gen
Jan 4, 2024
fd6537e
fix pre-commit
Jan 4, 2024
d4b68fc
add agent_builder agent
tuhahaha Jan 4, 2024
4689856
revert modelscope_agent/agent.py
Jan 5, 2024
b4bb3b8
Merge pull request #247 from suluyana/refactor/tool/image_gen
tuhahaha Jan 5, 2024
388e152
update agent and add react prompt
tuhahaha Jan 5, 2024
6cb1217
adapt agentbuilder in apps
tuhahaha Jan 8, 2024
41f6854
Merge remote-tracking branch 'upstream/refactor0103' into new_version
wangyijunlyy Jan 8, 2024
10c78f1
update style_repaint
wangyijunlyy Jan 8, 2024
4ad14ca
update style_repaint
wangyijunlyy Jan 8, 2024
053ad15
Merge pull request #250 from wangyijunlyy/new_version
tuhahaha Jan 8, 2024
b5f2a0b
change pipeline plugin tool (#248)
mushenL Jan 8, 2024
deba841
refactor ms agent
Jan 9, 2024
3e38201
save system to history
Jan 9, 2024
ddbf6e4
avoid duplicated system in roleplay
Jan 9, 2024
716aec8
builder with history running
Jan 9, 2024
079e85a
test case
wangyijunlyy Jan 9, 2024
5fbaf67
update tool
wangyijunlyy Jan 9, 2024
316931b
update
wangyijunlyy Jan 9, 2024
0c966d0
modify import method
wangyijunlyy Jan 9, 2024
812fe8d
Merge pull request #251 from wangyijunlyy/new_version
tuhahaha Jan 9, 2024
181b07d
code interpreter and knowledge
Jan 10, 2024
a3bf326
running code interpreter with file
Jan 10, 2024
c3efe6b
Refactor/citest (#257)
zzhangpurdue Jan 10, 2024
2a3b43d
add modelscope tool (#258)
mushenL Jan 11, 2024
7abdbd3
unittest-web search web browser
Jan 11, 2024
d968bf0
Merge branch 'refactor0103' of github.com:modelscope/modelscope-agent…
Jan 11, 2024
5dd2975
update tool and unittest
Jan 11, 2024
5346fe2
Refactor/gradio4 (#260)
suluyana Jan 12, 2024
9f97e1a
update reame and tool cfg
tuhahaha Jan 12, 2024
42f94cd
Merge branch 'refactor0103' of https://github.com/modelscope/modelsco…
tuhahaha Jan 12, 2024
92467e1
Refactor/unittest (#264)
zzhangpurdue Jan 13, 2024
ef7711f
Merge remote-tracking branch 'origin/master' into refactor0103
Jan 13, 2024
148a423
merge origin master
Jan 13, 2024
ace5831
fix bugs
Jan 13, 2024
17d9a0d
fix video-to-image
Jan 13, 2024
09dc91d
add qwen-max
Jan 15, 2024
408bd92
fix apps/agentfabric & update release version
Jan 15, 2024
fefdf54
apps/agentfabric/user_core.py
Jan 15, 2024
d0e11f1
fix pre-commit
Jan 15, 2024
79cfacc
Merge branch 'refactor0103' into release/0.3.0
Jan 15, 2024
2e72081
fix bugs & add video play for code interpreter
Jan 15, 2024
f5f4a89
comment out translate
Jan 15, 2024
3ccf308
Refactor log (#268)
lylalala Jan 15, 2024
9500ec7
Refactor/knowledgeretrieval (#271)
zzhangpurdue Jan 15, 2024
694154a
Merge remote-tracking branch 'origin/release/0.3.0' into refactor0103
Jan 15, 2024
5fce22c
add logger (#272)
zzhangpurdue Jan 15, 2024
36d250f
pass code unittest
Jan 15, 2024
7ecaf91
Merge branch 'release/0.3.0' into refactor0103
Jan 15, 2024
3b0f236
fix publish for missing MODELSCOPE_API_TOKEN alert & rm translation tool
Jan 16, 2024
8c8b611
fix bugs
Jan 16, 2024
deb2825
update log
Jan 16, 2024
93e2cda
fix bugs
Jan 17, 2024
c69bc5c
fix instruction
Jan 17, 2024
8437504
fix tool log
Jan 17, 2024
7dc36d1
fix bugs
Jan 19, 2024
a042aa0
fix pre-commit
Jan 19, 2024
517ff5f
Zhipu-glm4 (#276)
suluyana Jan 19, 2024
2bb40f3
add zhipuai to requirements.txt
Jan 19, 2024
caa1af9
make sure .md file is parsed by nltk
zzhangpurdue Jan 19, 2024
84c38e3
Update demo 20240118 (#275)
mushenL Jan 19, 2024
e671b63
add zhipuai
zzhangpurdue Jan 19, 2024
c23d191
Merge branch 'release/0.3.0' into refactor0103
zzhangpurdue Jan 21, 2024
be9777b
update retrieval knowledge logic to not load in agent fabric
zzhangpurdue Jan 22, 2024
53f92ca
update name
zzhangpurdue Jan 22, 2024
9097520
Merge branch 'release/0.3.0' of github.com:modelscope/modelscope-agen…
Jan 22, 2024
c275142
fix bugs
Jan 22, 2024
43ed672
fix pre-commit
Jan 22, 2024
5979950
fix ci
Jan 22, 2024
786a947
update max_token setting
zzhangpurdue Jan 22, 2024
2df7096
Merge remote-tracking branch 'origin/release/0.3.0' into release/0.3.0
zzhangpurdue Jan 22, 2024
da9e7e4
fix doc list extend method
zzhangpurdue Jan 23, 2024
6b91f14
fix ci
zzhangpurdue Jan 23, 2024
6388e69
fix ci
zzhangpurdue Jan 23, 2024
53d40c8
add docstr
tuhahaha Jan 24, 2024
befd8c5
rm useless agent: function call, react, react_chat
tuhahaha Jan 24, 2024
5ebc687
bugfix
tuhahaha Jan 24, 2024
1094f14
bugfix
tuhahaha Jan 24, 2024
5f7292e
bugfix: change _detect_tool for role_play
tuhahaha Jan 24, 2024
00515dc
remove uuid related log in ms
zzhangpurdue Jan 24, 2024
6c38563
fix publish avatar
Jan 25, 2024
6c1d023
version 0.3.0rc0
Jan 26, 2024
7e3bb66
fix bugs
zzhangpurdue Jan 26, 2024
938aac2
fix bug
Jan 26, 2024
bbc572b
fix audio->video
Jan 26, 2024
ad8abbc
Merge remote-tracking branch 'origin/release/0.3.0' into refactor0103
zzhangpurdue Jan 28, 2024
88033b3
feat: openapi
Jan 29, 2024
f0ca639
fix pre-commit
Jan 30, 2024
209d3da
update demo
zzhangpurdue Jan 30, 2024
e0a232a
bug fixed by comment
zzhangpurdue Jan 30, 2024
3a930ff
lint pass
zzhangpurdue Jan 30, 2024
82aefed
bug fixed
zzhangpurdue Jan 30, 2024
5cc2110
bug fixed
zzhangpurdue Jan 30, 2024
eb9907e
update
shenwzh3 Feb 1, 2024
782b034
update openai llm
Feb 1, 2024
946ad3e
Merge branch 'refactor0103' into alpha_umi
Feb 1, 2024
7f98951
debug & fix pre-commit
Feb 1, 2024
a653fc7
bugs fix & add demo
Feb 2, 2024
59ba6f7
Merge remote-tracking branch 'origin' into alpha_umi
Feb 23, 2024
4c15ee9
fix lint
Feb 23, 2024
b48afe1
fix ci
Feb 23, 2024
225a32e
fix bug in alpha_umi agent, change test case
shenwzh3 Feb 26, 2024
488bfc4
fix bug of alphaumi
shenwzh3 Feb 28, 2024
bcfe7b2
fix bug
shenwzh3 Feb 28, 2024
6c3c897
fix bug
shenwzh3 Feb 28, 2024
afd23e8
fix bug
shenwzh3 Feb 28, 2024
11c7c68
fix bug
shenwzh3 Feb 28, 2024
6d2e2fd
fix bug
shenwzh3 Feb 28, 2024
f508f67
add tools and fix bug
shenwzh3 Feb 28, 2024
640ad45
fix bug
shenwzh3 Feb 28, 2024
d37e45d
add alpha_umi demo
shenwzh3 Feb 29, 2024
33f7dec
fix bug & add rapidapi tool test
shenwzh3 Feb 29, 2024
79d5485
add rapidapi tool test
shenwzh3 Feb 29, 2024
8bd15d2
rename class name
zzhangpurdue Feb 29, 2024
36ad926
update sh
zzhangpurdue Feb 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .dev_scripts/dockerci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ cp tests/samples/* "${CODE_INTERPRETER_WORK_DIR}/"
ls "${CODE_INTERPRETER_WORK_DIR}"

# run ci
pytest
pytest tests
24 changes: 24 additions & 0 deletions demo/alpha_umi/run_deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export PYTHONPATH=./

export VLLM_USE_MODELSCOPE=True
python -m vllm.entrypoints.openai.api_server \
--model=iic/alpha-umi-planner-7b \
--revision=v1.0.0 --trust-remote-code \
--port 8090 \
--dtype float16 \
--gpu-memory-utilization 0.3 > planner.log &

python -m vllm.entrypoints.openai.api_server \
--model=iic/alpha-umi-caller-7b \
--revision=v1.0.0 --trust-remote-code \
--port 8091 \
--dtype float16 \
--gpu-memory-utilization 0.3 > caller.log &

python -m vllm.entrypoints.openai.api_server \
--model=iic/alpha-umi-summarizer-7b \
--revision=v1.0.0 --trust-remote-code \
--port 8092 \
--dtype float16 \
--gpu-memory-utilization 0.3 > summarizer.log &

5 changes: 5 additions & 0 deletions demo/alpha_umi/run_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export PYTHONPATH=./
export RAPID_API_TOKEN="1010919056msh03dc548f7c5ff35p1e0988jsndc80beff3fa8"
export MODELSCOPE_API_TOKEN="b9144b02-b94c-4c62-956d-a4c8228854e9"

python demo/alpha_umi/test_alpha_umi.py
53 changes: 53 additions & 0 deletions demo/alpha_umi/test_alpha_umi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import os
import time

from modelscope_agent.agents.alpha_umi import AlphaUmi
from openai import OpenAI

llm_configs = {
'planner_llm_config': {
'model': 'iic/alpha-umi-planner-7b',
'model_server': 'openai',
'api_base': 'http://localhost:8090/v1',
'is_chat': False
},
'caller_llm_config': {
'model': 'iic/alpha-umi-caller-7b',
'model_server': 'openai',
'api_base': 'http://localhost:8091/v1',
'is_chat': False
},
'summarizer_llm_config': {
'model': 'iic/alpha-umi-summarizer-7b',
'model_server': 'openai',
'api_base': 'http://localhost:8092/v1',
'is_chat': False
},
}


def test_alpha_umi():
function_list = [
"get_data_fact_for_numbers", "get_math_fact_for_numbers",
"get_year_fact_for_numbers", "listquotes_for_current_exchange",
"exchange_for_current_exchange"
]

bot = AlphaUmi(
function_list=function_list,
llm_planner=llm_configs['planner_llm_config'],
llm_caller=llm_configs['caller_llm_config'],
llm_summarizer=llm_configs['summarizer_llm_config'],
)

response = bot.run('how many CNY can I exchange for 1 US dollar? \
also, give me a special property about the number of CNY after exchange'
)

for chunk in response:
print(chunk)


if __name__ == '__main__':

test_alpha_umi()
254 changes: 254 additions & 0 deletions demo/demo_alpha_umi.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,254 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "45d56c67-7439-4264-912a-c0b4895cac63",
"metadata": {
"execution": {
"iopub.execute_input": "2023-09-04T14:17:41.716630Z",
"iopub.status.busy": "2023-09-04T14:17:41.716258Z",
"iopub.status.idle": "2023-09-04T14:17:42.097933Z",
"shell.execute_reply": "2023-09-04T14:17:42.097255Z",
"shell.execute_reply.started": "2023-09-04T14:17:41.716610Z"
}
},
"source": [
"### clone代码"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3851d799-7162-4e73-acab-3c13cb1e43bd",
"metadata": {
"ExecutionIndicator": {
"show": true
},
"tags": []
},
"outputs": [],
"source": [
"!git clone https://github.com/modelscope/modelscope-agent.git"
]
},
{
"cell_type": "markdown",
"id": "f71e64d0-f967-4244-98ba-4e5bc4530883",
"metadata": {
"execution": {
"iopub.execute_input": "2023-09-04T14:17:41.716630Z",
"iopub.status.busy": "2023-09-04T14:17:41.716258Z",
"iopub.status.idle": "2023-09-04T14:17:42.097933Z",
"shell.execute_reply": "2023-09-04T14:17:42.097255Z",
"shell.execute_reply.started": "2023-09-04T14:17:41.716610Z"
}
},
"source": [
"### 安装特定依赖"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "489900d6-cc33-4ada-b2be-7e3a139cf6ed",
"metadata": {},
"outputs": [],
"source": [
"! cd modelscope-agent && pip install -r requirements.txt"
]
},
{
"cell_type": "markdown",
"id": "9e9f3150",
"metadata": {},
"source": [
"### 本地配置"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a027a6e8",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"os.chdir('modelscope-agent/demo')\n",
"\n",
"import sys\n",
"sys.path.append('../')"
]
},
{
"cell_type": "markdown",
"id": "8f35e3f7",
"metadata": {},
"source": [
"### 部署模型"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ad038344",
"metadata": {},
"outputs": [],
"source": [
"os.system(\"export VLLM_USE_MODELSCOPE=True\")\n",
"os.system(\"python -m vllm.entrypoints.openai.api_server \\\n",
" --model=iic/alpha-umi-planner-7b \\\n",
" --revision=v1.0.0 --trust-remote-code \\\n",
" --port 8090 \\\n",
" --dtype float16 \\\n",
" --gpu-memory-utilization 0.3 > planner.log &\")\n",
"\n",
"os.system(\"python -m vllm.entrypoints.openai.api_server \\\n",
" --model=iic/alpha-umi-caller-7b \\\n",
" --revision=v1.0.0 --trust-remote-code \\\n",
" --port 8091 \\\n",
" --dtype float16 \\\n",
" --gpu-memory-utilization 0.3 > caller.log &\")\n",
"\n",
"os.system(\"python -m vllm.entrypoints.openai.api_server \\\n",
" --model=iic/alpha-umi-summarizer-7b \\\n",
" --revision=v1.0.0 --trust-remote-code \\\n",
" --port 8092 \\\n",
" --dtype float16 \\\n",
" --gpu-memory-utilization 0.3 > summarizer.log &\")\n"
]
},
{
"cell_type": "markdown",
"id": "3de23896",
"metadata": {},
"source": [
"### API_KEY管理"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "65e5dcc8",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
"print('请输入DASHSCOPE_API_KEY')\n",
"os.environ['DASHSCOPE_API_KEY'] = input()\n",
"print('请输入ModelScope Token')\n",
"os.environ['MODELSCOPE_API_TOKEN'] = input()\n",
"print('请输入RapidAPI Token')\n",
"os.environ['RAPID_API_TOKEN'] = input()"
]
},
{
"cell_type": "markdown",
"id": "8c8defa3",
"metadata": {},
"source": [
"### 构建agent"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "01e90564",
"metadata": {},
"outputs": [],
"source": [
"from modelscope_agent.agents.alpha_umi import AlphaUmi\n",
"\n",
"\n",
"llm_configs = {\n",
" 'planner_llm_config': {\n",
" 'model': 'iic/alpha-umi-planner-7b',\n",
" 'model_server': 'openai',\n",
" 'api_base': 'http://localhost:8090/v1',\n",
" 'is_chat': False\n",
" },\n",
" 'caller_llm_config': {\n",
" 'model': 'iic/alpha-umi-caller-7b',\n",
" 'model_server': 'openai',\n",
" 'api_base': 'http://localhost:8091/v1',\n",
" 'is_chat': False\n",
" },\n",
" 'summarizer_llm_config': {\n",
" 'model': 'iic/alpha-umi-summarizer-7b',\n",
" 'model_server': 'openai',\n",
" 'api_base': 'http://localhost:8092/v1',\n",
" 'is_chat': False\n",
" },\n",
"}\n",
"\n",
"\n",
"\n",
"function_list = [\"get_data_fact_for_numbers\", \"get_math_fact_for_numbers\", \"get_year_fact_for_numbers\",\n",
" \"listquotes_for_current_exchange\",\n",
" \"exchange_for_current_exchange\"]\n",
"\n",
"\n",
"bot = AlphaUmi(\n",
" function_list=function_list,\n",
" llm_planner=llm_configs['planner_llm_config'],\n",
" llm_caller=llm_configs['caller_llm_config'],\n",
" llm_summarizer=llm_configs['summarizer_llm_config'],\n",
" )\n",
"\n"
]
},
{
"cell_type": "markdown",
"id": "064ad74e",
"metadata": {},
"source": [
"### 执行agent"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fdd379ab",
"metadata": {},
"outputs": [],
"source": [
"response = bot.run('how many CNY can I exchange for 3.5 US dollar? \\\n",
" also, give me a special property about the number of CNY after exchange')\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "85434381",
"metadata": {},
"outputs": [],
"source": [
"text = ''\n",
"for chunk in response:\n",
" text += chunk\n",
"print(text)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading
Loading