Tool Methods in Python Class Missing self Argument When Used in Custom Agents #29004
-
I am working on a custom implementation of AI agents using Python, where the agents rely on langchain tools (methods) for interacting with a PostgreSQL database. The ToolWithConnection class initializes a database connection and defines tools like list_tables, tables_schema, check_sql, and execute_sql_to_df. These tools are later used by CrewAI agents to perform various tasks. Here’s the relevant part of the code:
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 10 replies
-
The error you're encountering is due to the way the To resolve this issue, you need to ensure that the
By using To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
Beta Was this translation helpful? Give feedback.
-
I managed to find the solution by making each tool a separate class. Below is an example of how I structured the tools: Tool ClassesEach tool is implemented as a standalone class, with attributes for its name, functionality, and description. This encapsulation provides clarity and modularity.
Initializing the ToolsIn the main workflow or kickoff process, the tools are initialized like this:
I hope this helps! |
Beta Was this translation helpful? Give feedback.
-
I managed to find the solution by making each tool a separate class. Below is an example of how I structured the tools: Tool ClassesEach tool is implemented as a standalone class, with attributes for its name, functionality, and description. This encapsulation provides clarity and modularity.
Initializing the ToolsIn the main workflow or kickoff process, the tools are initialized like this:
I hope this helps! |
Beta Was this translation helpful? Give feedback.
I managed to find the solution by making each tool a separate class. Below is an example of how I structured the tools:
Tool Classes
Each tool is implemented as a standalone class, with attributes for its name, functionality, and description. This encapsulation provides clarity and modularity.