1. 调用gpt-3.5的语句
由
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "你是一个自然语言处理模型,用于完成xx任务"},
{"role": "user", "content": content}
],
temperature=0.1
)
改为
response = openai.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "你是一个自然语言处理模型,用于完成x任务"},
{"role": "user", "content": content}
],
temperature=0.1
)
2.获取输出的语句
return response["choices"][0]["message"]["content"]
改为
return response.choices[0].message.content
3. 搜集报错的语句
except openai.error.APIConnectionError as error:
print(error)
改为
except openai.APIConnectionError as error:
print(error)
欢迎评论留言补充