For a simple OpenAI api call in python
response = openai.ChatCompletion.create(
model="gpt-4",
messages=[
{"role": "system", "content": instructions},
{"role": "user", "content": my_input}
])
I get meaningful data in response['choices'][0]['message']['content']
Under what circumstances will there be multiple entries in response['choices']
? How should I interpret this?
From what I see, the documentation says that if you set the parameter n
to more than 1 you will get more than one "choice
".
https://platform.openai.com/docs/api-reference/chat/create
n integer or null Optional Defaults to 1
How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep n as 1 to minimize costs.
I don't know the concept behind naming it choices
, but I can tell you that the default is 1
, so you always will have to access index 0
from choices
unless you change the n
parameter.