optimistic-gold
optimistic-gold7mo ago

[Solved ✅] Local tools not working

I was going through the guide for creating local tools but it looks like the examples are broken. Following the Readme doesn't work (terminal hangs up when running the examples)
27 Replies
optimistic-gold
optimistic-goldOP7mo ago
I tried the sql_agent
vicious-gold
vicious-gold7mo ago
Hey @Mario, Could you say me what error you exactly got??
Soham
Soham7mo ago
Hey, yes the docs have not been updated. Doing it today. Thanks for reporting.
optimistic-gold
optimistic-goldOP7mo ago
Hey, sorry for the late reply. There was no error but either the terminal got stuck when I ran the main.py file or the process got killed automatically and did not start Yes, I think the docs are a bit behind. Thanks for your support turns out it was an issue with pyenv, reinstalling pyenv solved that. Now I tried to create my own local tool but facing import issues in the examples folder (because the new tool is not present in the installed composio package). Please point me to any resources on this 🙏🏻
Soham
Soham7mo ago
Hey @Mario , if I may ask what kind of tool are you working on?
optimistic-gold
optimistic-goldOP7mo ago
sql tool for postgres
Soham
Soham7mo ago
can you give me 2 hours, we have made this really really easy and revamped the whole thing. I will update the docs.
optimistic-gold
optimistic-goldOP7mo ago
sure appreciate the fast replies 👍
Soham
Soham7mo ago
Thanks a lot. Basically, it's going to be a literal python function. Something pretty cool. Thanks.
optimistic-gold
optimistic-goldOP7mo ago
Sounds dope @Soham The docs are still the same, have you published your changes yet?
Soham
Soham7mo ago
Composio Docs
Creating a Local Tool - Composio
Composio enables your agents to connect with Various Tools and work with them
Soham
Soham7mo ago
I published the new local tools process.
optimistic-gold
optimistic-goldOP7mo ago
oh didn't see this one
Soham
Soham7mo ago
Just published. 😅
optimistic-gold
optimistic-goldOP7mo ago
🙂 k, thx I'm still not sure how to intgerate the tool into any example 😦
vicious-gold
vicious-gold7mo ago
Just import the action from your custom tool:
from composio import action
from custom_tools import say

composio_toolset = ComposioToolSet()

# Get required tools
tools = [
*composio_toolset.get_actions(
actions=[
say, # This is an example of a custom tool
]
),
]
from composio import action
from custom_tools import say

composio_toolset = ComposioToolSet()

# Get required tools
tools = [
*composio_toolset.get_actions(
actions=[
say, # This is an example of a custom tool
]
),
]
And add tools in your preferred framework (if taking crewAI as an example):
crewai_agent = Agent(
role="Github Agent",
goal="""You take action on Github using Github APIs""",
backstory=(
"You are AI agent that is responsible for taking actions on Github "
"on users behalf. You need to take action on Github using Github APIs"
),
verbose=True,
tools=tools, # add here
llm=llm,
)
crewai_agent = Agent(
role="Github Agent",
goal="""You take action on Github using Github APIs""",
backstory=(
"You are AI agent that is responsible for taking actions on Github "
"on users behalf. You need to take action on Github using Github APIs"
),
verbose=True,
tools=tools, # add here
llm=llm,
)
@Mario
optimistic-gold
optimistic-goldOP7mo ago
In this, the say() action takes a string param called message, can I pass any params to this action or does it have to be just message?
vicious-gold
vicious-gold7mo ago
It's totally up to you, just don't forget to give the correct type 🙌
optimistic-gold
optimistic-goldOP7mo ago
I think the docstring is required, that's giving me an exception
vicious-gold
vicious-gold7mo ago
Yes, it tells what your action is about 🙂
optimistic-gold
optimistic-goldOP7mo ago
I'm getting this validation error when trying to create an agent using crewAI
pydantic_core._pydantic_core.ValidationError: 1 validation error for Agent
Value error, 1 validation error for CrewAgentExecutor
tools -> 0
Can't instantiate abstract class BaseTool with abstract method _run (type=type_error) [type=value_error, input_value={'role': 'Query Executor ...***'), openai_proxy='')}, input_type=dict]
pydantic_core._pydantic_core.ValidationError: 1 validation error for Agent
Value error, 1 validation error for CrewAgentExecutor
tools -> 0
Can't instantiate abstract class BaseTool with abstract method _run (type=type_error) [type=value_error, input_value={'role': 'Query Executor ...***'), openai_proxy='')}, input_type=dict]
looks like the custom tools have some implementation issue? or am I missing something?
Soham
Soham7mo ago
Just checking. Yes doc string is required because agent uses the docstring information to decide if the tool should be called or not. You basically need to add description around the tool using the doc string. I will add it to the doc. Confirming the bug does exist. Thanks for pointing out.
optimistic-gold
optimistic-goldOP7mo ago
This is the longest I've spent on an assignment 🫠
Soham
Soham7mo ago
Please just submit your code even if it's not working. I had no idea you were on assignment. We have been refactoring the local tools recently.
optimistic-gold
optimistic-goldOP7mo ago
oh lol ok
Soham
Soham7mo ago
Hey, this has been corrected btw. Please use the latest version of the SDK.
optimistic-gold
optimistic-goldOP7mo ago
Oh, I have already submitted the application. 🥲

Did you find this page helpful?