ms-agent 0.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. ms_agent-0.0.0/LICENSE +203 -0
  2. ms_agent-0.0.0/MANIFEST.in +3 -0
  3. ms_agent-0.0.0/PKG-INFO +299 -0
  4. ms_agent-0.0.0/README.md +264 -0
  5. ms_agent-0.0.0/ms_agent/__init__.py +1 -0
  6. ms_agent-0.0.0/ms_agent/agent/__init__.py +6 -0
  7. ms_agent-0.0.0/ms_agent/agent/base.py +98 -0
  8. ms_agent-0.0.0/ms_agent/agent/code/__init__.py +2 -0
  9. ms_agent-0.0.0/ms_agent/agent/code/base.py +27 -0
  10. ms_agent-0.0.0/ms_agent/agent/code_agent.py +64 -0
  11. ms_agent-0.0.0/ms_agent/agent/llm_agent.py +347 -0
  12. ms_agent-0.0.0/ms_agent/agent/memory/__init__.py +3 -0
  13. ms_agent-0.0.0/ms_agent/agent/memory/base.py +21 -0
  14. ms_agent-0.0.0/ms_agent/agent/memory/mem0.py +2 -0
  15. ms_agent-0.0.0/ms_agent/agent/memory/utils.py +2 -0
  16. ms_agent-0.0.0/ms_agent/agent/plan/__init__.py +2 -0
  17. ms_agent-0.0.0/ms_agent/agent/plan/base.py +36 -0
  18. ms_agent-0.0.0/ms_agent/agent/plan/utils.py +3 -0
  19. ms_agent-0.0.0/ms_agent/agent/runtime.py +29 -0
  20. ms_agent-0.0.0/ms_agent/callbacks/__init__.py +3 -0
  21. ms_agent-0.0.0/ms_agent/callbacks/base.py +98 -0
  22. ms_agent-0.0.0/ms_agent/callbacks/utils.py +2 -0
  23. ms_agent-0.0.0/ms_agent/cli/__init__.py +1 -0
  24. ms_agent-0.0.0/ms_agent/cli/input_callback.py +33 -0
  25. ms_agent-0.0.0/ms_agent/cli/main.py +28 -0
  26. ms_agent-0.0.0/ms_agent/cli/run.py +70 -0
  27. ms_agent-0.0.0/ms_agent/config/__init__.py +3 -0
  28. ms_agent-0.0.0/ms_agent/config/config.py +171 -0
  29. ms_agent-0.0.0/ms_agent/config/env.py +17 -0
  30. ms_agent-0.0.0/ms_agent/llm/__init__.py +3 -0
  31. ms_agent-0.0.0/ms_agent/llm/claude.py +2 -0
  32. ms_agent-0.0.0/ms_agent/llm/dashscope_llm.py +37 -0
  33. ms_agent-0.0.0/ms_agent/llm/deepseek_llm.py +98 -0
  34. ms_agent-0.0.0/ms_agent/llm/llm.py +70 -0
  35. ms_agent-0.0.0/ms_agent/llm/model_mapping.py +8 -0
  36. ms_agent-0.0.0/ms_agent/llm/modelscope_llm.py +12 -0
  37. ms_agent-0.0.0/ms_agent/llm/openai_llm.py +369 -0
  38. ms_agent-0.0.0/ms_agent/llm/utils.py +49 -0
  39. ms_agent-0.0.0/ms_agent/rag/__init__.py +1 -0
  40. ms_agent-0.0.0/ms_agent/rag/base.py +61 -0
  41. ms_agent-0.0.0/ms_agent/rag/utils.py +2 -0
  42. ms_agent-0.0.0/ms_agent/tools/__init__.py +5 -0
  43. ms_agent-0.0.0/ms_agent/tools/base.py +58 -0
  44. ms_agent-0.0.0/ms_agent/tools/filesystem_tool.py +202 -0
  45. ms_agent-0.0.0/ms_agent/tools/mcp_client.py +166 -0
  46. ms_agent-0.0.0/ms_agent/tools/split_task.py +85 -0
  47. ms_agent-0.0.0/ms_agent/tools/tool_manager.py +79 -0
  48. ms_agent-0.0.0/ms_agent/utils/__init__.py +4 -0
  49. ms_agent-0.0.0/ms_agent/utils/llm_utils.py +84 -0
  50. ms_agent-0.0.0/ms_agent/utils/logger.py +119 -0
  51. ms_agent-0.0.0/ms_agent/utils/utils.py +71 -0
  52. ms_agent-0.0.0/ms_agent/version.py +1 -0
  53. ms_agent-0.0.0/ms_agent/workflow/__init__.py +1 -0
  54. ms_agent-0.0.0/ms_agent/workflow/base.py +36 -0
  55. ms_agent-0.0.0/ms_agent/workflow/chain_workflow.py +101 -0
  56. ms_agent-0.0.0/ms_agent.egg-info/PKG-INFO +299 -0
  57. ms_agent-0.0.0/ms_agent.egg-info/SOURCES.txt +69 -0
  58. ms_agent-0.0.0/ms_agent.egg-info/dependency_links.txt +1 -0
  59. ms_agent-0.0.0/ms_agent.egg-info/entry_points.txt +2 -0
  60. ms_agent-0.0.0/ms_agent.egg-info/not-zip-safe +1 -0
  61. ms_agent-0.0.0/ms_agent.egg-info/requires.txt +3 -0
  62. ms_agent-0.0.0/ms_agent.egg-info/top_level.txt +2 -0
  63. ms_agent-0.0.0/setup.cfg +36 -0
  64. ms_agent-0.0.0/setup.py +158 -0
  65. ms_agent-0.0.0/temp/__init__.py +0 -0
  66. ms_agent-0.0.0/temp/mcp_tests/__init__.py +0 -0
  67. ms_agent-0.0.0/temp/mcp_tests/mcp_playground_origin/__init__.py +0 -0
  68. ms_agent-0.0.0/temp/mcp_tests/mcp_playground_origin/test_app.py +531 -0
  69. ms_agent-0.0.0/temp/mcp_tests/mcp_playground_origin/test_mcp_client.py +238 -0
  70. ms_agent-0.0.0/temp/mcp_tests/run_mcp_client.py +109 -0
ms_agent-0.0.0/LICENSE ADDED
@@ -0,0 +1,203 @@
1
+ Copyright 2022-2023 Alibaba ModelScope. All rights reserved.
2
+
3
+ Apache License
4
+ Version 2.0, January 2004
5
+ http://www.apache.org/licenses/
6
+
7
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
+
9
+ 1. Definitions.
10
+
11
+ "License" shall mean the terms and conditions for use, reproduction,
12
+ and distribution as defined by Sections 1 through 9 of this document.
13
+
14
+ "Licensor" shall mean the copyright owner or entity authorized by
15
+ the copyright owner that is granting the License.
16
+
17
+ "Legal Entity" shall mean the union of the acting entity and all
18
+ other entities that control, are controlled by, or are under common
19
+ control with that entity. For the purposes of this definition,
20
+ "control" means (i) the power, direct or indirect, to cause the
21
+ direction or management of such entity, whether by contract or
22
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
23
+ outstanding shares, or (iii) beneficial ownership of such entity.
24
+
25
+ "You" (or "Your") shall mean an individual or Legal Entity
26
+ exercising permissions granted by this License.
27
+
28
+ "Source" form shall mean the preferred form for making modifications,
29
+ including but not limited to software source code, documentation
30
+ source, and configuration files.
31
+
32
+ "Object" form shall mean any form resulting from mechanical
33
+ transformation or translation of a Source form, including but
34
+ not limited to compiled object code, generated documentation,
35
+ and conversions to other media types.
36
+
37
+ "Work" shall mean the work of authorship, whether in Source or
38
+ Object form, made available under the License, as indicated by a
39
+ copyright notice that is included in or attached to the work
40
+ (an example is provided in the Appendix below).
41
+
42
+ "Derivative Works" shall mean any work, whether in Source or Object
43
+ form, that is based on (or derived from) the Work and for which the
44
+ editorial revisions, annotations, elaborations, or other modifications
45
+ represent, as a whole, an original work of authorship. For the purposes
46
+ of this License, Derivative Works shall not include works that remain
47
+ separable from, or merely link (or bind by name) to the interfaces of,
48
+ the Work and Derivative Works thereof.
49
+
50
+ "Contribution" shall mean any work of authorship, including
51
+ the original version of the Work and any modifications or additions
52
+ to that Work or Derivative Works thereof, that is intentionally
53
+ submitted to Licensor for inclusion in the Work by the copyright owner
54
+ or by an individual or Legal Entity authorized to submit on behalf of
55
+ the copyright owner. For the purposes of this definition, "submitted"
56
+ means any form of electronic, verbal, or written communication sent
57
+ to the Licensor or its representatives, including but not limited to
58
+ communication on electronic mailing lists, source code control systems,
59
+ and issue tracking systems that are managed by, or on behalf of, the
60
+ Licensor for the purpose of discussing and improving the Work, but
61
+ excluding communication that is conspicuously marked or otherwise
62
+ designated in writing by the copyright owner as "Not a Contribution."
63
+
64
+ "Contributor" shall mean Licensor and any individual or Legal Entity
65
+ on behalf of whom a Contribution has been received by Licensor and
66
+ subsequently incorporated within the Work.
67
+
68
+ 2. Grant of Copyright License. Subject to the terms and conditions of
69
+ this License, each Contributor hereby grants to You a perpetual,
70
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
71
+ copyright license to reproduce, prepare Derivative Works of,
72
+ publicly display, publicly perform, sublicense, and distribute the
73
+ Work and such Derivative Works in Source or Object form.
74
+
75
+ 3. Grant of Patent License. Subject to the terms and conditions of
76
+ this License, each Contributor hereby grants to You a perpetual,
77
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
78
+ (except as stated in this section) patent license to make, have made,
79
+ use, offer to sell, sell, import, and otherwise transfer the Work,
80
+ where such license applies only to those patent claims licensable
81
+ by such Contributor that are necessarily infringed by their
82
+ Contribution(s) alone or by combination of their Contribution(s)
83
+ with the Work to which such Contribution(s) was submitted. If You
84
+ institute patent litigation against any entity (including a
85
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
86
+ or a Contribution incorporated within the Work constitutes direct
87
+ or contributory patent infringement, then any patent licenses
88
+ granted to You under this License for that Work shall terminate
89
+ as of the date such litigation is filed.
90
+
91
+ 4. Redistribution. You may reproduce and distribute copies of the
92
+ Work or Derivative Works thereof in any medium, with or without
93
+ modifications, and in Source or Object form, provided that You
94
+ meet the following conditions:
95
+
96
+ (a) You must give any other recipients of the Work or
97
+ Derivative Works a copy of this License; and
98
+
99
+ (b) You must cause any modified files to carry prominent notices
100
+ stating that You changed the files; and
101
+
102
+ (c) You must retain, in the Source form of any Derivative Works
103
+ that You distribute, all copyright, patent, trademark, and
104
+ attribution notices from the Source form of the Work,
105
+ excluding those notices that do not pertain to any part of
106
+ the Derivative Works; and
107
+
108
+ (d) If the Work includes a "NOTICE" text file as part of its
109
+ distribution, then any Derivative Works that You distribute must
110
+ include a readable copy of the attribution notices contained
111
+ within such NOTICE file, excluding those notices that do not
112
+ pertain to any part of the Derivative Works, in at least one
113
+ of the following places: within a NOTICE text file distributed
114
+ as part of the Derivative Works; within the Source form or
115
+ documentation, if provided along with the Derivative Works; or,
116
+ within a display generated by the Derivative Works, if and
117
+ wherever such third-party notices normally appear. The contents
118
+ of the NOTICE file are for informational purposes only and
119
+ do not modify the License. You may add Your own attribution
120
+ notices within Derivative Works that You distribute, alongside
121
+ or as an addendum to the NOTICE text from the Work, provided
122
+ that such additional attribution notices cannot be construed
123
+ as modifying the License.
124
+
125
+ You may add Your own copyright statement to Your modifications and
126
+ may provide additional or different license terms and conditions
127
+ for use, reproduction, or distribution of Your modifications, or
128
+ for any such Derivative Works as a whole, provided Your use,
129
+ reproduction, and distribution of the Work otherwise complies with
130
+ the conditions stated in this License.
131
+
132
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
133
+ any Contribution intentionally submitted for inclusion in the Work
134
+ by You to the Licensor shall be under the terms and conditions of
135
+ this License, without any additional terms or conditions.
136
+ Notwithstanding the above, nothing herein shall supersede or modify
137
+ the terms of any separate license agreement you may have executed
138
+ with Licensor regarding such Contributions.
139
+
140
+ 6. Trademarks. This License does not grant permission to use the trade
141
+ names, trademarks, service marks, or product names of the Licensor,
142
+ except as required for reasonable and customary use in describing the
143
+ origin of the Work and reproducing the content of the NOTICE file.
144
+
145
+ 7. Disclaimer of Warranty. Unless required by applicable law or
146
+ agreed to in writing, Licensor provides the Work (and each
147
+ Contributor provides its Contributions) on an "AS IS" BASIS,
148
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
149
+ implied, including, without limitation, any warranties or conditions
150
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
151
+ PARTICULAR PURPOSE. You are solely responsible for determining the
152
+ appropriateness of using or redistributing the Work and assume any
153
+ risks associated with Your exercise of permissions under this License.
154
+
155
+ 8. Limitation of Liability. In no event and under no legal theory,
156
+ whether in tort (including negligence), contract, or otherwise,
157
+ unless required by applicable law (such as deliberate and grossly
158
+ negligent acts) or agreed to in writing, shall any Contributor be
159
+ liable to You for damages, including any direct, indirect, special,
160
+ incidental, or consequential damages of any character arising as a
161
+ result of this License or out of the use or inability to use the
162
+ Work (including but not limited to damages for loss of goodwill,
163
+ work stoppage, computer failure or malfunction, or any and all
164
+ other commercial damages or losses), even if such Contributor
165
+ has been advised of the possibility of such damages.
166
+
167
+ 9. Accepting Warranty or Additional Liability. While redistributing
168
+ the Work or Derivative Works thereof, You may choose to offer,
169
+ and charge a fee for, acceptance of support, warranty, indemnity,
170
+ or other liability obligations and/or rights consistent with this
171
+ License. However, in accepting such obligations, You may act only
172
+ on Your own behalf and on Your sole responsibility, not on behalf
173
+ of any other Contributor, and only if You agree to indemnify,
174
+ defend, and hold each Contributor harmless for any liability
175
+ incurred by, or claims asserted against, such Contributor by reason
176
+ of your accepting any such warranty or additional liability.
177
+
178
+ END OF TERMS AND CONDITIONS
179
+
180
+ APPENDIX: How to apply the Apache License to your work.
181
+
182
+ To apply the Apache License to your work, attach the following
183
+ boilerplate notice, with the fields enclosed by brackets "[]"
184
+ replaced with your own identifying information. (Don't include
185
+ the brackets!) The text should be enclosed in the appropriate
186
+ comment syntax for the file format. We also recommend that a
187
+ file or class name and description of purpose be included on the
188
+ same "printed page" as the copyright notice for easier
189
+ identification within third-party archives.
190
+
191
+ Copyright 2020-2022 Alibaba ModelScope.
192
+
193
+ Licensed under the Apache License, Version 2.0 (the "License");
194
+ you may not use this file except in compliance with the License.
195
+ You may obtain a copy of the License at
196
+
197
+ http://www.apache.org/licenses/LICENSE-2.0
198
+
199
+ Unless required by applicable law or agreed to in writing, software
200
+ distributed under the License is distributed on an "AS IS" BASIS,
201
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
202
+ See the License for the specific language governing permissions and
203
+ limitations under the License.
@@ -0,0 +1,3 @@
1
+ recursive-include modelscope_agent/tools/code_interpreter *.ttf
2
+ recursive-include modelscope_agent/utils *.tiktoken
3
+ recursive-include modelscope_agent/utils/nltk *.zip
@@ -0,0 +1,299 @@
1
+ Metadata-Version: 2.4
2
+ Name: ms-agent
3
+ Version: 0.0.0
4
+ Summary: ms-agent: Empowering agents with autonomous exploration
5
+ Home-page: https://github.com/modelscope/ms-agent
6
+ Author: The ModelScope teams
7
+ Author-email: contact@modelscope.cn
8
+ License: Apache License 2.0
9
+ Keywords: python,agent,LLM
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: License :: OSI Approved :: Apache Software License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: dotenv
22
+ Requires-Dist: modelscope
23
+ Requires-Dist: omegaconf
24
+ Dynamic: author
25
+ Dynamic: author-email
26
+ Dynamic: classifier
27
+ Dynamic: description
28
+ Dynamic: description-content-type
29
+ Dynamic: home-page
30
+ Dynamic: keywords
31
+ Dynamic: license
32
+ Dynamic: license-file
33
+ Dynamic: requires-dist
34
+ Dynamic: summary
35
+
36
+ <h1> ModelScope-Agent: Building Your Customizable Agent System with Open-source Large Language Models</h1>
37
+
38
+ <p align="center">
39
+ <br>
40
+ <img src="https://modelscope.oss-cn-beijing.aliyuncs.com/modelscope.gif" width="400"/>
41
+ <br>
42
+ <p>
43
+
44
+ <p align="center">
45
+ <a href="https://modelscope.cn/home">Modelscope Hub</a> | <a href="https://arxiv.org/abs/2309.00986">Paper</a> | <a href="https://modelscope.cn/studios/damo/ModelScopeGPT/summary">Demo</a>
46
+ <br>
47
+ <a href="README_CN.md">中文</a>&nbsp | &nbspEnglish
48
+ </p>
49
+
50
+ <p align="center">
51
+ <img src="https://img.shields.io/badge/python-%E2%89%A53.8-5be.svg">
52
+ <a href='https://modelscope-agent.readthedocs.io/en/latest/?badge=latest'>
53
+ <img src='https://readthedocs.org/projects/modelscope-agent/badge/?version=latest' alt='Documentation Status' />
54
+ </a>
55
+ <a href="https://github.com/modelscope/modelscope"><img src="https://img.shields.io/badge/modelscope[framework]-%E2%89%A51.16.0-5D91D4.svg"></a>
56
+ <a href="https://github.com/modelscope/modelscope-agent/actions?query=branch%3Amaster+workflow%3Acitest++"><img src="https://img.shields.io/github/actions/workflow/status/modelscope/modelscope-agent/citest.yaml?branch=master&logo=github&label=CI"></a>
57
+ <a href="https://github.com/modelscope/modelscope-agent/blob/main/LICENSE"><img src="https://img.shields.io/github/license/modelscope/modelscope-agent"></a>
58
+ <a href="https://github.com/modelscope/modelscope-agent/pulls"><img src="https://img.shields.io/badge/PR-welcome-55EB99.svg"></a>
59
+ <a href="https://pypi.org/project/modelscope-agent/"><img src="https://badge.fury.io/py/modelscope-agent.svg"></a>
60
+ <a href="https://pepy.tech/project/modelscope-agent"><img src="https://pepy.tech/badge/modelscope-agent"></a>
61
+ </p>
62
+
63
+ <p align="center">
64
+ <a href="https://trendshift.io/repositories/323" target="_blank"><img src="https://trendshift.io/api/badge/repositories/323" alt="modelscope%2Fmodelscope-agent | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
65
+ </p>
66
+
67
+ ## Introduction
68
+
69
+ Modelscope-Agent is a customizable and scalable Agent framework. A single agent has abilities such as role-playing, LLM calling, tool usage, planning, and memory.
70
+ It mainly has the following characteristics:
71
+
72
+ - **Simple Agent Implementation Process**: Simply specify the role instruction, LLM name, and tool name list to implement an Agent application. The framework automatically arranges workflows for tool usage, planning, and memory.
73
+ - **Rich models and tools**: The framework is equipped with rich LLM interfaces, such as Dashscope and Modelscope model interfaces, OpenAI model interfaces, etc. Built in rich tools, such as **code interpreter**, **weather query**, **text to image**, **web browsing**, etc., make it easy to customize exclusive agents.
74
+ - **Unified interface and high scalability**: The framework has clear tools and LLM registration mechanism, making it convenient for users to expand more diverse Agent applications.
75
+ - **Low coupling**: Developers can easily use built-in tools, LLM, memory, and other components without the need to bind higher-level agents.
76
+
77
+
78
+ ## 🎉 News
79
+ * 🔥🔥🔥Aug 8, 2024: A new graph based code generation tool [CodexGraph](https://arxiv.org/abs/2408.03910) is released by Modelscope-Agent, it has been proved effective and versatile on various code related tasks, please check [example](https://github.com/modelscope/modelscope-agent/tree/master/apps/codexgraph_agent).
80
+ * 🔥🔥Aug 1, 2024: A high efficient and reliable Data Science Assistant is running on Modelscope-Agent, please find detail in [example](https://github.com/modelscope/modelscope-agent/tree/master/apps/datascience_assistant).
81
+ * 🔥July 17, 2024: Parallel tool calling on Modelscope-Agent-Server, please find detail in [doc](https://github.com/modelscope/modelscope-agent/blob/master/modelscope_agent_servers/README.md).
82
+ * 🔥June 17, 2024: Upgrading RAG flow based on LLama-index, allow user to hybrid search knowledge by different strategies and modalities, please find detail in [doc](https://github.com/modelscope/modelscope-agent/blob/master/modelscope_agent/rag/README_zh.md).
83
+ * 🔥June 6, 2024: With [Modelscope-Agent-Server](https://github.com/modelscope/modelscope-agent/blob/master/modelscope_agent_servers/README.md), **Qwen2** could be used by OpenAI SDK with tool calling ability, please find detail in [doc](https://github.com/modelscope/modelscope-agent/blob/master/docs/llms/qwen2_tool_calling.md).
84
+ * 🔥June 4, 2024: Modelscope-Agent supported Mobile-Agent-V2[arxiv](https://arxiv.org/abs/2406.01014),based on Android Adb Env, please check in the [application](https://github.com/modelscope/modelscope-agent/tree/master/apps/mobile_agent).
85
+ * 🔥May 17, 2024: Modelscope-Agent supported multi-roles room chat in the [gradio](https://github.com/modelscope/modelscope-agent/tree/master/apps/multi_roles_chat_room).
86
+ * May 14, 2024: Modelscope-Agent supported image input in `RolePlay` agents with latest OpenAI model `GPT-4o`. Developers can experience this feature by specifying the `image_url` parameter.
87
+ * May 10, 2024: Modelscope-Agent launched a user-friendly `Assistant API`, and also provided a `Tools API` that executes utilities in isolated, secure containers, please find the [document](https://github.com/modelscope/modelscope-agent/blob/master/modelscope_agent_servers/)
88
+ * Apr 12, 2024: The [Ray](https://docs.ray.io/en/latest/) version of multi-agent solution is on modelscope-agent, please find the [document](https://github.com/modelscope/modelscope-agent/blob/master/modelscope_agent/multi_agents_utils/README.md)
89
+ * Mar 15, 2024: Modelscope-Agent and the [AgentFabric](https://github.com/modelscope/modelscope-agent/tree/master/apps/agentfabric) (opensource version for GPTs) is running on the production environment of [modelscope studio](https://modelscope.cn/studios/agent).
90
+ * Feb 10, 2024: In Chinese New year, we upgrade the modelscope agent to version v0.3 to facilitate developers to customize various types of agents more conveniently through coding and make it easier to make multi-agent demos. For more details, you can refer to [#267](https://github.com/modelscope/modelscope-agent/pull/267) and [#293](https://github.com/modelscope/modelscope-agent/pull/293) .
91
+ * Nov 26, 2023: [AgentFabric](https://github.com/modelscope/modelscope-agent/tree/master/apps/agentfabric) now supports collaborative use in ModelScope's [Creation Space](https://modelscope.cn/studios/modelscope/AgentFabric/summary), allowing for the sharing of custom applications in the Creation Space. The update also includes the latest [GTE](https://modelscope.cn/models/damo/nlp_gte_sentence-embedding_chinese-base/summary) text embedding integration.
92
+ * Nov 17, 2023: [AgentFabric](https://github.com/modelscope/modelscope-agent/tree/master/apps/agentfabric) released, which is an interactive framework to facilitate creation of agents tailored to various real-world applications.
93
+ * Oct 30, 2023: [Facechain Agent](https://modelscope.cn/studios/CVstudio/facechain_agent_studio/summary) released a local version of the Facechain Agent that can be run locally. For detailed usage instructions, please refer to [Facechain Agent](#facechain-agent).
94
+ * Oct 25, 2023: [Story Agent](https://modelscope.cn/studios/damo/story_agent/summary) released a local version of the Story Agent for generating storybook illustrations. It can be run locally. For detailed usage instructions, please refer to [Story Agent](#story-agent).
95
+ * Sep 20, 2023: [ModelScope GPT](https://modelscope.cn/studios/damo/ModelScopeGPT/summary) offers a local version through gradio that can be run locally. You can navigate to the demo/msgpt/ directory and execute `bash run_msgpt.sh`.
96
+ * Sep 4, 2023: Three demos, [demo_qwen](demo/demo_qwen_agent.ipynb), [demo_retrieval_agent](demo/demo_retrieval_agent.ipynb) and [demo_register_tool](demo/demo_register_new_tool.ipynb), have been added, along with detailed tutorials provided.
97
+ * Sep 2, 2023: The [preprint paper](https://arxiv.org/abs/2309.00986) associated with this project was published.
98
+ * Aug 22, 2023: Support accessing various AI model APIs using ModelScope tokens.
99
+ * Aug 7, 2023: The initial version of the modelscope-agent repository was released.
100
+
101
+
102
+ ## Installation
103
+
104
+ clone repo and install dependency:
105
+ ```shell
106
+ git clone https://github.com/modelscope/modelscope-agent.git
107
+ cd modelscope-agent && pip install -r requirements.txt
108
+ ```
109
+
110
+ ### ModelScope notebook【recommended】
111
+
112
+ The ModelScope Notebook offers a free-tier that allows ModelScope user to run the FaceChain application with minimum setup, refer to [ModelScope Notebook](https://modelscope.cn/my/mynotebook/preset)
113
+
114
+ ```shell
115
+ # Step1: 我的notebook -> PAI-DSW -> GPU环境
116
+
117
+ # Step2: Download the [demo file](https://github.com/modelscope/modelscope-agent/blob/master/demo/demo_qwen_agent.ipynb) and upload it to the GPU.
118
+
119
+ # Step3: Execute the demo notebook in order.
120
+ ```
121
+
122
+
123
+ ## Quickstart
124
+
125
+ The agent incorporates an LLM along with task-specific tools, and uses the LLM to determine which tool or tools to invoke in order to complete the user's tasks.
126
+
127
+ To start, all you need to do is initialize an `RolePlay` object with corresponding tasks
128
+
129
+ - This sample code uses the qwen-max model, drawing tools and weather forecast tools.
130
+ - Using the qwen-max model requires replacing YOUR_DASHSCOPE_API_KEY in the example with your API-KEY for the code to run properly. YOUR_DASHSCOPE_API_KEY can be obtained [here](https://help.aliyun.com/zh/dashscope/developer-reference/activate-dashscope-and-create-an-api-key). The drawing tool also calls DASHSCOPE API (wanx), so no additional configuration is required.
131
+ - When using the weather forecast tool, you need to replace YOUR_AMAP_TOKEN in the example with your AMAP weather API-KEY so that the code can run normally. YOUR_AMAP_TOKEN is available [here](https://lbs.amap.com/api/javascript-api-v2/guide/services/weather).
132
+
133
+
134
+ ```Python
135
+ # 配置环境变量;如果您已经提前将api-key提前配置到您的运行环境中,可以省略这个步骤
136
+ import os
137
+ os.environ['DASHSCOPE_API_KEY']=YOUR_DASHSCOPE_API_KEY
138
+ os.environ['AMAP_TOKEN']=YOUR_AMAP_TOKEN
139
+
140
+ # 选用RolePlay 配置agent
141
+ from modelscope_agent.agents.role_play import RolePlay # NOQA
142
+
143
+ role_template = '你扮演一个天气预报助手,你需要查询相应地区的天气,并调用给你的画图工具绘制一张城市的图。'
144
+
145
+ llm_config = {'model': 'qwen-max', 'model_server': 'dashscope'}
146
+
147
+ # input tool name
148
+ function_list = ['amap_weather', 'image_gen']
149
+
150
+ bot = RolePlay(
151
+ function_list=function_list, llm=llm_config, instruction=role_template)
152
+
153
+ response = bot.run('朝阳区天气怎样?')
154
+
155
+ text = ''
156
+ for chunk in response:
157
+ text += chunk
158
+ ```
159
+
160
+ Result
161
+ - Terminal runs
162
+ ```shell
163
+ # 第一次调用llm的输出
164
+ Action: amap_weather
165
+ Action Input: {"location": "朝阳区"}
166
+
167
+ # 第二次调用llm的输出
168
+ 目前,朝阳区的天气状况为阴天,气温为1度。
169
+
170
+ Action: image_gen
171
+ Action Input: {"text": "朝阳区城市风光", "resolution": "1024*1024"}
172
+
173
+ # 第三次调用llm的输出
174
+ 目前,朝阳区的天气状况为阴天,气温为1度。同时,我已为你生成了一张朝阳区的城市风光图,如下所示:
175
+
176
+ ![](https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/45/20240204/3ab595ad/96d55ca6-6550-4514-9013-afe0f917c7ac-1.jpg?Expires=1707123521&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=RsJRt7zsv2y4kg7D9QtQHuVkXZY%3D)
177
+ ```
178
+
179
+ ## modules
180
+ ### Agent
181
+
182
+ An `Agent` object consists of the following components:
183
+
184
+ - `LLM`: A large language model that is responsible to process your inputs and decide calling tools.
185
+ - `function_list`: A list consists of available tools for agents.
186
+
187
+ Currently, configuration of `Agent` may contain following arguments:
188
+ - `llm`: The llm config of this agent
189
+ - When Dict: set the config of llm as {'model': '', 'api_key': '', 'model_server': ''}
190
+ - When BaseChatModel: llm is sent by another agent
191
+ - `function_list`: A list of tools
192
+ - When str: tool names
193
+ - When Dict: tool cfg
194
+ - `storage_path`: If not specified otherwise, all data will be stored here in KV pairs by memory
195
+ - `instruction`: the system instruction of this agent
196
+ - `name`: the name of agent
197
+ - `description`: the description of agent, which is used for multi_agent
198
+ - `kwargs`: other potential parameters
199
+
200
+ `Agent`, as a base class, cannot be directly initialized and called. Agent subclasses need to inherit it. They must implement function `_run`, which mainly includes three parts: generation of messages/propmt, calling of llm(s), and tool calling based on the results of llm. We provide an implement of these components in `RolePlay` for users, and you can also custom your components according to your requirement.
201
+
202
+ ```python
203
+ from modelscope_agent import Agent
204
+ class YourCustomAgent(Agent):
205
+ def _run(self, user_request, **kwargs):
206
+ # Custom your workflow
207
+ ```
208
+
209
+
210
+ ### LLM
211
+ LLM is core module of agent, which ensures the quality of interaction results.
212
+
213
+ Currently, configuration of `` may contain following arguments:
214
+ - `model`: The specific model name will be passed directly to the model service provider.
215
+ - `model_server`: provider of model services.
216
+
217
+ `BaseChatModel`, as a base class of llm, cannot be directly initialized and called. The subclasses need to inherit it. They must implement function `_chat_stream` and `_chat_no_stream`, which correspond to streaming output and non-streaming output respectively.
218
+ Optionally implement `chat_with_functions` and `chat_with_raw_prompt` for function calling and text completion.
219
+
220
+ Currently we provide the implementation of three model service providers: dashscope (for qwen series models), zhipu (for glm series models) and openai (for all openai api format models). You can directly use the models supported by the above service providers, or you can customize your llm.
221
+
222
+ For more information please refer to `docs/modules/llm.md`
223
+
224
+ ### `Tool`
225
+
226
+ We provide several multi-domain tools that can be configured and used in the agent.
227
+
228
+ You can also customize your tools with set the tool's name, description, and parameters based on a predefined pattern by inheriting the base tool. Depending on your needs, call() can be implemented.
229
+ An example of a custom tool is provided in [demo_register_new_tool](/demo/demo_register_new_tool.ipynb)
230
+
231
+ You can pass the tool name or configuration you want to use to the agent.
232
+ ```python
233
+ # by tool name
234
+ function_list = ['amap_weather', 'image_gen']
235
+ bot = RolePlay(function_list=function_list, ...)
236
+
237
+ # by tool configuration
238
+ from langchain.tools import ShellTool
239
+ function_list = [{'terminal':ShellTool()}]
240
+ bot = RolePlay(function_list=function_list, ...)
241
+
242
+ # by mixture
243
+ function_list = ['amap_weather', {'terminal':ShellTool()}]
244
+ bot = RolePlay(function_list=function_list, ...)
245
+ ```
246
+
247
+ #### Built-in tools
248
+ - `image_gen`: [Wanx Image Generation](https://help.aliyun.com/zh/dashscope/developer-reference/tongyi-wanxiang). [DASHSCOPE_API_KEY](https://help.aliyun.com/zh/dashscope/developer-reference/activate-dashscope-and-create-an-api-key) needs to be configured in the environment variable.
249
+ - `code_interpreter`: [Code Interpreter](https://jupyter-client.readthedocs.io/en/5.2.2/api/client.html)
250
+ - `web_browser`: [Web Browsing](https://python.langchain.com/docs/use_cases/web_scraping)
251
+ - `amap_weather`: [AMAP Weather](https://lbs.amap.com/api/javascript-api-v2/guide/services/weather). AMAP_TOKEN needs to be configured in the environment variable.
252
+ - `wordart_texture_generation`: [Word art texture generation](https://help.aliyun.com/zh/dashscope/developer-reference/wordart). [DASHSCOPE_API_KEY](https://help.aliyun.com/zh/dashscope/developer-reference/activate-dashscope-and-create-an-api-key) needs to be configured in the environment variable.
253
+ - `web_search`: [Web Searching](https://learn.microsoft.com/en-us/bing/search-apis/bing-web-search/overview). []
254
+ - `qwen_vl`: [Qwen-VL image recognition](https://help.aliyun.com/zh/dashscope/developer-reference/tongyi-qianwen-vl-plus-api). [DASHSCOPE_API_KEY](https://help.aliyun.com/zh/dashscope/developer-reference/activate-dashscope-and-create-an-api-key) needs to be configured in the environment variable.
255
+ - `style_repaint`: [Character style redrawn](https://help.aliyun.com/zh/dashscope/developer-reference/tongyi-wanxiang-style-repaint). [DASHSCOPE_API_KEY](https://help.aliyun.com/zh/dashscope/developer-reference/activate-dashscope-and-create-an-api-key) needs to be configured in the environment variable.
256
+ - `image_enhancement`: [Chasing shadow-magnifying glass](https://github.com/dreamoving/Phantom). [DASHSCOPE_API_KEY](https://help.aliyun.com/zh/dashscope/developer-reference/activate-dashscope-and-create-an-api-key) needs to be configured in the environment variable.
257
+ - `text-address`: [Geocoding](https://www.modelscope.cn/models/iic/mgeo_geographic_elements_tagging_chinese_base/summary). [MODELSCOPE_API_TOKEN](https://www.modelscope.cn/my/myaccesstoken) needs to be configured in the environment variable.
258
+ - `speech-generation`: [Speech generation](https://www.modelscope.cn/models/iic/speech_sambert-hifigan_tts_zh-cn_16k/summary). [MODELSCOPE_API_TOKEN](https://www.modelscope.cn/my/myaccesstoken) needs to be configured in the environment variable.
259
+ - `video-generation`: [Video generation](https://www.modelscope.cn/models/iic/text-to-video-synthesis/summary). [MODELSCOPE_API_TOKEN](https://www.modelscope.cn/my/myaccesstoken) needs to be configured in the environment variable.
260
+
261
+ ### Multi-agent
262
+
263
+ Please refer the multi-agent [readme](modelscope_agent/multi_agents_utils/README.md).
264
+
265
+
266
+ ## Related Tutorials
267
+
268
+ If you would like to learn more about the practical details of Agent, you can refer to our articles and video tutorials:
269
+
270
+ * [Article Tutorial](https://mp.weixin.qq.com/s/L3GiV2QHeybhVZSg_g_JRw)
271
+ * [Video Tutorial](https://b23.tv/AGIzmHM)
272
+
273
+ ## Share Your Agent
274
+
275
+ We appreciate your enthusiasm in participating in our open-source ModelScope-Agent project. If you encounter any issues, please feel free to report them to us. If you have built a new Agent demo and are ready to share your work with us, please create a pull request at any time! If you need any further assistance, please contact us via email at [contact@modelscope.cn](mailto:contact@modelscope.cn) or [communication group](https://modelscope.cn/docs/%E8%81%94%E7%B3%BB%E6%88%91%E4%BB%AC)!
276
+
277
+ ### Facechain Agent
278
+ Facechain is an open-source project for generating personalized portraits in various styles using facial images uploaded by users. By integrating the capabilities of Facechain into the modelscope-agent framework, we have greatly simplified the usage process. The generation of personalized portraits can now be done through dialogue with the Facechain Agent.
279
+
280
+ FaceChainAgent Studio Application Link: https://modelscope.cn/studios/CVstudio/facechain_agent_studio/summary
281
+
282
+ You can run it directly in a notebook/Colab/local environment: https://www.modelscope.cn/my/mynotebook
283
+
284
+ ```
285
+ ! git clone -b feat/facechain_agent https://github.com/modelscope/modelscope-agent.git
286
+
287
+ ! cd modelscope-agent && ! pip install -r requirements.txt
288
+ ! cd modelscope-agent/demo/facechain_agent/demo/facechain_agent && ! pip install -r requirements.txt
289
+ ! pip install http://dashscope-cn-beijing.oss-cn-beijing.aliyuncs.com/zhicheng/modelscope_agent-0.1.0-py3-none-any.whl
290
+ ! PYTHONPATH=/mnt/workspace/modelscope-agent/demo/facechain_agent && cd modelscope-agent/demo/facechain_agent/demo/facechain_agent && python app_v1.0.py
291
+ ```
292
+
293
+ ## License
294
+
295
+ This project is licensed under the [Apache License (Version 2.0)](https://github.com/modelscope/modelscope/blob/master/LICENSE).
296
+
297
+ ## Star History
298
+
299
+ [![Star History Chart](https://api.star-history.com/svg?repos=modelscope/modelscope-agent&type=Date)](https://star-history.com/#modelscope/modelscope-agent&Date)