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.

34 lines
816 B

import requests
import json
prompt = "请帮我根据题目为“{}”生成一个论文目录只含有一级目录和二级目录".format("煤业集团水文监测系统建设项目设计与实现")
OPENAI_API_KEY = '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'
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": prompt},
],
"temperature": 0.7
}
response = requests.post(url,
headers=headers,
data=json.dumps(data),
timeout=1000)
res = response.json()
print(res)
print(res["choices"][0]["message"]["content"])