The v0.2 upgrade broke a lot of people's agents. Here's what actually changed:
The biggest thing — AgentExecutor isn't the default anymore
from langchain.agents import initialize_agent, AgentType
agent = initialize_agent(
tools=tools,
llm=llm,
agent=AgentType.OPENAI_FUNCTIONS,
verbose=True
)
agent.run("What's the weather in Delhi?")
In the new version ,initialize_agent this function is deprecated. The new way uses LCEL
from langchain import hub
from langchain.agents import create_openai_functions_agent, AgentExecutor
prompt = hub.pull("hwchase17/openai-functions-agent")
agent = create_openai_functions_agent(llm, tools, prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
agent_executor.invoke({"input": "What's the weather in Delhi?"})