Find answers from the community

Updated last year

I cant seem to get streaming working

I cant seem to get streaming working with the OpenAIAgent chat.

Simple example

Plain Text
resp = agent.stream_chat("My name is Jordan")

for part in resp.chat_stream:
    print(part)


It recognises that its a generator but it doesn't loop and print anything... If I print the resp it returns the output...
L
W
8 comments
I thiiiink you have a typo?

Plain Text
resp = agent.stream_chat("My name is Jordan")

for part in resp.response_gen:
    print(part, end="", flush=True)
You are a wizzard harry!
How would I stream events from the agent. E.g. each tool start stop or action start stop? Do i need to build my own callback handler?
E.g.

{ "event": "agent_action", "value": "search"}
{ "event": "llm_token", "value", "hello" }
{ "event": "agent_output": "value": "hello"}
{ "event": "agent_action", value": "final_answer" }
{ "event": "agent_output": "value": "hello"}
The goal being to show in the UI each agent action that happens
Kind of want each step of the subquestion query engine to yeild an agent output or some event back to the UI as well
Yea it would have to be a custom callback handler πŸ€”
Add a reply
Sign up and join the conversation on Discord