How to ‘stream’ output in ChatGPT style while using openAI Completion method

Avra
4 min readFeb 15, 2023

Live streaming of completion response wihle using openai.Completion.create method

👨🏾‍💻 GitHub ⭐️| 🐦 Twitter | 📹 YouTube | ☕️ BuyMeaCoffee | Ko-fi💜

Lol My face looks scary , in real-life not so . I code and chill and love cats :)

TLDR: In this article, we’ll explore how to build an AI assistant using Streamlit and OpenAI, and how to use the stream argument to change the mode of operation from batch to streaming.

Introduction

Streamlit is a web-based framework for building data-driven applications. It’s designed to be simple to use and requires minimal code, making it a great choice for building quick prototypes or small applications. On the other hand, OpenAI is a leading AI research institute that has developed some of the most advanced language models in the world. With OpenAI’s API, we can use its language models to generate natural language text, answer questions, and more.

In this example, we will use the OpenAI API to create a text completion model. Our AI assistant will take in a prompt, generate a response, and display the result in a live streaming format within our Streamlit front-end framework.

You can refer to the video as well, which will walk you through step-by-step

--

--

Avra

Community Lead, Databutton. Biophysics, PhD Candidate