Python and Javascript code to stream responses with Flask, ChatGPT and (partially) Langchain. Perhaps it's too messy (sorry), but you get the idea.
If you want to run this on a server with Gunicorn and Nginx, go to /etc/nginx/sites-available/<FlaskGPT>
and set proxy_buffering off
:
location / {
proxy_buffering off;
}
Big thank you to oneryalcin and python273 for their ideas. Shout out to David Richards.