-
Notifications
You must be signed in to change notification settings - Fork 72
Description
I am using langchain and cohere. It works fine whenever i used invoke with agent executor, but whenever i moved for streaming and using astream_events i got extra data along with the response. Following is my sample code and response.
agent = create_cohere_react_agent(
llm=llm,
tools=tools,
prompt=prompt
)
agent_executor = AgentExecutor(agent=agent, tools=[search_1, search_2], verbose=True)
# Get Response
async for event in agent_executor.astream_events({
"preamble": session_data["initial_prompt"],
}, version="v2", exclude_names=["Plan", "Action", "Relevant Documents", "Cited Documents"]):
if event["event"] == "on_chat_model_stream":
chunk_content = serialize_aimessagechunk(event["data"]["chunk"])
chunk_content_html = chunk_content.replace("\n", "<br>")
yield f"data: {json.dumps({'event': 'stream', 'data': chunk_content_html})}\n\n"
I am getting following response:
Plan: I will greet the user and ask for their name and location, then tailor my response accordingly. Action:
json [ { "tool_name": "directly_answer", "parameters": {} } ]
Relevant Documents: None Cited Documents: None Answer: Hi! It's lovely to hear from you. What's your name, and are you based in Australia or New Zealand? Grounded answer: Hi! It's lovely to hear from you. What's your name, and are you based in Australia or New Zealand?
https://docs.cohere.com/v2/docs/implementing-a-multi-step-agent-with-langchain i found multi step agent log should be like my response.