OpenBMB / XAgent

An Autonomous LLM Agent for Complex Task Solving
https://blog.x-agent.net/blog/xagent/
Apache License 2.0
8.06k stars 827 forks source link

AttributeError: 'ToolServerInterface' object has no attribute 'cookies' #332

Closed jfo888 closed 9 months ago

jfo888 commented 9 months ago

Issue Description / 问题描述

Please provide a detailed description of the error or issue you encountered. / 请详细描述您遇到的错误或问题。

Steps to Reproduce / 复现步骤

Please provide the specific steps to reproduce the error. / 请提供复现错误的具体步骤。 启动XAgent-Server时提示AttributeError: 'ToolServerInterface' object has no attribute 'cookies',xagent-main-ToolServerManager-1提示docker.errors.APIError: 500 Server Error for http+docker://localhost/v1.43/containers/d7b6edec7ae50ef3150d64f5de5e4a54aa5930f65178bb264bf49e65a25e7b16/start: Internal Server Error ("error while mounting volume '/var/lib/docker/volumes/toolserverconfig/_data': failed to mount local volume: mount /assets/config:/var/lib/docker/volumes/toolserverconfig/_data, flags: 0x1000: no such file or directory")

Expected Behavior / 预期行为

Describe the behavior you expected to see. / 请描述您期望的正确行为。

Environment / 环境信息

Error Screenshots or Logs / 错误截图或日志

If possible, please provide relevant screenshots or logs of the error. / 如果可能,请提供相关的错误截图或日志文件。 2023-12-12 10:53:00 INFO: Will watch for changes in these directories: ['/app'] 2023-12-12 10:53:00 INFO: Uvicorn running on http://0.0.0.0:8090 (Press CTRL+C to quit) 2023-12-12 10:53:00 INFO: Started reloader process [1] using StatReload 2023-12-12 10:53:29 INFO: Started server process [37] 2023-12-12 10:53:29 INFO: Waiting for application startup. 2023-12-12 10:53:29 INFO: Application startup complete. 2023-12-12 10:55:01 XAgent Service Startup Param: 2023-12-12 10:55:01 app: app:app 2023-12-12 10:55:01 prod: False 2023-12-12 10:55:01 base_dir: XAgentServer 2023-12-12 10:55:01 use_redis: False 2023-12-12 10:55:01 recorder_root_dir: running_records 2023-12-12 10:55:01 default_login: True 2023-12-12 10:55:01 check_running: False 2023-12-12 10:55:01 host: 0.0.0.0 2023-12-12 10:55:01 port: 8090 2023-12-12 10:55:01 debug: True 2023-12-12 10:55:01 reload: True 2023-12-12 10:55:01 workers: 1 2023-12-12 10:55:01 share_url: https://x-agent.net/api/conv/community 2023-12-12 10:55:01 DB: <class 'XAgentServer.application.core.envs.XAgentServerEnv.DB'> 2023-12-12 10:55:01 Redis: <class 'XAgentServer.application.core.envs.XAgentServerEnv.Redis'> 2023-12-12 10:55:01 Email: <class 'XAgentServer.application.core.envs.XAgentServerEnv.Email'> 2023-12-12 10:55:01 Upload: <class 'XAgentServer.application.core.envs.XAgentServerEnv.Upload'> 2023-12-12 10:55:01 XAgent Service Init Dependence.
2023-12-12 10:55:01 init a thread pool executor, max_workers: 1
2023-12-12 10:55:01 XAgent Service Init Dependence: Complete!
2023-12-12 10:55:01 Default user: Guest, token: xagent, you can use it to login
2023-12-12 10:55:01 XAgent Server Dependences:
2023-12-12 10:55:01 Python: 3.10+ 2023-12-12 10:55:01 FastAPI: Http server 2023-12-12 10:55:01 Websocket: long connect with client 2023-12-12 10:55:01 MySQL: save xagent data 2023-12-12 10:55:01 SqlAlchemy: ORM with MySQL 2023-12-12 10:55:01 Redis: save status of interaction 2023-12-12 10:55:01 Threading: run interaction 2023-12-12 10:55:01 APScheduler: send data to client and keep alive 2023-12-12 10:55:01 FastAPI APIRouter: manage websocket route 2023-12-12 10:55:01 XAgentError: XAgentServer.exts.exception_ext 2023-12-12 10:55:01 XAgent Server Version:
2023-12-12 10:55:01 V 1.1.0 2023-12-12 10:55:01 Notes:
2023-12-12 10:55:01 Since V 1.1.0, 2023-12-12 10:55:01 Local storage will no longer be supported, replaced by Mysql. 2023-12-12 10:55:01 The service depends on Redis and Mysql, 2023-12-12 10:55:01 so you need to install Redis and Mysql before using it. 2023-12-12 10:55:01 Before you use this service, please ensure that the following services are available: 2023-12-12 10:55:01 1. Redis on docker, port: 6379, you can start it by docker, default password: xagent 2023-12-12 10:55:01 2. Mysql on docker, port: 3306, you can start it by docker 2023-12-12 10:55:01 3. XAgent Tool Server is runnning on port 8080 2023-12-12 10:55:01 4. Port 8090 is not occupied 2023-12-12 10:55:01
2023-12-12 10:55:01 INFO: 127.0.0.1:37864 - "POST /conv/getUserInteractions HTTP/1.0" 200 OK 2023-12-12 10:55:02 INFO: 127.0.0.1:37850 - "POST /conv/init_conv_env HTTP/1.0" 200 OK 2023-12-12 10:55:15 Receive connection from 38ea7f2a827f41b8a61ed2bc2c242468: user_id: guest, token: xagent, description: f 2023-12-12 10:55:15 Receive data from 38ea7f2a827f41b8a61ed2bc2c242468: { 2023-12-12 10:55:15 "type": "data", 2023-12-12 10:55:15 "args": { 2023-12-12 10:55:15 "goal": "f" 2023-12-12 10:55:15 }, 2023-12-12 10:55:15 "agent": "agent", 2023-12-12 10:55:15 "mode": "auto", 2023-12-12 10:55:15 "file_list": [] 2023-12-12 10:55:15 } 2023-12-12 10:55:15 Receive data from 38ea7f2a827f41b8a61ed2bc2c242468: { 2023-12-12 10:55:15 "type": "connect" 2023-12-12 10:55:15 } 2023-12-12 10:55:15 init interaction: 38ea7f2a827f41b8a61ed2bc2c242468 2023-12-12 10:55:15 Register logger into interaction of 38ea7f2a827f41b8a61ed2bc2c242468, done! 2023-12-12 10:55:15 Register db into interaction of 38ea7f2a827f41b8a61ed2bc2c242468, done! 2023-12-12 10:55:15 Register logger into XAgentServer of 38ea7f2a827f41b8a61ed2bc2c242468, done! 2023-12-12 10:55:11 INFO: ('192.168.65.1', 16654) - "WebSocket /ws/base/38ea7f2a827f41b8a61ed2bc2c242468?user_id=guest&token=xagent&description=f" [accepted] 2023-12-12 10:55:11 INFO: connection open 2023-12-12 10:55:15 Start a new thread to run interaction of 38ea7f2a827f41b8a61ed2bc2c242468, done! 2023-12-12 10:55:15 ---config file--- 2023-12-12 10:55:15 assets/config.yml 2023-12-12 10:55:15 ---args--- 2023-12-12 10:55:15 {} 2023-12-12 10:55:15 server is running, the start query is f 2023-12-12 10:55:15 register tool server interface 2023-12-12 10:55:15 lazy init tool server interface 2023-12-12 10:55:19 Run time of job "MainServer.send_data (trigger: interval[0:00:01], next run at: 2023-12-12 02:55:19 UTC)" was missed by 0:00:01.039593 2023-12-12 10:55:25 Exception in thread Thread-1 (task_handler): 2023-12-12 10:55:25 Traceback (most recent call last): 2023-12-12 10:55:25 File "/app/XAgentServer/server.py", line 52, in interact 2023-12-12 10:55:25 xagent_core.build(xagent_param, interaction=interaction) 2023-12-12 10:55:25 File "/app/XAgent/core.py", line 198, in build 2023-12-12 10:55:25 self.register_all(param, interaction) 2023-12-12 10:55:25 File "/app/XAgent/core.py", line 188, in register_all 2023-12-12 10:55:25 self.register_toolserver_interface(param) 2023-12-12 10:55:25 File "/app/XAgent/core.py", line 141, in register_toolserver_interface 2023-12-12 10:55:25 self.toolserver_interface.lazy_init(config=param.config) 2023-12-12 10:55:25 File "/app/XAgent/toolserver_interface.py", line 94, in lazy_init 2023-12-12 10:55:25 response.raise_for_status() 2023-12-12 10:55:25 File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 1021, in raise_for_status 2023-12-12 10:55:25 raise HTTPError(http_error_msg, response=self) 2023-12-12 10:55:25 requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: http://toolservermanager:8080/get_cookie 2023-12-12 10:55:25 2023-12-12 10:55:25 The above exception was the direct cause of the following exception: 2023-12-12 10:55:25 2023-12-12 10:55:25 Traceback (most recent call last): 2023-12-12 10:55:25 File "/app/XAgentServer/server.py", line 93, in interact 2023-12-12 10:55:25 raise XAgentRunningError(str(e)) from e 2023-12-12 10:55:25 XAgentServer.exts.exception_ext.XAgentRunningError: 500 Server Error: Internal Server Error for url: http://toolservermanager:8080/get_cookie 2023-12-12 10:55:25 2023-12-12 10:55:25 During handling of the above exception, another exception occurred: 2023-12-12 10:55:25 2023-12-12 10:55:25 Traceback (most recent call last): 2023-12-12 10:55:25 File "/usr/local/lib/python3.10/threading.py", line 1016, in _bootstrap_inner 2023-12-12 10:55:25 self.run() 2023-12-12 10:55:25 File "/usr/local/lib/python3.10/threading.py", line 953, in run 2023-12-12 10:55:25 self._target(*self._args, **self._kwargs) 2023-12-12 10:55:25 File "/app/XAgentServer/application/websockets/base.py", line 324, in task_handler 2023-12-12 10:55:25 server.interact(interaction=interaction) 2023-12-12 10:55:25 File "/app/XAgentServer/server.py", line 96, in interact 2023-12-12 10:55:25 xagent_core.close() 2023-12-12 10:55:25 File "/app/XAgent/core.py", line 216, in close 2023-12-12 10:55:25 self.toolserver_interface.download_all_files() 2023-12-12 10:55:25 File "/app/XAgent/toolserver_interface.py", line 166, in download_all_files 2023-12-12 10:55:25 response = requests.post(url, cookies=self.cookies,) 2023-12-12 10:55:25 AttributeError: 'ToolServerInterface' object has no attribute 'cookies'

Additional Notes / 其他备注

If you have any additional information or notes, please add them here. / 如果有其他补充信息,请在此处添加。 2023-12-12 10:52:40 [2023-12-12 02:52:40 +0000] [1] [INFO] Starting gunicorn 21.2.0 2023-12-12 10:52:40 [2023-12-12 02:52:40 +0000] [1] [INFO] Listening at: http://0.0.0.0:8080 (1) 2023-12-12 10:52:40 [2023-12-12 02:52:40 +0000] [1] [INFO] Using worker: uvicorn.workers.UvicornWorker 2023-12-12 10:52:41 [2023-12-12 02:52:41 +0000] [7] [INFO] Booting worker with pid: 7 2023-12-12 10:52:41 [2023-12-12 02:52:41 +0000] [8] [INFO] Booting worker with pid: 8 2023-12-12 10:52:51 [2023-12-12 02:52:51 +0000] [7] [INFO] Database connected 2023-12-12 10:52:51 [2023-12-12 02:52:51 +0000] [8] [INFO] Database connected 2023-12-12 10:52:51 [2023-12-12 02:52:51 +0000] [7] [INFO] Docker client connected 2023-12-12 10:52:51 [2023-12-12 02:52:51 +0000] [8] [INFO] Docker client connected 2023-12-12 10:52:52 [2023-12-12 02:52:52 +0000] [7] [INFO] Started server process [7] 2023-12-12 10:52:52 [2023-12-12 02:52:52 +0000] [7] [INFO] Waiting for application startup. 2023-12-12 10:52:52 [2023-12-12 02:52:52 +0000] [8] [INFO] Started server process [8] 2023-12-12 10:52:52 [2023-12-12 02:52:52 +0000] [8] [INFO] Waiting for application startup. 2023-12-12 10:52:54 [2023-12-12 02:52:54 +0000] [8] [INFO] Application startup complete. 2023-12-12 10:52:54 [2023-12-12 02:52:54 +0000] [7] [INFO] Application startup complete. 2023-12-12 10:55:25 [2023-12-12 02:55:25 +0000] [7] [ERROR] Exception in ASGI application 2023-12-12 10:55:25 Traceback (most recent call last): 2023-12-12 10:55:25 File "/usr/local/lib/python3.10/site-packages/docker/api/client.py", line 268, in _raise_for_status 2023-12-12 10:55:25 response.raise_for_status() 2023-12-12 10:55:25 File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 1021, in raise_for_status 2023-12-12 10:55:25 raise HTTPError(http_error_msg, response=self) 2023-12-12 10:55:25 requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: http+docker://localhost/v1.43/containers/d7b6edec7ae50ef3150d64f5de5e4a54aa5930f65178bb264bf49e65a25e7b16/start 2023-12-12 10:55:25 2023-12-12 10:55:25 The above exception was the direct cause of the following exception: 2023-12-12 10:55:25 2023-12-12 10:55:25 Traceback (most recent call last): 2023-12-12 10:55:25 File "/usr/local/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 408, in run_asgi 2023-12-12 10:55:25 result = await app( # type: ignore[func-returns-value] 2023-12-12 10:55:25 File "/usr/local/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in call 2023-12-12 10:55:25 return await self.app(scope, receive, send) 2023-12-12 10:55:25 File "/usr/local/lib/python3.10/site-packages/fastapi/applications.py", line 1106, in call 2023-12-12 10:55:25 await super().call(scope, receive, send) 2023-12-12 10:55:25 File "/usr/local/lib/python3.10/site-packages/starlette/applications.py", line 122, in call 2023-12-12 10:55:25 await self.middleware_stack(scope, receive, send) 2023-12-12 10:55:25 File "/usr/local/lib/python3.10/site-packages/starlette/middleware/errors.py", line 184, in call 2023-12-12 10:55:25 raise exc 2023-12-12 10:55:25 File "/usr/local/lib/python3.10/site-packages/starlette/middleware/errors.py", line 162, in call 2023-12-12 10:55:25 await self.app(scope, receive, _send) 2023-12-12 10:55:25 File "/usr/local/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 79, in call 2023-12-12 10:55:25 raise exc 2023-12-12 10:55:25 File "/usr/local/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 68, in call 2023-12-12 10:55:25 await self.app(scope, receive, sender) 2023-12-12 10:55:25 File "/usr/local/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in call 2023-12-12 10:55:25 raise e 2023-12-12 10:55:25 File "/usr/local/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in call 2023-12-12 10:55:25 await self.app(scope, receive, send) 2023-12-12 10:55:25 File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 718, in call 2023-12-12 10:55:25 await route.handle(scope, receive, send) 2023-12-12 10:55:25 File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 276, in handle 2023-12-12 10:55:25 await self.app(scope, receive, send) 2023-12-12 10:55:25 File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 66, in app 2023-12-12 10:55:25 response = await func(request) 2023-12-12 10:55:25 File "/usr/local/lib/python3.10/site-packages/fastapi/routing.py", line 274, in app 2023-12-12 10:55:25 raw_response = await run_endpoint_function( 2023-12-12 10:55:25 File "/usr/local/lib/python3.10/site-packages/fastapi/routing.py", line 191, in run_endpoint_function 2023-12-12 10:55:25 return await dependant.call(values) 2023-12-12 10:55:25 File "/app/main.py", line 130, in read_cookie_info 2023-12-12 10:55:25 container = docker_client.containers.run( 2023-12-12 10:55:25 File "/usr/local/lib/python3.10/site-packages/docker/models/containers.py", line 865, in run 2023-12-12 10:55:25 container.start() 2023-12-12 10:55:25 File "/usr/local/lib/python3.10/site-packages/docker/models/containers.py", line 406, in start 2023-12-12 10:55:25 return self.client.api.start(self.id, kwargs) 2023-12-12 10:55:25 File "/usr/local/lib/python3.10/site-packages/docker/utils/decorators.py", line 19, in wrapped 2023-12-12 10:55:25 return f(self, resource_id, *args, **kwargs) 2023-12-12 10:55:25 File "/usr/local/lib/python3.10/site-packages/docker/api/container.py", line 1127, in start 2023-12-12 10:55:25 self._raise_for_status(res) 2023-12-12 10:55:25 File "/usr/local/lib/python3.10/site-packages/docker/api/client.py", line 270, in _raise_for_status 2023-12-12 10:55:25 raise create_api_error_from_http_exception(e) from e 2023-12-12 10:55:25 File "/usr/local/lib/python3.10/site-packages/docker/errors.py", line 39, in create_api_error_from_http_exception 2023-12-12 10:55:25 raise cls(e, response=response, explanation=explanation) from e 2023-12-12 10:55:25 docker.errors.APIError: 500 Server Error for http+docker://localhost/v1.43/containers/d7b6edec7ae50ef3150d64f5de5e4a54aa5930f65178bb264bf49e65a25e7b16/start: Internal Server Error ("error while mounting volume '/var/lib/docker/volumes/toolserverconfig/_data': failed to mount local volume: mount /assets/config:/var/lib/docker/volumes/toolserverconfig/_data, flags: 0x1000: no such file or directory")

jfo888 commented 9 months ago

又出现了新的报错信息XAgentServer.exts.exception_ext.XAgentRunningError: 500 Server Error: Internal Server Error for url: http://localhost:8080/get_cookie (python310) e:\rengongzhineng\XAgent-main>python run.py --task "你好" --model "gpt-4" XAgentServer is running on cmd mode XAgentServer log: XAgentServer\localstorage\interact_records\2023-12-12\27e7e159220845d194f54f0c336f744d init interaction: 27e7e159220845d194f54f0c336f744d Register logger into interaction of 27e7e159220845d194f54f0c336f744d, done! Register db into interaction of 27e7e159220845d194f54f0c336f744d, done! Register logger into XAgentServer of 27e7e159220845d194f54f0c336f744d, done! Start a new thread to run interaction of 27e7e159220845d194f54f0c336f744d, done! ---config file--- assets/config.yml ---args--- {'task': '你好', 'default_completion_kwargs': {'model': 'gpt-4', 'temperature': 0.2, 'request_timeout': 60}, 'mode': 'auto', 'quiet': False, 'enable_ask_human_for_help': False, 'config_file': 'assets/config.yml'} server is running, the start query is 你好 register tool server interface lazy init tool server interface Trying to connect to ToolServer at http://localhost:8080 Traceback (most recent call last): File "e:\rengongzhineng\XAgent-main\XAgentServer\server.py", line 52, in interact xagent_core.build(xagent_param, interaction=interaction) File "e:\rengongzhineng\XAgent-main\XAgent\core.py", line 198, in build self.register_all(param, interaction) File "e:\rengongzhineng\XAgent-main\XAgent\core.py", line 188, in register_all self.register_toolserver_interface(param) File "e:\rengongzhineng\XAgent-main\XAgent\core.py", line 141, in register_toolserver_interface self.toolserver_interface.lazy_init(config=param.config) File "e:\rengongzhineng\XAgent-main\XAgent\toolserver_interface.py", line 94, in lazy_init response.raise_for_status() File "D:\ProgramData\anaconda3\envs\python310\lib\site-packages\requests\models.py", line 1021, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: http://localhost:8080/get_cookie

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "e:\rengongzhineng\XAgent-main\XAgentServer\server.py", line 93, in interact raise XAgentRunningError(str(e)) from e XAgentServer.exts.exception_ext.XAgentRunningError: 500 Server Error: Internal Server Error for url: http://localhost:8080/get_cookie

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "e:\rengongzhineng\XAgent-main\run.py", line 70, in cmd.start() File "e:\rengongzhineng\XAgent-main\command.py", line 282, in start self.run() File "e:\rengongzhineng\XAgent-main\command.py", line 220, in run self.task_handler(parameter=parameter) File "e:\rengongzhineng\XAgent-main\command.py", line 265, in task_handler server.interact(interaction=interaction) File "e:\rengongzhineng\XAgent-main\XAgentServer\server.py", line 96, in interact xagent_core.close() File "e:\rengongzhineng\XAgent-main\XAgent\core.py", line 216, in close self.toolserver_interface.download_all_files() File "e:\rengongzhineng\XAgent-main\XAgent\toolserver_interface.py", line 166, in download_all_files response = requests.post(url, cookies=self.cookies,) AttributeError: 'ToolServerInterface' object has no attribute 'cookies'

Umpire2018 commented 9 months ago

Can you contact me here? We can schedule a meeting to locate the problem.