Oct. 2, 2023, 6:13 a.m. | quandale dingle

DEV Community dev.to

I'm trying to make a chatbot website. I want the ai's response to be sent chunk by chunk as soon as the chunk is processed, but the output message is being sent all at once on my website.

In the terminal, I made it so that the response gets outputted as soon as each chunk is processed, and it worked for the terminal using this code:



print(chunk_message['content'], end='', flush=True)


But I can't figure out how to make it send as …

api chatbot django html openai openai api python terminal webdev website

Data Architect

@ University of Texas at Austin | Austin, TX

Data ETL Engineer

@ University of Texas at Austin | Austin, TX

Lead GNSS Data Scientist

@ Lurra Systems | Melbourne

Senior Machine Learning Engineer (MLOps)

@ Promaton | Remote, Europe

Software Engineering Manager, Generative AI - Characters

@ Meta | Bellevue, WA | Menlo Park, CA | Seattle, WA | New York City | San Francisco, CA

Senior Operations Research Analyst / Predictive Modeler

@ LinQuest | Colorado Springs, Colorado, United States