Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot stream response from cohere #592

Open
hizbul-inument opened this issue Oct 15, 2024 · 0 comments
Open

Cannot stream response from cohere #592

hizbul-inument opened this issue Oct 15, 2024 · 0 comments

Comments

@hizbul-inument
Copy link

hizbul-inument commented Oct 15, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant