-
Notifications
You must be signed in to change notification settings - Fork 72
Open
Description
I am using langgraph stream_events
and inside tools i am using cohere.
from langgraph.prebuilt import create_react_agent
async def generate_stream_response(message: str, user: dict, prompt_dict: dict):
tools = [search_for_australia, search_for_newzealand]
langgraph_agent_executor = create_react_agent(
llm,
tools=tools,
state_modifier=None,
checkpointer=memory
)
config = {"configurable": {"thread_id": prompt_dict['group_id']}}
prompt = {"messages": [{"role": "user", "content": message}]}
async for event in langgraph_agent_executor.astream_events(prompt, config, stream_mode="values", version="v2"):
print(event)
I can not yeild response from tools.
@tool
def search_for_australia(query: str):
"""Searches Australia for relevant information"""
documents = query_faiss(faiss_index, query, model, texts)
llm_response_stream = co.chat_stream(
messages=[{"role": "user", "content": query}],
documents=documents,
model="command-r-plus-08-2024",
temperature=0.4
)
for event in llm_response_stream:
if event:
if event.type == "content-delta":
print(event.delta.message.content.text)
But, can print like above. And If I co.chat
and return response the data the it works. But, it's not a solution, cause it's return all data at a time and langgraph_agent_executor.astream_events
is waiting until get the response.
Note: I can not show the citations also.
Metadata
Metadata
Assignees
Labels
No labels