数据处理代码,为了生成chatgpt数据
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
999 B

2 years ago
import requests
import json
with open("api_key.txt", "r",) as f:
a = f.read()
a = a.split("\n")
api_key_list = []
for i in a:
api_key_list.append(str(i.split("----")[-1]))
for i in api_key_list:
OPENAI_API_KEY = i
url = "https://api.openai.com/v1/chat/completions"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {OPENAI_API_KEY}"
}
data = {
"model": "gpt-3.5-turbo",
"messages": [
{"role": "user", "content": "请帮我根据题目为“初中英语写作教学的现状分析及应对策略”生成一个论文目录其中只含有一级标题和二级标题"},
],
"temperature": 0.7
}
response = requests.post(url,
headers=headers,
data=json.dumps(data),
timeout=240)
res = response.json()
print(res)
print(res["choices"][0]["message"]["content"])