gpt4 book ai didi

chatbot - 使用 gpt 3.5 时出现 Few-shot 提示错误

转载 作者:行者123 更新时间:2023-12-02 05:49:21 25 4
gpt4 key购买 nike

我正在尝试使用 messages 参数而不是 prompt 参数来训练带有少量提示的 GPT 3.5 模型。尽管 OpenAI 文档中明确提到我们可以通过这种方式训练模型,但它还是会抛出错误。

import openai

conversation=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who won the world series in 2020?"},
{"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."},
]

def askGPT(question):
conversation.append({"role": "user", "content": question})
openai.api_key = "openai key"
response = openai.Completion.create(
model = "gpt-3.5-turbo",
messages = conversation,
temperature = 0.6
#max_tokens = 150,
)
#conversation.append({"role": "assistant","content":response})
#print(response)
#print(response["choices"][0]["message"]["content"])


conversation.append({"role": "assistant", "content": response.choices[0].message.content})
print(response.choices[0].message.content)

def main():
while True:
print('GPT: Ask me a question\n')
myQn = input()
askGPT(myQn)
print('\n')


main()

错误:

openai.error.InvalidRequestError: Unrecognized request argument supplied: messages

我尝试在“响应”内向模型提供“对话”,但它似乎不起作用。

最佳答案

您在聊天完成完成之间犯了一个错误。请参阅文档。

完成:https://platform.openai.com/docs/api-reference/completions/create

聊天完成:https://platform.openai.com/docs/api-reference/chat/create

关于chatbot - 使用 gpt 3.5 时出现 Few-shot 提示错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76502113/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com