PySpur-Dev / pyspur

A visual playground for agentic workflows: Iterate over your agents 10x faster

Home Page:https://pyspur.dev

Repository from Github https://github.comPySpur-Dev/pyspurRepository from Github https://github.comPySpur-Dev/pyspur

Error occurred when using custom tools in workflow

Panda98 opened this issue · comments

Hi,

I created a custom tool following the example from https://github.com/PySpur-Dev/pyspur/blob/main/backend/pyspur/examples/tool_function_example.py, but encountered an error when using it and running in workflow:

Traceback (most recent call last):
  File "/data/xxxxxx/venv/lib/python3.11/site-packages/pyspur/execution/workflow_executor.py", line 610, in _execute_node
    node_instance = NodeFactory.create_node(
                    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/xxxxxx/venv/lib/python3.11/site-packages/pyspur/nodes/factory.py", line 106, in create_node
    node_class = getattr(module, class_name)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'tools.weather' has no attribute 'weather_tool.node_class'

Python version: 3.11.6
PySpur version: 0.1.16

Here's my workflow:

Image
commented

Temporary solution working for me is adding this to the bottom of your_custom_tool.py

setattr(sys.modules[__name__], "string_manipulator.node_class", string_manipulator.node_class)
setattr(sys.modules[__name__], "math_tool.node_class", math_tool.node_class)
setattr(sys.modules[__name__], "template_example.node_class", template_example.node_class)
setattr(sys.modules[__name__], "weather_tool.node_class", weather_tool.node_class)

Temporary solution working for me is adding this to the bottom of your_custom_tool.py

setattr(sys.modules[__name__], "string_manipulator.node_class", string_manipulator.node_class)
setattr(sys.modules[__name__], "math_tool.node_class", math_tool.node_class)
setattr(sys.modules[__name__], "template_example.node_class", template_example.node_class)
setattr(sys.modules[__name__], "weather_tool.node_class", weather_tool.node_class)

It works! Thx