【发布时间】:2022-12-07 11:27:32
【问题描述】:
我正在玩弄 openAi API,我正在尝试继续对话。例如:
import openai
openai.api_key = mykey
prompt= "write me a haiku"
response = openai.Completion.create(engine="text-davinci-001",prompt=prompt
,max_tokens=50)
print(response)
这将生成以下格式的俳句:
{
"choices": [
{
"finish_reason": "stop",
"index": 0,
"logprobs": null,
"text": "\n\n\n\nThis world is\nfull of wonders\nSo much to see and do"
}
],
"created": 1670379922,
"id": "cmpl-6KePalYQFhm1cXmwOOJdyKiygSMUq",
"model": "text-davinci-001",
"object": "text_completion",
"usage": {
"completion_tokens": 17,
"prompt_tokens": 5,
"total_tokens": 22
}
}
这很好,但是,如果我现在想要求 openai “给我写另一个”怎么办?如果我使用 openai playground chat 或 chatGPT,我可以继续对话。我想通过我的 python 脚本来做到这一点。我注意到我收到了 id 作为回应。我可以用它来继续我的谈话吗?
提前致谢!
【问题讨论】: