Skip to content

Instantly share code, notes, and snippets.

@mme
mme / server.py
Last active January 30, 2024 17:16
# Adapted from: https://github.com/anshumankmr/Streaming-ChatGPT-Responses-in-ReactJS/blob/main/server/app.py
# See also: https://stackoverflow.com/questions/76311866/unable-to-send-openai-stream-response-via-flask-api
# Write a simple flask app with one route to return an response from OpenAI's Gpt3.5 turbo model using the completions API
from flask import Flask, Response, stream_with_context, request
import os
import openai
import requests
from flask_cors import CORS

Keybase proof

I hereby claim:

  • I am mme on github.
  • I am mme_ (https://keybase.io/mme_) on keybase.
  • I have a public key ASCQWgL43yHaNDp5DwuUeixvw0K02NXCkxKHvPe_HDaEJAo

To claim this, I am signing this object: