Getting lists and dictionaries from my function call in the openai api

513 views Asked by At

While working with the ChatGPT api, I want to make function calls. Below is one of my functions:

{
 "name": "set_absolute_parameter_values_for_component",
 "example": "Change the margin to ‘comfortable’.",
 "description": "Set specific values for parameters of a single component in the specified card(s). "+
 "This function applies absolute changes. Note: the 'Content' component cannot contain text, but 'Info' can hold text."+
 "Call this function if both a relative and an absolute term are used.",
 "parameters": {
     "type": "object",
     "properties": {
         "to_card_list": {
         "type": "string",
         "description": "A list with card names that the user wants to update. If ",
         "enum" : CARD_INFO['cards'],
         },
        "component_list": {
            "type": "string",
            "description": "A list with the component that the user wants to update. Note: the 'Content' component can NOT contain text.",
            "enum" : CARD_INFO['component_list'],
            },
        "parameter_dict": {
            "type": "string",
            "description": "A dictionary mapping parameters to their desired values.",
            "enum" : list(CARD_INFO['all_parameters']),
            },
        }
     }
 },

As the names for the parameters suggest, I want to get two lists and a dictionary. Sometimes ChatGPT (both 3.5 turbo and 4) returns the correct format, whereas it returns the wrong format, too, at times. I get an error when I change the types to ‘list’ and ‘dict’. Based on suggestions, I tried changing it to ‘array’ and ‘object’, which also resulted in errors.

Is it possible to set the type to lists and dicts?

0

There are 0 answers