How to use streaming in Django framework and pass response to UI(Assistants API)

I am using Django framework and want to pass the streaming response to UI(client side Html Page).
Is it possible to pass streaming response in to UI. Or do i need to change the framework.
Reference:
https://platform.openai.com/docs/assistants/overview?context=with-streaming

Please help me on the topic.

1 Like

As far as i can tell you can use the python SDK runs.create as shown in the API reference: https://platform.openai.com/docs/api-reference/runs/createRun
DeepinScreenshot_select-area_20240322090907.

You need to create a iterator for the stream events and pass that iterator to the front-end using the StreamingHttpResponse . By looking at the source code, I think you can’t interrupt the streaming using the runs.create_and_stream method.

2 Likes

thanks for contributing, In StreamingHttpResponse , I am getting all the responses together, and not like word/line wise.