mirror of
https://github.com/langchain-ai/langchain.git
synced 2026-10-05 01:15:09 +03:00
This patch updates function "run" to "invoke" in fake_llm.ipynb. Without this patch, you see following warning. LangChainDeprecationWarning: The function `run` was deprecated in LangChain 0.1.0 and will be removed in 0.2.0. Use invoke instead. Signed-off-by: Masanari Iida <standby24x7@gmail.com>
2.9 KiB
2.9 KiB
In [1]:
from langchain_community.llms.fake import FakeListLLMIn [2]:
from langchain.agents import AgentType, initialize_agent, load_toolsIn [3]:
tools = load_tools(["python_repl"])In [16]:
responses = ["Action: Python REPL\nAction Input: print(2 + 2)", "Final Answer: 4"]
llm = FakeListLLM(responses=responses)In [17]:
agent = initialize_agent(
tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True
)In [18]:
agent.invoke("whats 2 + 2")Out [18]:
[1m> Entering new AgentExecutor chain...[0m [32;1m[1;3mAction: Python REPL Action Input: print(2 + 2)[0m Observation: [36;1m[1;3m4 [0m Thought:[32;1m[1;3mFinal Answer: 4[0m [1m> Finished chain.[0m
'4'
In [ ]: