NagaAgent icon indicating copy to clipboard operation
NagaAgent copied to clipboard

[BUG]运行start脚本时No module named 'tool_call_utils'

Open TiaNHu1 opened this issue 1 year ago • 4 comments

Traceback (most recent call last): File "G:\NagaAgent\main.py", line 13, in from conversation_core import NagaConversation File "G:\NagaAgent\conversation_core.py", line 21, in from apiserver.tool_call_utils import parse_tool_calls, execute_tool_calls, tool_call_loop File "G:\NagaAgent\apiserver_init_.py", line 5, in from .api_server import app File "G:\NagaAgent\apiserver\api_server.py", line 34, in from tool_call_utils import parse_tool_calls, execute_tool_calls, tool_call_loop ModuleNotFoundError: No module named 'tool_call_utils' Press any key to continue . . . 以及检查脚本里对powershell的检测似乎是不必要的

TiaNHu1 avatar Jul 27 '25 14:07 TiaNHu1

总之最后是搞定了 似乎是api_server.py和外面有个core循环引用的问题 不知道其他人有没有这个问题 如果有的话 可以看这个解决方案 解决方案: 确保正确的包结构:

在 G:\NagaAgent\ 目录下创建一个空的 init.py 文件。 在 G:\NagaAgent\apiserver\ 目录下创建一个空的 init.py 文件。 修正 apiserver/api_server.py 中的导入:

修复 tool_call_utils 的导入: 将 from tool_call_utils import ... 改为 from .tool_call_utils import ... (注意前面的点 .)。 移除手动路径设置: 删除 sys.path.insert(...) 的代码行。 修复 NagaConversation 的类型提示: 将 naga_agent: Optional[NagaConversation] 改为 naga_agent: Optional['NagaConversation'] (用单引号括起来)。 延迟 NagaConversation 的实际导入和实例化: 删除 api_server.py 文件顶部(顶层作用域)的任何 from conversation_core import NagaConversation 导入语句。 确保 from conversation_core import NagaConversation 和 naga_agent = NagaConversation() 的代码 仅在 lifespan 函数内部 执行。 验证 conversation_core.py 中的导入:

确认导入语句是 from apiserver.tool_call_utils import ... (绝对导入)。 确认 conversation_core.py 在文件顶部没有导入 api_server 或 NagaConversation。

TiaNHu1 avatar Jul 27 '25 14:07 TiaNHu1

这个已修复,只是还没传

RTGS2017 avatar Jul 27 '25 14:07 RTGS2017

好的
检测脚本里对c++ build tool和powershell环境检测有问题 需要我提pr吗

TiaNHu1 avatar Jul 27 '25 14:07 TiaNHu1

可以

RTGS2017 avatar Jul 27 '25 14:07 RTGS2017