TypeError: BaseTool.__call__() missing 1 required positional argument: 'tool_input' #20175
Replies: 7 comments 2 replies
-
Hey @artificialai223, great to see you diving into the LangChain framework again! Hope you've been doing well since our last chat. Based on the error message you provided, it seems like you're trying to instantiate your Here's the definition of the def __call__(self, tool_input: str, callbacks: Callbacks = None) -> str:
"""Make tool callable."""
return self.run(tool_input, callbacks=callbacks) As you can see, this method expects a To resolve this issue, you should call your custom Weather tool with the required # Assuming weather_tool is an instance of your custom Weather tool
weather_tool_result = weather_tool("your_tool_input_here") Replace You can find more information about the Please let me know if this resolves your issue or if you need further assistance. Sources
|
Beta Was this translation helpful? Give feedback.
-
@dosu-bot I am trying to make it so the AI can call it via OpenAI tools parser. Could you rewrite my tool file for this? from langchain.pydantic_v1 import BaseModel, Field def weather_lookup(location: str) -> str: WeatherLookup = StructuredTool.from_function( |
Beta Was this translation helpful? Give feedback.
-
Try this
|
Beta Was this translation helpful? Give feedback.
-
I resolved it, thanks for the help though. I copied the code from the
Tavily tool and adapted it heavily.
…On Tue, 9 Apr 2024, 06:30 Guangdong Liu, ***@***.***> wrote:
Try this
import requests
from langchain.tools import StructuredTool
def weather_lookup(location: str) -> str:
"""Find the weather of a location."""
r = requests.get(
'https://api.weatherapi.com/v1/current.json?q=' + location + '&key=redacted')
return r.json()
weather_tool = StructuredTool.from_function(
func=weather_lookup,
name="tool_weather_information",
description="""A tool designed to gather accurate information on weather around the globe.
Useful for when you need to answer questions about the weather.
Input should be the location.""",
handle_tool_error=True,
# coroutine= ... <- you can specify an async method if desired as well
)
print(weather_tool.run("London"))
—
Reply to this email directly, view it on GitHub
<#20175 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALK5WVEN4JDZZZWZQIHUQKTY4N4IZAVCNFSM6AAAAABF5HUVI6VHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TANJUGI4DI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
I can't since I used PyCharm to jump to source and I have heavily modified
it to my needs now. You just have to find a sample tool and use that for
future reference when making a tool.
…On Sun, 14 Apr 2024, 01:06 David uche, ***@***.***> wrote:
hey can you link the code from the Tavily tool here please?
—
Reply to this email directly, view it on GitHub
<#20175 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALK5WVD5E2LPEDCTSE66GQDY5HB7FAVCNFSM6AAAAABF5HUVI6VHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TCMBWGY2TS>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
Simply providing the input in the form of dict should work. |
Beta Was this translation helpful? Give feedback.
-
Deprecation warning:
Error:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Checked other resources
Commit to Help
Example Code
Description
I am trying to create a custom Weather tool and I get this error.
TypeError: BaseTool.call() missing 1 required positional argument: 'tool_input'
This is the code that adds the tool to the array.
System Info
System Information
Package Information
Packages not installed (Not Necessarily a Problem)
The following packages were not found:
Beta Was this translation helpful? Give feedback.
All reactions