Function with integer enum stopped working properly on openai api with gpt-3.5-turbo-0613

Still works on azure though.


data='{"messages": [{"role": "user", "content": "...\\n---------------------\\nUsing only the choices defined in the schema and not prior knowledge, generate\\nthe selection object and reason that is most relevant to the\\nquestion: \'Who is Emma?\'\\n"}], "stream": false, "model": "gpt-3.5-turbo-0613", "temperature": 0.0, "max_tokens": 384, "functions": [{"name": "ToolSelection", "description": "A single selection of a choice.", "parameters": {"title": "ToolSelection", "description": "A single selection of a choice.", "type": "object", "properties": {"index": {"description": "Index of selected tool.\\nWhere:\\n(0) \\n    Use this tool bla bla\\n\\n(1) \\n    Use this tool to bla bla.\\n\\n(2) \\n    If the question is not related to the movie described above, always return this choice!\\n    Use this tool to answer questions which are not related to the bla bla\\n\\n", "allOf": [{"$ref": "#/definitions/ToolEnum"}]}, "reason": {"title": "Reason", "type": "string"}}, "required": ["index", "reason"], "definitions": {"ToolEnum": {"title": "ToolEnum", "description": "Enum for query engine tools.", "enum": [0, 1, 2], "type": "integer"}}}}], "function_call": {"name": "ToolSelection"}}' message='Post details'

The response has string instead of integer as index

{'function_call': <OpenAIObject at 0x7f9bfc2db0b0> JSON: {
  "name": "ToolSelection",
  "arguments": "{\n  \"index\": \"1\",\n  \"reason\": \"The question is asking about a character in the movie\"\n}"
1 Like

you might want to add a “type”: “number” to the index property.
also, I normally write enums like this:

"index": {
    "description":"Integer index of ...",
    "type": "number",
    "enum": [1,2,3,4,5],