+
95
-

python如何流式输出chatgpt api接口的回答数据?

python如何流式输出chatgpt api接口的回答数据?

completion = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=msg)


网友回复

+
15
-
import openai
import time
openai.api_key = "APIkey"


### STREAM CHATGPT API RESPONSES
delay_time = 0.01 #  faster
max_response_length = 200
answer = ''
# ASK QUESTION
prompt = input("Ask a question: ")
start_time = time.time()

response = openai.ChatCompletion.create(
    # CHATPG GPT API REQQUEST...

点击查看剩余70%

我知道答案,我要回答