1 Star 1 Fork 0

野草 / XAgent

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

XAgent

Twitter Discord License: Apache 2.0 Welcome

English中文日本語

教程演示博客文档引用

📖 介绍

XAgent是一个开源的基于大型语言模型(LLM)的自主智能体,可以自动解决各种任务。 它被设计为一个通用的智能体,可以应用于各种任务。目前,XAgent仍处于早期阶段,我们正在努力改进它。

🏆 我们的目标是创建一个可以解决任何给定任务的超级智能智能体!

我们欢迎各种形式的合作,包括全职、兼职等。如果您对智能体的前沿感兴趣,并希望加入我们实现真正的自主智能体,请通过 xagentteam@gmail.com 与我们联系。

XAgent概述
XAgent功能概览

XAgent

XAgent具有以下特点:

  • 自主性:XAgent可以在没有人类参与的情况下自动解决各种任务。
  • 安全性:XAgent被设计为安全运行。所有的行为都被限制在一个docker容器内。不用担心你的主机环境受到影响
  • 可扩展性:XAgent被设计为可扩展的。您可以轻松地添加新的工具来增强智能体的能力,甚至是新的智能体!
  • GUI:XAgent为用户提供了友好的GUI来与智能体交互。您也可以使用命令行界面与智能体交互。
  • 与人类的合作:XAgent可以与您合作解决任务。它不仅有能力在行进中遵循您的指导来解决复杂的任务,而且在遇到挑战时还可以寻求您的帮助。

XAgent由三部分组成:

  • 🤖 调度器 负责动态实例化和分派任务给不同的智能体。它允许我们添加新的智能体和改进智能体的能力。
  • 🧐 规划器 负责为任务生成和校正计划。它将任务分解为子任务,并为它们生成里程碑,使智能体能够逐步解决任务。
  • 🦾 行动者 负责采取行动实现目标和完成子任务。行动者利用各种工具来解决子任务,它也可以与人类合作来解决任务。
XAgent的工作流程
XAgent的工作流程图。

🧰 工具服务器

工具服务器是为XAgent提供强大和安全的工具来解决任务的服务器。它是一个docker容器,为XAgent提供一个安全的运行环境。 目前,工具服务器提供以下工具:

  • 📝 文件编辑器 提供一个文本编辑工具,可以写入、读取和修改文件。
  • 📘 Python笔记本 提供一个交互式的Python笔记本,可以运行Python代码来验证想法、绘制图形等。
  • 🌏 网页浏览器 提供一个网页浏览器,可以搜索和访问网页。
  • 🖥️ Shell 提供一个bash shell工具,可以执行任何shell命令,甚至安装程序和托管服务。
  • 🧩 Rapid API 提供一个从Rapid API检索API并调用它们的工具,为XAgent提供了广泛的API。有关Rapid API集合的更多信息,请参见ToolBench。 您也可以轻松地向工具服务器添加新的工具,以增强XAgent的能力。

✨ 快速开始

🛠️ 构建和设置工具服务器

工具服务器是XAgent的行动发生的地方。它是一个docker容器,为XAgent提供一个安全的运行环境。 因此,您应该首先安装dockerdocker-compose。 然后,您需要构建工具服务器的镜像。在ToolServer目录下,运行以下命令:

docker-compose up --build

这将构建工具服务器的镜像并启动工具服务器的容器。如果您想在后台运行容器,请使用docker-compose up -d --build。 参考ToolServer获取更多信息。

如果需要更新工具服务器或您想重新构建工具服务器的镜像,请使用以下命令:

docker compose build

🎮 配置并运行XAgent

在启动ToolServer后,您可以配置并运行XAgent。

  • 安装依赖项:(需要Python版本 >= 3.10)
pip install -r requirements.txt
  • 配置XAgent 您需要使用config.yml配置XAgent才能运行。 请提供至少一个 OpenAI key,用于访问OpenAI API。 我们建议您配置使用gpt-4-32k来使用XAgent,gpt-4也可以用于大多数简单的任务。 并且,在任何情况下,至少需要提供一个gpt-3.5-turbo-16k API key作为备用模型。 我们不建议您使用gpt-3.5-turbo来运行XAgent,因为它的上下文长度非常有限,您不应该尝试在上面运行XAgent。

  • 运行XAgent

python run.py --task "put your task here" --model "gpt-4"

您可以使用参数--upload_files来指定提交给XAgent的文件。 您的XAgent的本地工作空间在local_workspace中,您可以在运行过程中找到XAgent生成的所有文件。 此外,在running_records中,您可以找到所有的中间步骤信息,例如任务状态、LLM的输入输出对、使用的工具等。 在运行结束后,ToolServerNode中的完整worksapce也将被打包下载到其中。

  • 使用GUI运行XAgent
## 在ToolServer docker 时已经开启web ui docker了
## 只需新开一个命令行,开启docker中的 nginx
docker exec XAgent-Server systemctl start nginx

构建XAgent-Server的docker镜像并启动docker容器。 您将看到XAgent Server在端口8090上监听。 您可以在浏览器中打开http://localhost:5173来访问XAgent的GUI。 参考XAgentServer获取更多信息。

🎬 案例

我们提供了一些使用XAgent解决任务的案例: 你可以在XAgent官网上查看我们的在线演示。我们还提供了视频演示和使用XAgent的案例: Demo

案例1. 数据分析:展示双环机制的有效性

在这个案例中,我们将展示XAgent如何使用双环机制来解决数据分析任务。 我们将使用一个简单的数据集iris.zip上传到XAgent,然后让XAgent分析数据集并生成一个报告。 XAgent将任务分解为4个子任务:(1)数据理解,(2)验证Python环境,(3)编写数据分析代码,(4)编写报告。 这里是XAgent绘制的一张图:

Data Statics by XAgent

案例2. 推荐:展示与人类的合作

XAgent拥有独特的能力,可以积极寻求人类协助并共同解决问题,持续重新定义着人类与智能体人合作的界限。如下方截图所示,用户寻求了XAgent的帮助,以推荐一些适合友好聚会的优秀餐厅,但未提供具体细节。识别到提供的信息不足,XAgent利用了“请求人类帮助”工具,促使人类介入以获取用户的偏好位置、预算限制、烹饪偏好以及任何饮食限制。凭借这宝贵的反馈信息,XAgent轻松地生成了定制的餐厅推荐,确保用户及其朋友们获得了个性化和令人满意的体验。

Illustration of Ask for Human Help of XAgent

案例3. 训练模型:高级工具使用者

XAgent 不仅能处理琐碎任务,还可以在复杂任务中提供宝贵的帮助,比如模型训练。在这里,我们展示了一个用户希望分析电影评论并评估特定电影周围公众情感的情景。作为回应,XAgent 迅速启动了下载 IMDB 数据集的过程,以训练一款先进的 BERT 模型(见下方截图),利用深度学习的强大能力。拥有了这个训练有素的 BERT 模型,XAgent 能够轻松地应对电影评论的复杂细节,提供关于公众对各种电影看法的见解性预测。

bert_1 bert_2 bert_3

📊 评测

我们进行了人类偏好评估,以评估XAgent的性能。我们为评估准备了超过50个现实世界的复杂任务,可以分为5个类别:搜索与报告,编码与开发,数据分析,数学和生活助手。

我们将XAgent的结果与AutoGPT进行比较,结果显示XAgent完全胜过AutoGPT。 我们将很快放出XAgent的运行日志。 HumanPrefer 我们在人类偏好方面报告了XAgent相对于AutoGPT的显著改进。

此外,我们还在以下基准上对XAgent进行了评估: Benchmarks

🖌️ 博客

我们的官方博客在这里

🌟 我们的贡献者

衷心感谢所有贡献者。你们的努力使得这个项目不断成长和进步。无论大小,每一份贡献都是宝贵的。

贡献者

🌟 星标历史

Star History Chart

引用

如果您发现我们的仓库对您有帮助,请引用我们的论文:

@misc{xagent2023,
      title={XAgent: An Autonomous Agent for Complex Task Solving}, 
      author={XAgent Team},
      year={2023},
}
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright 2023 OpenBMB Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

暂无描述 展开 收起
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Python
1
https://gitee.com/wjqnxw/XAgent.git
git@gitee.com:wjqnxw/XAgent.git
wjqnxw
XAgent
XAgent
main

搜索帮助

53164aa7 5694891 3bd8fe86 5694891