使用gpt 3.5时出现“少拍”提示错误

c90pui9n  于 2023-06-24  发布在  其他
关注(0)|答案(1)|浏览(190)

我正在尝试使用 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:提供了无法识别的请求参数:信息
我试着在“回应”中给模型“对话”,但似乎不起作用。

相关问题