六期L1-从零构建企业生产级Agent服务:根据@聚客AI-Li老师提供的安装包版本修改,ReActAgents里面01到05文件夹下面代码可以跑通,但06_ReActAgentHILApiMultiSessionTask任务可以启动,按课件资料操作如下。估计还是版本兼容细节问题,麻烦老师提供本章节完整的requirements,或者其它方法解决一下,谢谢!
1.进入 06_ReActAgentHILApiMultiSessionTask 文件夹下运行脚本进行测试,支持多用户访问
2.首先运行 celery -A 01_backendServer.celery_app worker --loglevel=info 启动 celery 服务
3.再运行后端服务 python 01_backendServer.py
4.最后运行前端服务 python 02_frontendServer.py
在运行前端服务 python 02_frontendServer.py,命令行输入任意消息都报错,日志如下:
一、celery -A 01_backendServer.celery_app worker --loglevel=info报错日志:
celery -A 01_backendServer.celery_app worker --loglevel=info
 
 -------------- celery@DESKTOP-8SRNKHO v5.5.2 (immunity)
--- ***** -----
-- ******* ---- Windows-10-10.0.19045-SP0 2025-10-26 17:50:39
- *** --- * ---
- ** ---------- [config]
- ** ---------- .> app:         01_backendServer:0x1af1cef9150
- ** ---------- .> transport:   redis://localhost:6379/0
- ** ---------- .> results:     disabled://
- *** --- * --- .> concurrency: 8 (prefork)
-- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)
--- ***** -----
 -------------- [queues]
                .> celery           exchange=celery(direct) key=celery
[tasks]
  . utils.tasks.invoke_agent_task
  . utils.tasks.resume_agent_task
[2025-10-26 17:50:39,266: INFO/MainProcess] Connected to redis://localhost:6379/0
[2025-10-26 17:50:39,273: INFO/MainProcess] mingle: searching for neighbors
[2025-10-26 17:50:39,818: INFO/SpawnPoolWorker-6] child process 17964 calling self.run()
[2025-10-26 17:50:39,896: INFO/SpawnPoolWorker-2] child process 14000 calling self.run()
[2025-10-26 17:50:39,921: INFO/SpawnPoolWorker-4] child process 14140 calling self.run()
[2025-10-26 17:50:39,932: INFO/SpawnPoolWorker-3] child process 1756 calling self.run()
[2025-10-26 17:50:39,951: INFO/SpawnPoolWorker-1] child process 17132 calling self.run()
[2025-10-26 17:50:39,953: INFO/SpawnPoolWorker-7] child process 16428 calling self.run()
[2025-10-26 17:50:39,955: INFO/SpawnPoolWorker-8] child process 12124 calling self.run()
[2025-10-26 17:50:39,958: INFO/SpawnPoolWorker-5] child process 6112 calling self.run()
[2025-10-26 17:50:40,444: INFO/MainProcess] mingle: all alone
[2025-10-26 17:50:40,579: INFO/MainProcess] celery@DESKTOP-8SRNKHO ready.
[2025-10-26 17:52:20,413: INFO/MainProcess] Task utils.tasks.invoke_agent_task[b04f7001-d678-44ad-aa32-7960186805c8] received
[2025-10-26 17:52:20,427: ERROR/MainProcess] Task handler raised error: ValueError('not enough values to unpack (expected 3, got 0)')
billiard.einfo.RemoteTraceback:
"""
Traceback (most recent call last):
  File "D:\Users\ThinkPad\miniconda3\envs\ReActAgents\Lib\site-packages\billiard\pool.py", line 362, in workloop
    result = (True, prepare_result(fun(*args, **kwargs)))
                                   ^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\ThinkPad\miniconda3\envs\ReActAgents\Lib\site-packages\celery\app\trace.py", line 640, in fast_trace_task
    tasks, accept, hostname = _loc
    ^^^^^^^^^^^^^^^^^^^^^^^
ValueError: not enough values to unpack (expected 3, got 0)
"""
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "D:\Users\ThinkPad\miniconda3\envs\ReActAgents\Lib\site-packages\billiard\pool.py", line 362, in workloop
    result = (True, prepare_result(fun(*args, **kwargs)))
                                   ^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\ThinkPad\miniconda3\envs\ReActAgents\Lib\site-packages\celery\app\trace.py", line 640, in fast_trace_task
    tasks, accept, hostname = _loc
    ^^^^^^^^^^^^^^^^^^^^^^^
ValueError: not enough values to unpack (expected 3, got 0)
[2025-10-26 17:52:25,267: INFO/MainProcess] Task utils.tasks.invoke_agent_task[41f9ce72-7d8e-4c92-8ba1-f71f9f5a0892] received
[2025-10-26 17:52:25,270: ERROR/MainProcess] Task handler raised error: ValueError('not enough values to unpack (expected 3, got 0)')
billiard.einfo.RemoteTraceback:
"""
Traceback (most recent call last):
  File "D:\Users\ThinkPad\miniconda3\envs\ReActAgents\Lib\site-packages\billiard\pool.py", line 362, in workloop
    result = (True, prepare_result(fun(*args, **kwargs)))
                                   ^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\ThinkPad\miniconda3\envs\ReActAgents\Lib\site-packages\celery\app\trace.py", line 640, in fast_trace_task
    tasks, accept, hostname = _loc
    ^^^^^^^^^^^^^^^^^^^^^^^
ValueError: not enough values to unpack (expected 3, got 0)
"""
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "D:\Users\ThinkPad\miniconda3\envs\ReActAgents\Lib\site-packages\billiard\pool.py", line 362, in workloop
    result = (True, prepare_result(fun(*args, **kwargs)))
                                   ^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\ThinkPad\miniconda3\envs\ReActAgents\Lib\site-packages\celery\app\trace.py", line 640, in fast_trace_task
    tasks, accept, hostname = _loc
    ^^^^^^^^^^^^^^^^^^^^^^^
ValueError: not enough values to unpack (expected 3, got 0)
二、python 01_backendServer.py服务报错日志:
INFO:     Started server process [11296]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://0.0.0.0:8001 (Press CTRL+C to quit)
INFO:     127.0.0.1:64706 - "GET /system/info HTTP/1.1" 500 Internal Server Error
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "D:\Users\ThinkPad\miniconda3\envs\ReActAgents\Lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 403, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\ThinkPad\miniconda3\envs\ReActAgents\Lib\site-packages\uvicorn\middleware\proxy_headers.py", line 60, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\ThinkPad\miniconda3\envs\ReActAgents\Lib\site-packages\fastapi\applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File "D:\Users\ThinkPad\miniconda3\envs\ReActAgents\Lib\site-packages\starlette\applications.py", line 112, in __call__
    await self.middleware_stack(scope, receive, send)
  File "D:\Users\ThinkPad\miniconda3\envs\ReActAgents\Lib\site-packages\starlette\middleware\errors.py", line 187, in __call__
    raise exc
  File "D:\Users\ThinkPad\miniconda3\envs\ReActAgents\Lib\site-packages\starlette\middleware\errors.py", line 165, in __call__
    await self.app(scope, receive, _send)
  File "D:\Users\ThinkPad\miniconda3\envs\ReActAgents\Lib\site-packages\starlette\middleware\exceptions.py", line 62, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "D:\Users\ThinkPad\miniconda3\envs\ReActAgents\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "D:\Users\ThinkPad\miniconda3\envs\ReActAgents\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "D:\Users\ThinkPad\miniconda3\envs\ReActAgents\Lib\site-packages\starlette\routing.py", line 714, in __call__
    await self.middleware_stack(scope, receive, send)
  File "D:\Users\ThinkPad\miniconda3\envs\ReActAgents\Lib\site-packages\starlette\routing.py", line 734, in app
    await route.handle(scope, receive, send)
  File "D:\Users\ThinkPad\miniconda3\envs\ReActAgents\Lib\site-packages\starlette\routing.py", line 288, in handle
    await self.app(scope, receive, send)
  File "D:\Users\ThinkPad\miniconda3\envs\ReActAgents\Lib\site-packages\starlette\routing.py", line 76, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "D:\Users\ThinkPad\miniconda3\envs\ReActAgents\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "D:\Users\ThinkPad\miniconda3\envs\ReActAgents\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "D:\Users\ThinkPad\miniconda3\envs\ReActAgents\Lib\site-packages\starlette\routing.py", line 73, in app
    response = await f(request)
               ^^^^^^^^^^^^^^^^
  File "D:\Users\ThinkPad\miniconda3\envs\ReActAgents\Lib\site-packages\fastapi\routing.py", line 301, in app
    raw_response = await run_endpoint_function(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\ThinkPad\miniconda3\envs\ReActAgents\Lib\site-packages\fastapi\routing.py", line 212, in run_endpoint_function
    return await dependant.call(**values)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\PythonProject\聚客AI大模型课程\第五期L1课程\六期13-项目4_从零构建企业生产级Agent服务\ReActAgents\06_ReActAgentHILApiMultiSessionTask\01_backendServer.py", line 246, in get_system_info
    sessions_count=await app.state.session_manager.get_session_count(),
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\PythonProject\聚客AI大模型课程\第五期L1课程\六期13-项目4_从零构建企业生产级Agent服务\ReActAgents\06_ReActAgentHILApiMultiSessionTask\utils\redis.py", line 190, in get_session_count
    await self.cleanup_all_tasks()
  File "D:\PythonProject\聚客AI大模型课程\第五期L1课程\六期13-项目4_从零构建企业生产级Agent服务\ReActAgents\06_ReActAgentHILApiMultiSessionTask\utils\redis.py", line 256, in cleanup_all_tasks
    session_id, task_id = session_task.split(":", 1)
    ^^^^^^^^^^^^^^^^^^^
ValueError: not enough values to unpack (expected 2, got 1)
INFO:     127.0.0.1:64709 - "GET /agent/active/sessionid/user_1761472326 HTTP/1.1" 200 OK
INFO:     127.0.0.1:64714 - "POST /agent/invoke HTTP/1.1" 200 OK
INFO:     127.0.0.1:64720 - "POST /agent/invoke HTTP/1.1" 200 OK
三、02_frontendServer.py 打印输出:
┌─────────────────────── ReAct Agent智能体交互演示系统 ───────────────────────┐
│ 前端客户端模拟服务(异步任务调度)                                            │
└─────────────────────────────────────────────────────────────────────────────┘
无法获取当前系统内全部的会话状态信息,但这不影响使用
请输入用户ID (新ID将创建新用户,已有ID将恢复使用该用户) (user_1761472326): 
将为你打开一个全新会话,会话ID为 1a28abd1-f5d8-4d16-b664-351aa7f03bf6 
请输入您的问题 (输入 'exit' 退出,输入 'status' 查询状态,输入 'new' 
开始新会话,输入 'history' 恢复历史会话,输入 'setting' 偏好设置) (你好): 你是谁
正在提交查询,请求运行智能体...
收到响应数据:{'user_id': 'user_1761472326', 'session_id': 
'1a28abd1-f5d8-4d16-b664-351aa7f03bf6', 'task_id': 
'57bf63ae-1757-4d58-aeac-3686480ad6f3'}
响应时间: 2025-10-26 17:52:20 | 会话ID: 1a28abd1-f5d8-4d16-b664-351aa7f03bf6 | 
任务ID: 57bf63ae-1757-4d58-aeac-3686480ad6f3
本次查询任务已成功提交,任务ID为 57bf63ae-1757-4d58-aeac-3686480ad6f3 ,请输入 
history 特殊指令查看任务完成情况
请输入您的问题 (输入 'exit' 退出,输入 'status' 查询状态,输入 'new' 
开始新会话,输入 'history' 恢复历史会话,输入 'setting' 偏好设置) (你好): 
正在提交查询,请求运行智能体...
收到响应数据:{'user_id': 'user_1761472326', 'session_id': 
'1a28abd1-f5d8-4d16-b664-351aa7f03bf6', 'task_id': 
'fb411451-fd55-418a-aa9a-b6b9a4207695'}
响应时间: 2025-10-26 17:52:25 | 会话ID: 1a28abd1-f5d8-4d16-b664-351aa7f03bf6 | 
任务ID: fb411451-fd55-418a-aa9a-b6b9a4207695
本次查询任务已成功提交,任务ID为 fb411451-fd55-418a-aa9a-b6b9a4207695 ,请输入 
history 特殊指令查看任务完成情况
请输入您的问题 (输入 'exit' 退出,输入 'status' 查询状态,输入 'new' 
开始新会话,输入 'history' 恢复历史会话,输入 'setting' 偏好设置) (你好): 你好
正在提交查询,请求运行智能体...
收到响应数据:{'user_id': 'user_1761472326', 'session_id': 
'1a28abd1-f5d8-4d16-b664-351aa7f03bf6', 'task_id': 
'af6c960f-943c-41b7-a958-e7e18d9ab36f'}
响应时间: 2025-10-26 18:53:06 | 会话ID: 1a28abd1-f5d8-4d16-b664-351aa7f03bf6 | 
任务ID: af6c960f-943c-41b7-a958-e7e18d9ab36f
本次查询任务已成功提交,任务ID为 af6c960f-943c-41b7-a958-e7e18d9ab36f ,请输入 
history 特殊指令查看任务完成情况
请输入您的问题 (输入 'exit' 退出,输入 'status' 查询状态,输入 'new' 
开始新会话,输入 'history' 恢复历史会话,输入 'setting' 偏好设置) (你好):