How to implement the printing effect for GPT-3.5?

Hello everyone. Someone implemented the printing effect in GPT-3.5, can you tell me how you did it or what methods you used for this?

Welcome to the community @cf6oz70e

If you’re referring to streaming.

Here’s how you can do it in python:

for line in openai.ChatCompletion.create(model="gpt-3.5-turbo",
                                             messages=conversation,
                                             max_tokens=100,
                                             stream=True):
    token = getattr(line.choices[0].delta, "content", "")
    print(token, end="")