System Info
langchain==0.0.232
Google Colab
Who can help?
No response
Information
Related Components
Reproduction
def get_current_oil_price():
ticker_data = yf.Ticker("CL=F")
recent = ticker_data.history(period='1d')
return {"price": recent.iloc[0]["Close"], "currency": ticker_data.info["currency"]}
def get_oil_price_performance(days):
past_date = datetime.today() - timedelta(days=int(days))
ticker_data = yf.Ticker("CL=F")
history = ticker_data.history(start=past_date)
old_price = history.iloc[0]["Close"]
current_price = history.iloc[-1]["Close"]
return {"percent_change": ((current_price - old_price) / old_price) * 100}
class CurrentOilPriceTool(BaseTool):
name = "get_oil_price"
description = "Get the current oil price. No parameter needed from input"
def _run(self):
price_response = get_current_oil_price()
return price_response
def _arun(self):
raise NotImplementedError("get_oil_price does not support async")
class CurrentOilPerformanceTool(BaseTool):
name = "get_oil_performance"
description = "Get the current oil price evolution over a given number of days. Enter the number of days."
def _run(self, days):
performance_response = get_oil_price_performance(days)
return performance_response
def _arun(self):
raise NotImplementedError("get_oil_performance does not support async")
llm = ChatOpenAI(model="gpt-3.5-turbo-0613", temperature=0)
tools = [CurrentOilPriceTool(), CurrentOilPerformanceTool()]
agent = initialize_agent(
tools=tools,
llm=llm,
agent=AgentType.OPENAI_FUNCTIONS,
verbose=True
)
agent.run("What is the oil price?")
Expected behavior
> Entering new AgentExecutor chain...
Invoking: `get_oil_price`
But instead, the executor insists on adding a parameter to the tool function !!!
> Entering new AgentExecutor chain...
Invoking: `get_oil_price` with `USD`
provoking an obvious error:
TypeError: CurrentOilPriceTool._run() takes 1 positional argument but 2 were given
System Info
langchain==0.0.232
Google Colab
Who can help?
No response
Information
Related Components
Reproduction
agent.run("What is the oil price?")Expected behavior
But instead, the executor insists on adding a parameter to the tool function !!!
provoking an obvious error:
TypeError: CurrentOilPriceTool._run() takes 1 positional argument but 2 were given