XAgent的部署及运行

源代码clone

git clone

config 文件的修改

在XAgent源码目录,运行 vi .env, 修改以下配置条目

CONFIG_FILE=assets/gpt-3.5-turbo_config.yml

python环境

python >=3.10

安装conda,通过conda激活python3.10的环境

wget https://repo.anaconda.com/archive/Anaconda3-2023.03-1-Linux-x86_64.sh

# 修改执行权限
chmod 777 Anaconda3-2023.03-1-Linux-x86_64.sh

# 执行
./Anaconda3-2023.03-1-Linux-x86_64.sh

# 创建python3.10+ 的环境
conda create --name py310 python=3.10

#查看新创建的环境 
conda info --envs
# conda environments:
#
# base                  *  /root/anaconda3
# py310                    /root/anaconda3/envs/py310

# 激活py310环境
activate py310

# 重新进入shell后,查看python的版本
python --version

PIP

安装pip包

# 下载安装脚本
wget https://bootstrap.pypa.io/get-pip.py

# 运行安装脚本
python3 get-pip.py

docker的部署及运行

确保已安装docker,在XAgent源码目录,运行以下命令,从代码builddocker

docker compose build
# 如果不是第一次build,可以加上--no-cache参数,强制不使用缓存,否则build内容可能不会被更新
docker compose build --no-cache

看到以下提示时,运行完毕

=> [ 4/12] RUN apt update && apt install -y build-essential make openjdk-17-jdk-headless curl docker.io docker-compose psmisc sudo                                                                         41.5s
 => [ 5/12] RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple                                                                                                                     1.9s
 => [ 6/12] RUN pip install playwright && playwright install chromium &&  playwright install-deps                                                                                                           83.0s
 => [ 7/12] COPY ToolServer/ToolServerNode/requirements.txt .                                                                                                                                                0.1s
 => [ 8/12] RUN pip install --no-cache-dir -r requirements.txt                                                                                                                                             144.4s
 => [ 9/12] RUN rm -rf /tmp/* /var/tmp/*                                                                                                                                                                     0.4s
 => [10/12] COPY ToolServer/ToolServerNode .                                                                                                                                                                 0.1s 
 => [11/12] RUN mkdir -p assets                                                                                                                                                                              0.2s 
 => [12/12] RUN mkdir -p workspace                                                                                                                                                                           0.2s 
 => exporting to image                                                                                                                                                                                       9.8s 
 => => exporting layers                                                                                                                                                                                      9.8s
 => => writing image sha256:45e525fd5f2f9fbbb7679e96359934cd4b4a0658f6aaa39c0987718c87758b64                                                                                                                 0.0s
 => => naming to docker.io/xagentteam/toolserver-node:latest       

使用 docker images 命令查看,可以看到xagent的几个images已经出现在列表中

REPOSITORY                      TAG       IMAGE ID       CREATED          SIZE
xagentteam/toolserver-node      latest    45e525fd5f2f   18 minutes ago   3.75GB
xagentteam/xagent-server        latest    829edddf670b   19 minutes ago   1.29GB
xagentteam/toolserver-manager   latest    1fab5aa2bb99   22 minutes ago   1.03GB
xagentteam/toolserver-monitor   latest    803d4cd44e84   23 minutes ago   1.02GB

再运行

#  拉取的依赖容器并启动相应的服务
docker compose up

再使用 docker images 命令查看,依赖的images,比如redis,mongo,mysql也出现在列表中。在这里需要注意,系统中的某些端口不能被占用,比如3306,否则就会导致相应的应用启动失败

REPOSITORY                      TAG       IMAGE ID       CREATED          SIZE
xagentteam/toolserver-node      latest    45e525fd5f2f   23 minutes ago   3.75GB
xagentteam/xagent-server        latest    829edddf670b   24 minutes ago   1.29GB
xagentteam/toolserver-manager   latest    1fab5aa2bb99   28 minutes ago   1.03GB
xagentteam/toolserver-monitor   latest    803d4cd44e84   28 minutes ago   1.02GB
redis                           latest    76506809a39f   9 days ago       138MB
mongo                           latest    5acb2131d51f   11 days ago      757MB
mysql                           latest    f7fdab215ab7   7 weeks ago      605MB

同时,一些容器也会在系统中创建成功,可以使用docker ps --no-trunc查看(我的这个列表中mysql容器因为端口原因就启动失败了,需要更改被占用的端口后重启)

[root@opencloudos XAgent-1.0.0]# docker ps --no-trunc
                                NAMES
0c28937576b3036d988d8075c23ca5fa2acd952b0719879e2fd5301d463192bb   xagentteam/toolserver-node:0.2         "uvicorn main:app --host 0.0.0.0 --port 31942"                                                                                                      19 minutes ago   Up 19 minutes (healthy)   31942/tcp                                                                              friendly_darwin
3cf4eb9a46caf8bc774ad731a2dae9f6dffaf67ef6da85b5f8198a117f766dd0   xagentteam/xagent-server:latest        "python start_server.py"                                                                                                                            21 minutes ago   Up 21 minutes             0.0.0.0:5173->5173/tcp, :::5173->5173/tcp, 0.0.0.0:8090->8090/tcp, :::8090->8090/tcp   XAgent-Server
ede01c59c67f61dbbe7e16b984447fcdb9c65df39da264085dc001abb9b31b83   xagentteam/toolserver-node:latest      "uvicorn main:app --host 0.0.0.0 --port 31942"                                                                                                      21 minutes ago   Up 21 minutes             31942/tcp                                                                              xagent-main-ToolServerNode-1
8c5b52f2d082ed74603fa01bf75fbbbdd44301d482843c6e59dbda4f03b25347   xagentteam/toolserver-manager:latest   "gunicorn main:app -b 0.0.0.0:8080 --worker-class uvicorn.workers.UvicornWorker --workers 2 -t 600"                                                 21 minutes ago   Up 21 minutes (healthy)   0.0.0.0:8080->8080/tcp, :::8080->8080/tcp                                              xagent-main-ToolServerManager-1
0c19c715098a7b719eeb427c13f3b0ddc6eacbf059df07bae36553aefc66170e   xagentteam/toolserver-node:0.2         "uvicorn main:app --host 0.0.0.0 --port 31942"                                                                                                      8 hours ago      Up 8 hours (healthy)      31942/tcp                                                                              nice_diffie
41f1b764cbdfce3fe7d2dfad75f90fdaca9e3abd660c8942b040268f4bcb1a34   xagentteam/toolserver-node:0.2         "uvicorn main:app --host 0.0.0.0 --port 31942"                                                                                                      11 hours ago     Up 11 hours (healthy)     31942/tcp                                                                              eager_greider
1a2bfe7c41fad33417ae9528135d3a46c9c24465fc934e5cf9228e8002762de7   mysql                                  "docker-entrypoint.sh --default-authentication-plugin=caching_sha2_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci"   11 hours ago     Up 8 hours (healthy)      0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp                                   xagent-main-xagent-mysql-1
379d82d0c10df5ef2933acffc6529569a390bbd5f79cc4abdd2149ee42ff435a   redis                                  "docker-entrypoint.sh redis-server --requirepass xagent"                                                                                            11 hours ago     Up 8 hours (healthy)      0.0.0.0:6379->6379/tcp, :::6379->6379/tcp                                              xagent-main-xagent-redis-1


如果顺利启动,则可以看到以下提示:

INFO:     Register env WebEnv with 2 tools!
xagent-100-ToolServerNode-1     | INFO:     Register env PythonNotebook with 2 tools!
xagent-100-ToolServerNode-1     | INFO:     Register env FileSystemEnv with 3 tools!
xagent-100-ToolServerNode-1     | INFO:     Register tool shell_command_executor!
xagent-100-ToolServerNode-1     | INFO:     Loaded 8 tools and 3 envs!
xagent-100-ToolServerNode-1     | INFO:     Application startup complete.
xagent-100-ToolServerNode-1     | INFO:     Uvicorn running on http://0.0.0.0:31942 (Press CTRL+C to quit)
xagent-100-xagent-mysql-1       | 2023-12-14T05:49:03.879382Z 8 [Warning] [MY-013360] [Server] Plugin mysql_native_password reported: ''mysql_native_password' is deprecated and will be removed in a future release. Please use caching_sha2_password instead'
XAgent-Server                   | INFO:     Will watch for changes in these directories: ['/app']
XAgent-Server                   | INFO:     Uvicorn running on http://0.0.0.0:8090 (Press CTRL+C to quit)
XAgent-Server                   | INFO:     Started reloader process [1] using StatReload
xagent-100-xagent-mysql-1       | 2023-12-14T05:49:06.192883Z 9 [Warning] [MY-013360] [Server] Plugin mysql_native_password reported: ''mysql_native_password' is deprecated and will be removed in a future release. Please use caching_sha2_password instead'
XAgent-Server                   | INFO:     Started server process [16]
XAgent-Server                   | INFO:     Waiting for application startup.
XAgent-Server                   | INFO:     Application startup complete.

访问XAgent-Server

XAgent-Server启动后,默认的访问地址是 http://localhost:5173, 要确保端口是对外开放的,首次访问该地址,会看到上个步骤的控制台上会打印访问的日志信息:


XAgent-Server                   |   XAgent Service Startup Param:
XAgent-Server                   |             app: app:app
XAgent-Server                   |             prod: False
XAgent-Server                   |             base_dir: XAgentServer
XAgent-Server                   |             use_redis: False
XAgent-Server                   |             recorder_root_dir: running_records
XAgent-Server                   |             default_login: True
XAgent-Server                   |             check_running: False
XAgent-Server                   |             host: 0.0.0.0
XAgent-Server                   |             port: 8090
XAgent-Server                   |             debug: True
XAgent-Server                   |             reload: True
XAgent-Server                   |             workers: 1
XAgent-Server                   |             share_url: https://x-agent.net/api/conv/community
XAgent-Server                   |             DB: <class 'XAgentServer.application.core.envs.XAgentServerEnv.DB'>
XAgent-Server                   |             Redis: <class 'XAgentServer.application.core.envs.XAgentServerEnv.Redis'>
XAgent-Server                   |             Email: <class 'XAgentServer.application.core.envs.XAgentServerEnv.Email'>
XAgent-Server                   |             Upload: <class 'XAgentServer.application.core.envs.XAgentServerEnv.Upload'>
XAgent-Server                   | XAgent Service Init Dependence.  
XAgent-Server                   | init a thread pool executor, max_workers: 1  
XAgent-Server                   | XAgent Service Init Dependence: Complete!  
XAgent-Server                   | Default user: Guest, token: xagent, you can use it to login  
XAgent-Server                   | XAgent Server Dependences:  
XAgent-Server                   |         Python: 3.10+ 
XAgent-Server                   |         FastAPI: Http server
XAgent-Server                   |         Websocket: long connect with client
XAgent-Server                   |         MySQL: save xagent data
XAgent-Server                   |         SqlAlchemy: ORM with MySQL
XAgent-Server                   |         Redis: save status of interaction
XAgent-Server                   |         Threading: run interaction
XAgent-Server                   |         APScheduler: send data to client and keep alive
XAgent-Server                   |         FastAPI APIRouter: manage websocket route
XAgent-Server                   |         XAgentError: XAgentServer.exts.exception_ext
XAgent-Server                   | XAgent Server Version:  
XAgent-Server                   |         V 1.1.0
XAgent-Server                   | Notes:  
XAgent-Server                   |         Since V 1.1.0, 
XAgent-Server                   |         Local storage will no longer be supported, replaced by Mysql.
XAgent-Server                   |         The service depends on Redis and Mysql, 
XAgent-Server                   |         so you need to install Redis and Mysql before using it.
XAgent-Server                   |         Before you use this service, please ensure that the following services are available:
XAgent-Server                   |             1. Redis on docker, port: 6379, you can start it by docker, default password: xagent
XAgent-Server                   |             2. Mysql on docker, port: 3306, you can start it by docker
XAgent-Server                   |             3. XAgent Tool Server is runnning on port 8080
XAgent-Server                   |             4. Port 8090 is not occupied

在这里插入图片描述

部署及启动过程中的一些错误解决

错误列表

ToolServerNode—but the ‘h2’ package is not installed

我是使用的是XAgent-1.0.0版本,启动过程中xagentteam/toolserver-node:latest这个image的容器碰到以下错误:

ImportError: Using http2=True, but the 'h2' package is not installed. Make sure to install httpx using `pip install httpx[http2]`.
xagent-100-ToolServerNode-1     | 
xagent-100-ToolServerNode-1     | ERROR:    Application startup failed. Exiting.

解决方法

# 到\XAgent-1.0.0\dockerfiles\ToolServerNode\目录下
# 修改Dockerfile文件
# 在RUN pip install playwright && playwright install chromium &&  playwright install-deps这段之后添加:
RUN pip install httpx[http2]
# 注意,添加上面这段脚本后,要重新运行docker compose build 和 docker compose up

mysql启动后不停闪现的warning信息

后台服务启动后,如果不停闪现以下错误:

 [Warning] [MY-013360] [Server] Plugin mysql_native_password reported: ''mysql_native_password' is deprecated and will be removed in a future release. Please use caching_sha2_password instead'

解决方法 请修改mysql的healthcheck段配置:

healthcheck:
     # test: [ "CMD", "mysqladmin","ping", "-h", "localhost" ]
     test: ["CMD-SHELL", "mysql -h localhost -u root -pxagent -e 'SELECT 1'"]
     #interval: 10s
     timeout: 20s
     retries: 20

如果以上配置修改不能解决您的问题,尝试将你的Xagent代码切换到master版本,我在1.00版本碰到该问题,切换到master版本后运行,以上问题应该已经被修复

max_workers must be greater than 0 错误

暂无解决方案,如果你是1.00版本,建议使用master版本尝试该问题是否能修复,总而言之,master版本似乎要比1.00版本稳定不少。

   |   File "/app/XAgent/function_handler.py", line 234, in handle_tool_call
XAgent-Server                   |     command_result = self.long_result_summary(
XAgent-Server                   |   File "/app/XAgent/function_handler.py", line 167, in long_result_summary
XAgent-Server                   |     with ThreadPoolExecutor(max_workers=len(result)) as pool:
XAgent-Server                   |   File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 144, in __init__
XAgent-Server                   |     raise ValueError("max_workers must be greater than 0")
XAgent-Server                   | ValueError: max_workers must be greater than 0

AttributeError: ‘ToolServerInterface’ object has no attribute ‘cookies’

伴随以上错误,同时会有以下异常信息:

 XAgentServer.exts.exception_ext.XAgentRunningError: HTTPConnectionPool(host='localhost', port=8080): Max retries exceeded with url: /get_cookie

解决方法 问题是由localhost的8080端口沟通失败引起的,尝试使用IP地址,请注意打开8080端口的访问权限

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/256997.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

josef约瑟 跳合位、电源监视继电器 HRTH-Y-2H2D DC220V

系列型号&#xff1a; HRTH-Y-2H2D-X-T跳位监视、合位监视、电源监控继电器&#xff1b; HRTH-Y-2Z-X-T跳位监视、合位监视、电源监控继电器&#xff1b; HRTH-Y-2H-X-T跳位监视、合位监视、电源监控继电器&#xff1b; HRTH-J-2H2D-X-T跳位监视、合位监视、电源监控继电器…

Axure中继器的基本使用

介绍中继器 在 Axure 中&#xff0c;中继器是一种交互设计元素&#xff0c;用于在不同页面之间传递数据或触发特定的事件。它可以帮助模拟真实的用户交互流程和页面之间的传递逻辑&#xff0c;继承关系用于描述两个元件之间的父子关系。通过使用继承关系&#xff0c;您可以创建…

Linux的SSH(远程登录)

SSH定义&#xff1a; SSH&#xff08;Secure Shell 的缩写&#xff09;是一种网络协议&#xff0c;用于加密两台计算机之间的通信&#xff0c;并且支持各种身份验证机制。 实务中&#xff0c;它主要用于保证远程登录和远程通信的安全&#xff0c;任何网络服务都可以用这个协议…

深度学习笔记_7经典网络模型LSTM解决FashionMNIST分类问题

1、 调用模型库&#xff0c;定义参数&#xff0c;做数据预处理 import numpy as np import torch from torchvision.datasets import FashionMNIST import torchvision.transforms as transforms from torch.utils.data import DataLoader import torch.nn.functional as F im…

自定义 spring-boot组件自动注入starter

1&#xff1a;创建maven项目 2&#xff1a;pom文件 <?xml version"1.0" encoding"UTF-8"?> <project xmlns"http://maven.apache.org/POM/4.0.0" xmlns:xsi"http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocati…

stm32与Freertos入门(二)移植FreeRTOS到STM32中

简介 注意&#xff1a;FreeRTOS并不是实时操作系统&#xff0c;而是分时复用的&#xff0c;只不过切换频率很快&#xff0c;感觉上是同时在工作。本次使用的单片机型号为STM32F103C8T6,通过CubeMX快速移植。 一、CubeMX快速移植 1、选择芯片 打开CubeMX软件&#xff0c;进行…

轻量封装WebGPU渲染系统示例<53>- 多盏灯灯光照在地面的效果

WebGPU实时渲染实现模拟多盏灯的灯光照在地面的效果灯光效果 。 当前示例源码github地址: https://github.com/vilyLei/voxwebgpu/blob/feature/material/src/voxgpu/sample/MultiLightsTest.ts 当前示例运行效果: 此示例基于此渲染系统实现&#xff0c;当前示例TypeScript源…

Ribbon负载均衡原理、策略、饥饿加载

Ribbon负载均衡原理、策略、饥饿加载 MapperScan("cn.itcast.order.mapper") SpringBootApplication public class OrderApplication {public static void main(String[] args) {SpringApplication.run(OrderApplication.class, args);}/*** 完成创建RestTemplate&am…

虾皮 选品:如何在虾皮平台上进行有效的选品?

在虾皮&#xff08;Shopee&#xff09;这个跨境电商平台上&#xff0c;选品对于卖家来说至关重要。选品决定了店铺的销售额和竞争力。为了帮助卖家进行选品&#xff0c;虾皮平台提供了一些免费的选品工具&#xff0c;如知虾。同时&#xff0c;还有一些第三方选品工具&#xff0…

支持可视化提取变量,Apipost配置变量不要太简单

在调试接口时我们需要将响应结果中的某个字段配置为环境变量在其他接口中引用&#xff0c;之前在Apipost中需要配置脚本而在最近Apipost后执行操作中可以进行可视化的断言和变量提取&#xff0c;无需配置繁琐脚本。 这里我们在登录接口下配置一条Token环境变量&#xff0c;在后…

去面试性能测试工程师必问的问题,

性能测试的三个核心原理是什么&#xff1f; 1.基于协议。性能测试的对象是网络分布式架构的软件&#xff0c;而网络分布式架构的核心是网络协议 2.多线程。人的大脑是单线程的&#xff0c;电脑的cpu是多线程的。性能测试就是利用多线程的技术模拟多用户去负载 3.模拟真实场景。…

外卖系统海外版:技术智能引领全球美食新潮流

随着全球数字化浪潮的推动&#xff0c;外卖系统海外版不仅是食客们品味美食的便捷通道&#xff0c;更是技术智能在美食领域的引领者。本文将深入剖析其背后的技术实现&#xff0c;揭开代码带来的美食革新。 多语言支持&#xff1a;构建全球美食沟通桥梁 def multilingual_su…

机器人也能干的更好:RPA技术的优势和应用场景

RPA是什么&#xff1f; 机器人流程自动化RPA&#xff08;Robotic Process Automation&#xff09;是一种自动化技术&#xff0c;它使用软件机器人来高效完成重复且有逻辑性的工作。近年来&#xff0c;随着人工智能和自动化技术的不断发展和普及&#xff0c;RPA已经成为企业提高…

双指针——找到字符串中的所有字母异位词

https://leetcode.cn/problems/find-all-anagrams-in-a-string/description/?envTypestudy-plan-v2&envIdtop-100-liked 双指针&#xff0c;每次都统计出来p长度的滑动窗口里的数字,拿Arrays.equals进行对比,然后滑动一小格&#xff0c;减1加1继续比对即可。 class Solut…

2023年12月最新软件测试面试题(带答案)

1. 请自我介绍一下(需简单清楚的表述自已的基本情况&#xff0c;在这过程中要展现出自信&#xff0c;对工作有激情&#xff0c;上进&#xff0c;好学) 面试官您好&#xff0c;我叫###&#xff0c;今年26岁&#xff0c;来自江西九江&#xff0c;就读专业是电子商务&#xff0c;毕…

教你如何使用天眼销查企业客户

天眼销是一款能够帮助客户获取最新的企业联系方式、工商信息等关键数据的平台。 平台基于先进的技术和大数据解决方案&#xff0c;深入挖掘和分析企业信息&#xff0c;能够高效地收集、整理和存储各类企业数据&#xff0c;为用户提供360度视角和洞察&#xff1b;提供全面、准确…

从零开始掌握MAYA 2022:打造视觉创意的艺术大师之路

&#x1f482; 个人网站:【 海拥】【神级代码资源网站】【办公神器】&#x1f91f; 基于Web端打造的&#xff1a;&#x1f449;轻量化工具创作平台&#x1f485; 想寻找共同学习交流的小伙伴&#xff0c;请点击【全栈技术交流群】 Autodesk Maya是一款强大的三维计算机图形软件…

ROS-安装Rviz

安装 运行下列命令进行安装&#xff0c;xxxxxx处更改为自己的版本 sudo apt-get install ros-xxxxxx-rviz运行 先打开roscore roscore再运行rviz rviz参考&#xff1a; [1]https://blog.csdn.net/qq_66540741/article/details/134400248 [2]https://blog.csdn.net/baidu_384…

PostgreSQL入门指南:快速学会创建和管理数据库!

当谈到数据库管理系统时&#xff0c;PostgreSQL是一个功能强大且广泛使用的开源关系型数据库。在本次讲解中&#xff0c;我将为您介绍如何创建和管理数据库&#xff0c;并提供一些有关PostgreSQL的基本概念和最佳实践的指导。 创建数据库 在开始之前&#xff0c;请确保您已经成…