You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I added a very descriptive title to this question.
I searched the LangChain documentation with the integrated search.
I used the GitHub search to find a similar question and didn't find it.
Commit to Help
I commit to help with one of those options 👆
Example Code
fromlangchainimporthubfromlangchain.agentsimportcreate_tool_calling_agent, AgentExecutorfromlangchain.toolsimportBingSearchResultsimportosbing_search=BingSearchResults(api_key=os.getenv("BING_KEY"))
tools= [bing_search]
fromlangchain_openaiimportChatOpenAImodel=ChatOpenAI(model="gpt-4")
prompt="""You are an agent that finds the country for a list of 50 random cities. You will run a separate Bing search query to find the country for each city in the list.Here is the list of cities:Tokyo, New York, Paris, London, Berlin, Sydney, Moscow, Beijing, Rio de Janeiro, Cairo,Mumbai, Los Angeles, Buenos Aires, Rome, Istanbul, Toronto, Mexico City, Jakarta, Seoul, Lagos,Bangkok, Madrid, Kuala Lumpur, Nairobi, Lima, Tehran, Baghdad, Dhaka, Karachi, Santiago,Singapore, Hong Kong, Dubai, Riyadh, Cape Town, Hanoi, Athens, Vienna, Warsaw, Budapest,Prague, Brussels, Zurich, Stockholm, Oslo, Helsinki, Copenhagen, Dublin, Lisbon."""agent=create_tool_calling_agent(model, tools, prompt)
agent_executor=AgentExecutor(agent=agent, tools=tools, max_iterations=5)
response=agent_executor.invoke({"input": "Find the country for the list of cities provided."})
print(response["output"])
Description
We observed a similar query to the one above and saw that despite the max_iterations on the AgentExecutor we saw 50 invocations of the BingSearchResults tool. This causes huge load spikes on related services. We want to limit the amount of times a tool can be called by the Executor.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Checked other resources
Commit to Help
Example Code
Description
We observed a similar query to the one above and saw that despite the
max_iterations
on the AgentExecutor we saw 50 invocations of the BingSearchResults tool. This causes huge load spikes on related services. We want to limit the amount of times a tool can be called by the Executor.System Info
Beta Was this translation helpful? Give feedback.
All reactions