Assume my company provides meals subscription service . I described the following functions to gpt-3.5.
By specifying "unit": {"type": "string", "enum": ["meals", "days"]}
, I intent to force the ChatCompletion model returned parameter “unit” to be “meals” or “days”.
functions = [
{
"name": "summarize_order",
"description": "Summarize the customer order request",
"parameters": {
"type": "object",
"properties": {
"product_name": {
"type": "string",
"description": "Product name ordered by customer",
},
"quantity": {
"type": "integer",
"description": "Quantity ordered by customer",
},
"unit": {
"type": "string",
"enum": ["meals", "days"],
"description": "unit of measurement of the customer order"
},
},
"required": ["product_name","quantity", "unit"],
},
}
]
def get_completion_from_messages(messages,
functions,
model="gpt-3.5-turbo-0613",
temperature=0,
max_tokens=500):
response = openai.ChatCompletion.create(
model=model,
messages=messages,
temperature=temperature,
max_tokens=max_tokens,
functions=functions,
function_call={"name": "summarize_order"},
)
return response["choices"][0]["message"]
If a customer says: “I’d like to order the keto meal for 2 months”, it should return-
{‘product_name’: ‘keto meal’,
‘quantity’: 60,
‘unit’: ‘days’}
However, gpt-3.5-turbo-0613
still returns
{‘product_name’: ‘keto meal’,
‘quantity’: 2,
‘unit’: ‘months’}
How can I force the output parameter “unit” to be “meals” or “days”?