Reputation: 23
I am trying to train GPT 3.5 model with few-shot prompting using messages argument instead of prompt argument. It throws an error even though it's clearly mentioned in OpenAI documentation that we can train a model this way.
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()
Error:
openai.error.InvalidRequestError: Unrecognized request argument supplied: messages
I tried to give "conversations" to the model inside "responses" but it soesn't seem to work.
Upvotes: 0
Views: 602
Reputation: 721
You made a mistake between chat completion and completion. See documentation.
completion: https://platform.openai.com/docs/api-reference/completions/create
chat completion: https://platform.openai.com/docs/api-reference/chat/create
Upvotes: 0