Replies: 1 comment
-
Yes, you need to call Here's an example to illustrate this: # Create the agent
memory = SqliteSaver.from_conn_string(":memory:")
model = ChatAnthropic(model_name="claude-3-sonnet-20240229")
search = TavilySearchResults(max_results=2)
tools = [search]
agent = create_react_agent(model, tools, checkpointer=memory)
agent_executor = AgentExecutor(agent=agent, tools=tools)
# Use the agent
config = {"configurable": {"thread_id": "abc123"}}
for chunk in agent_executor.stream(
{"messages": [HumanMessage(content="hi im bob! and i live in sf")]}, config
):
print(chunk)
print("----")
for chunk in agent_executor.stream(
{"messages": [HumanMessage(content="whats the weather where I live?")]}, config
):
print(chunk)
print("----") In this code, Additionally, the LangChain documentation provides an example of using |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Checked other resources
Commit to Help
Example Code
Description
@dosu,
Do I need to call AgentExecutor?
agent = create_react_agent(llm, tools, prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
Or not?
react_agent = create_react_agent(model=llm_with_tools, tools=tools, messages_modifier=prompt, checkpointer=memory)
inputs = {"messages": [HumanMessage(content=self.contexto["input"])]}
config={"configurable": {"thread_id": "1"}}
result = await react_agent.ainvoke(inputs, config=config, debug=True)
Thank you!
System Info
langchain==0.2.6
langchain-community==0.2.6
langchain-core==0.2.10
langchain-experimental==0.0.62
langchain-openai==0.1.13
langchain-qdrant==0.1.0
langchain-text-splitters==0.2.1
Beta Was this translation helpful? Give feedback.
All reactions