Skip to content

Commit dfdafd9

Browse files
ok Merge branch 'main' of github.com:modelscope/ms-agent into release/1.1
2 parents aedae57 + 18ad76e commit dfdafd9

File tree

23 files changed

+595
-145
lines changed

23 files changed

+595
-145
lines changed

.dev_scripts/dockerci.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
#!/bin/bash
22

33
# install dependencies for ci
4-
5-
sudo apt-get install libcurl4 openssl
6-
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-7.0.11.tgz
7-
tar -zxvf mongodb-linux-x86_64-ubuntu2004-7.0.11.tgz
8-
export PATH=`pwd`/mongodb-linux-x86_64-ubuntu2004-7.0.11/bin:$PATH
9-
104
pip install torch
115
export CODE_INTERPRETER_WORK_DIR=${GITHUB_WORKSPACE}
126
echo "${CODE_INTERPRETER_WORK_DIR}"
Lines changed: 11 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
12
name: Bug report
23
title: "[<Agent component: framework|tool|llm|etc...>] "
34
description: Problems and issues with code of MS-Agent
45
labels: [bug]
56
assignees:
6-
- zzhangpurdue
7+
- wangxingjun778
8+
- tastelikefeet
79
- suluyana
810
body:
911
- type: markdown
@@ -19,28 +21,22 @@ body:
1921
label: Initial Checks
2022
description: |
2123
Just a few checks to make sure you need to create a bug report.
22-
23-
_Sorry to sound so draconian 👿; but every second spent replying to issues is time not spent improving MS-Agent 🙇._
2424
options:
25-
- label: I have searched GitHub for a duplicate issue and I'm sure this is something new
25+
- label: I have searched related issues and docs but cannot get the expected help.
2626
required: false
27-
- label: I have read and followed [the docs & demos](https://github.com/modelscope/ms-agent/tree/master/demo) and still think this is a bug
28-
required: false
29-
- label: >
30-
I am confident that the issue is with ms-agent
31-
(not my code, or another library in the ecosystem)
27+
- label: The bug has not been fixed in the latest version.
3228
required: false
3329

3430
- type: textarea
3531
attributes:
36-
label: What happened + What you expected to happen
37-
description: Describe 1. the bug 2. expected behavior 3. useful information (e.g., logs)
32+
label: A clear and concise description of what the bug is.
33+
description: ''
3834
placeholder: >
39-
Please provide the context in which the problem occurred and explain what happened. Further,
40-
please also explain why you think the behaviour is erroneous. It is extremely helpful if you can
41-
copy and paste the fragment of logs showing the exact error messages or wrong behaviour here.
35+
To help us understand the issue better, please provide the following:
4236
43-
**NOTE**: please copy and paste texts instead of taking screenshots of them for easy future search.
37+
- What command or script did you run?
38+
- What happened? What did you expect to happen?
39+
- If there are any error messages, please copy and paste the exact log output (no screenshots).
4440
validations:
4541
required: true
4642

@@ -52,32 +48,3 @@ body:
5248
Please specify the versions of dependencies.
5349
validations:
5450
required: true
55-
56-
- type: textarea
57-
attributes:
58-
label: Reproduction script
59-
description: >
60-
Please provide a reproducible script. Providing a narrow reproduction (minimal / no external dependencies) will
61-
help us triage and address issues in the timely manner!
62-
placeholder: >
63-
Please provide a short code snippet (less than 50 lines if possible) that can be copy-pasted to
64-
reproduce the issue. The snippet should have **no external library dependencies**
65-
(i.e., use fake or mock data / environments).
66-
67-
**NOTE**: If the code snippet cannot be run by itself, the issue will be marked as "needs-repro-script"
68-
until the repro instruction is updated.
69-
validations:
70-
required: true
71-
72-
- type: dropdown
73-
attributes:
74-
label: Issue Severity
75-
description: |
76-
How does this issue affect your experience as a MS-Agent user?
77-
multiple: false
78-
options:
79-
- "Low: It annoys or frustrates me."
80-
- "Medium: It is a significant difficulty but I can work around it."
81-
- "High: It blocks me from completing my task."
82-
validations:
83-
required: false

.github/ISSUE_TEMPLATE/feature-requests.yaml

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ description: Suggest an idea for MS-Agent project
33
title: "[<Agent component: framework|tool|llm|etc...>] "
44
labels: [enhancement]
55
assignees:
6-
- zzhangpurdue
6+
- wangxingjun778
7+
- tastelikefeet
78
- suluyana
89

910
body:
@@ -13,20 +14,6 @@ body:
1314
Thank you for finding the time to propose a new feature!
1415
We really appreciate the community efforts to improve MS-Agent.
1516
16-
- type: checkboxes
17-
id: searched
18-
attributes:
19-
label: Initial Checks
20-
description: |
21-
Just a few checks to make sure you need to create a feature request.
22-
23-
_Sorry to sound so draconian 👿; but every second spent replying to issues is time not spent improving MS-Agent 🙇._
24-
options:
25-
- label: I have searched Google & GitHub for similar requests and couldn't find anything
26-
required: true
27-
- label: I have read and followed [the docs & demos](https://github.com/modelscope/ms-agent/tree/main/demo) and still think this feature is missing
28-
required: true
29-
3017
- type: textarea
3118
attributes:
3219
label: Description
@@ -36,8 +23,6 @@ body:
3623
attributes:
3724
label: Use case
3825
description: >
39-
Describe the use case of your feature request. It will help us understand and
40-
prioritize the feature request.
26+
Describe what you're trying to achieve with this feature request. This helps us understand and prioritize it.
4127
placeholder: >
42-
Rather than telling us how you might implement this feature, try to take a
43-
step back and describe what you are trying to achieve.
28+
Tell us what you're trying to do or solve.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<!-- Thank you for your contribution! -->
2-
<!-- Unless your change is trivial, please create an issue to discuss the change before creating a PR -->
32

43
## Change Summary
54

@@ -14,6 +13,4 @@
1413
* [ ] The pull request title is a good summary of the changes - it will be used in the changelog
1514
* [ ] Unit tests for the changes exist
1615
* [ ] Run `pre-commit install` and `pre-commit run --all-files` before git commit, and passed lint check.
17-
* [ ] Some cases need DASHSCOPE_TOKEN_API to pass the Unit Tests, I have at least **pass the Unit tests on local**
1816
* [ ] Documentation reflects the changes where applicable
19-
* [ ] My PR is ready to review, **please add a comment including the phrase "please review" to assign reviewers**

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ celerybeat-schedule
9494
*.sage.py
9595

9696
# Environments
97-
.env
97+
projects/deep_research/.env
9898
.venv
99+
.env
99100
env/
100101
venv/
101102
ENV/

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,10 @@ For more details, refer to [Doc Research](projects/doc_research/README.md),
243243
244244
<br>
245245
246+
### Interesting works
247+
248+
1. A news collection agent [ms-agent/newspaper](https://www.modelscope.cn/models/ms-agent/newspaper/summary)
249+
246250
## License
247251
248252
This project is licensed under the [Apache License (Version 2.0)](https://github.com/modelscope/modelscope/blob/master/LICENSE).

ms_agent/agent/llm_agent.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from ms_agent.callbacks import Callback, callbacks_mapping
1111
from ms_agent.llm.llm import LLM
1212
from ms_agent.llm.utils import Message, Tool
13-
from ms_agent.rag.base import Rag
13+
from ms_agent.rag.base import RAG
1414
from ms_agent.rag.utils import rag_mapping
1515
from ms_agent.tools import ToolManager
1616
from ms_agent.utils import async_retry
@@ -62,7 +62,7 @@ def __init__(self,
6262
self.tool_manager: Optional[ToolManager] = None
6363
self.memory_tools: List[Memory] = []
6464
self.planer: Optional[Planer] = None
65-
self.rag: Optional[Rag] = None
65+
self.rag: Optional[RAG] = None
6666
self.llm: Optional[LLM] = None
6767
self.runtime: Optional[Runtime] = None
6868
self.max_chat_round: int = 0
@@ -220,7 +220,7 @@ async def _prepare_messages(
220220
Message(role='user', content=inputs or query),
221221
]
222222
if self.rag is not None:
223-
messages = await self.rag.run(messages)
223+
messages = await self.rag.query(messages[1].content)
224224
return messages
225225

226226
async def _prepare_memory(self):
@@ -251,7 +251,7 @@ async def _prepare_rag(self):
251251
assert rag.name in rag_mapping, (
252252
f'{rag.name} not in rag_mapping, '
253253
f'which supports: {list(rag_mapping.keys())}')
254-
self.rag: Rag = rag_mapping(rag.name)(self.config)
254+
self.rag: RAG = rag_mapping(rag.name)(self.config)
255255

256256
async def _refine_memory(self, messages: List[Message]) -> List[Message]:
257257
"""
@@ -509,6 +509,7 @@ async def _run(self, messages: Union[List[Message], str],
509509

510510
await self._loop_callback('on_task_end', messages)
511511
await self._cleanup_tools()
512+
yield messages
512513
except Exception as e:
513514
if hasattr(self.config, 'help'):
514515
logger.error(

ms_agent/cli/app.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Copyright (c) Alibaba, Inc. and its affiliates.
22
import argparse
33

4-
from ms_agent.app.doc_research import launch_server as launch_doc_research
5-
64
from modelscope.cli.base import CLICommand
75

86

@@ -53,6 +51,7 @@ def define_args(parsers: argparse.ArgumentParser):
5351
def execute(self):
5452

5553
if self.args.doc_research:
54+
from ms_agent.app.doc_research import launch_server as launch_doc_research
5655
launch_doc_research(
5756
server_name=self.args.server_name,
5857
server_port=self.args.server_port,

ms_agent/llm/openai_llm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __init__(
5050
base_url=base_url,
5151
)
5252
self.args: Dict = OmegaConf.to_container(
53-
getattr(config, 'generation_config', {}))
53+
getattr(config, 'generation_config', DictConfig({})))
5454

5555
def format_tools(self,
5656
tools: Optional[List[Tool]] = None

ms_agent/rag/base.py

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,52 @@
11
# Copyright (c) Alibaba, Inc. and its affiliates.
2-
from abc import abstractmethod
2+
from abc import ABC, abstractmethod
33
from typing import Any, List
44

5-
from ms_agent.llm import Message
65

7-
8-
class Rag:
6+
class RAG(ABC):
97
"""The base class for rags"""
108

119
def __init__(self, config):
1210
self.config = config
1311

1412
@abstractmethod
15-
async def add_document(self, url: str, content: str, **metadata) -> bool:
13+
async def add_documents(self, documents: List[str]) -> bool:
1614
"""Add document to Rag
1715
1816
Args:
19-
url(`str`): The url of the document
20-
content(`str`): The content of the document
21-
**metadata: Metadata information
17+
documents(`List[str]`): The content of the document
2218
2319
Returns:
2420
success or not
2521
"""
2622
pass
2723

2824
@abstractmethod
29-
async def search_documents(self,
30-
query: str,
31-
limit: int = 5,
32-
score_threshold: float = 0.7,
33-
**filters) -> List[Any]:
34-
"""Search documents in Rag
25+
async def query(self, query: str) -> str:
26+
"""Search documents
3527
3628
Args:
3729
query(`str`): The query to search for
38-
limit(`int`): The number of documents to return
39-
score_threshold(`float`): The score threshold
40-
**filters: Any extra filters
41-
4230
Returns:
43-
List of documents
31+
The query result
4432
"""
4533
pass
4634

4735
@abstractmethod
48-
async def delete_document(self, url: str) -> bool:
49-
"""Delete document from Rag
36+
async def retrieve(self,
37+
query: str,
38+
limit: int = 5,
39+
score_threshold: float = 0.7,
40+
**filters) -> List[Any]:
41+
"""Retrieve documents
5042
5143
Args:
52-
url(`str`): The url of the document
44+
query(`str`): The query to search for
45+
limit(`int`): The number of documents to return
46+
score_threshold(`float`): The score threshold
47+
**filters: Any extra filters
5348
5449
Returns:
55-
bool: True if the document was successfully deleted
50+
List of documents
5651
"""
5752
pass
58-
59-
@abstractmethod
60-
async def run(self, inputs: List[Message]) -> List[Message]:
61-
pass

0 commit comments

Comments
 (0)