```python
import json
import requests
# #存储所有对话内容
content_all = ''
# 定义一个函数,#发送请求并获取ChatGPT的响应
def get_chatgpt_response(prompt):
global content_all # 使用全局变量content_all
# ChatGPT API的URL
url = "https://token.w-l-h.yz/v1/chat/completions"
# 请求头,包括Authorization字段和Content-Type字段
headers = {
"Authorization": "Bearer sk-jZrpwYuqGZyGgF01c29001f7a4b48CbB61d2f3e3aF96943",
"Content-Type": "application/json"
}
# 请求体,包括模型名称、是否流式传输以及消息内容
data = {
"model": "gpt-3.5-turbo",
"stream": True,
"messages": "role": "user", "content": prompt,
}
# 发送POST请求到ChatGPT API,并获取响应
response = requests.post(url, headers=headers, json=data)
# 遍历响应的每一行
for line in response.iter_lines():
if line:
decoded_line = line.decode('utf-8')
# 如果响应中包含了'data: DONE