Terminal-stream isn't transmitted live to locally hosted website

Dear Community,

I created a Python-Django-Anthropic-Websocket-streaming Projects. Therefore I used the frame of a chatbot, which can be opened on your local website (, to test the functionality.

You can chat with the Bot very well. Before the response is transmitted to the local website, it is streamed in the terminal and afterwards streamed on the local website.

My aim is to stream the terminal-output simultaneously on the local website while it gets created.

I already implemented websocket for this kind of functionality. Furthermore I integrated Anthropic Asnyc functions (decalaration therefore in: consumers.py).

Right now the output gets streamed in the terminal, but not simultaneously on the local website, but time shifted.

Here is a link to the Github repository: GitHub - oelpisvandergossau56/Django-anthropic-websocket-stream

Can anyone help me regarding implementing the right functions for my aimed result?