@Tool decorator not working #26150
-
Checked other resources
Commit to Help
Example Code@Tool
def reset_process_tool():
"""Can be used to reset process when user wants to start over"""
process.reset() DescriptionI have used @tool decorator on a function but when I run it in pycharm I get this error:
TypeError: Tool.init() missing 2 required positional arguments: 'func' and 'description' System Infolangchain==0.2.16 |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 3 replies
-
The In your provided code, the @Tool(name="reset_process_tool", func=reset_process_tool, description="Can be used to reset process when user wants to start over")
def reset_process_tool():
"""Can be used to reset process when user wants to start over"""
process.reset() Alternatively, you can use the reset_process_tool = Tool.from_function(
func=reset_process_tool,
name="reset_process_tool",
description="Can be used to reset process when user wants to start over"
) Ensure the decorator is properly defined to handle the function and description arguments. The |
Beta Was this translation helpful? Give feedback.
-
Okay fine, but this documentation says I could just use @tool and it will take the function name by default. ---Excerpt from the documentation------- This @tool decorator is the simplest way to define a custom tool. The decorator uses the function name as the tool name by default, but this can be overridden by passing a string as the first argument. Additionally, the decorator will use the function's docstring as the tool's description - so a docstring MUST be provided. from langchain_core.tools import tool @tool print(multiply.name) |
Beta Was this translation helpful? Give feedback.
-
@dosu Even this does not work, it gives this error: Unresolved reference 'reset_process_tool' |
Beta Was this translation helpful? Give feedback.
-
@dosu Even this does not work, it gives this error: Unresolved reference 'reset_process_tool' |
Beta Was this translation helpful? Give feedback.
-
@dosu you only suggest me below code which is producing error: @tool(name="reset_process_tool", func=reset_process_tool, description="Can be used to reset process when user wants to start over") |
Beta Was this translation helpful? Give feedback.
-
The tool decorator is a lower case from langchain_core.tools import tool
@tool
def foo(): |
Beta Was this translation helpful? Give feedback.
The tool decorator is a lower case
tool
as opposed to theTool
class