我正在尝试使用 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:提供了无法识别的请求参数:信息
我试着在“回应”中给模型“对话”,但似乎不起作用。
1条答案
按热度按时间bq3bfh9z1#
您在聊天完成和完成之间出错。参见文档。
完成:https://platform.openai.com/docs/api-reference/completions/create
聊天完成:https://platform.openai.com/docs/api-reference/chat/create