# Function Call - Nested Objects in array as parameters

**URL:** <https://community.openai.com/t/function-call-nested-objects-in-array-as-parameters/709880>\
**Category:** API\
**Tags:** gpt-4, function-calling\
**Created:** [April 7, 2024, 10:43am UTC](https://community.openai.com/t/function-call-nested-objects-in-array-as-parameters/709880 "2024-04-07T10:43:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![voice10](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/voice10/32/146662_2.png) [@voice10](https://community.openai.com/u/voice10)\
**Post date:** [April 7, 2024, 10:43am UTC](https://community.openai.com/t/function-call-nested-objects-in-array-as-parameters/709880/1 "2024-04-07T10:43:18Z")

</div>

Hi  
the following function works with this prompt “Find the location for the following addresses: 123 Main Street, Anytown, Ontario Canada, 456 Second Street, Anytown, Ontario”  
(thanks @dlaytonj2 )

functions=[

```auto
{
      "name": "get_coordinates",
      "description": "Get the latitude and longitude of multiple mailing addresses",
      "parameters": {
          "type": "object",
          "properties": {
              "addresses": {
                  "type": "array",
                  "description": "The mailing addresses to be located",
                  "items": {
                      "type": "string"
                  }
              }
          },
          "required": ["addresses"]
      }
    }
]

```

but this function does not  
functions =

```auto
 {
        "name": "get_weather", 
        "description": "Get weather from given locations and datetimes", 
        "parameters": {
            "type": "object", 
            "properties": {
                "locations": {
                    "type": "array", 
                    "description": "The locations for which to get weather information",
                    "items": {
                        "type": "object",
                        "properties": {
                            "name": { 
                                "type": "string", 
                                "description": "Name of location, e.g. San Francisco, CA" 
                            },
                            "datetime": { 
                                "type": "string", 
                                "description": "Date or time, e.g. today, tomorrow, 2023-06-29" 
                            },
                        }
                    }
                }
            }, 
            "required": ['locations']
        }
 }

```

I used prompt: “Today What’s the weather like in Boston, and what’s the weather in Houston?”

I get this error : `"Error code: 400 - {'error': {'message': "'name' is not of type 'object' - 'functions.0'", 'type': 'invalid_request_error', 'param': None, 'code': None}}`  
It seems model can’t parse nested objects.  
any help would be highly apprecisted. thanks a lot!

---

<div class="post-metadata">

**Author:** ![\_j](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/_j/32/766292_2.png) [@\_j](https://community.openai.com/u/_j)\
**Post date:** [April 7, 2024, 11:10am UTC](https://community.openai.com/t/function-call-nested-objects-in-array-as-parameters/709880/2 "2024-04-07T11:10:53Z")

</div>

When using functions, objects within objects receive no descriptions, even though they are not blocked. They are also not flagged as optional. This means the AI has nothing except the name by which to figure out what they are for.

Your fault, however, seems to be in using a special “name” property incorrectly.

Here is the basic form for a nested function, with the warning of unpassed description:

```auto
functions = [
{
    "name": "data_demonstration",
    "description": "This is the main function description",
    "parameters": {
        "type": "object",
        "properties": {
            "object_1": {
                "type": "object",
                "description": "The object data type as a property",
                "properties": {
                "string_2a": {
                    "type": "string",
                    "enum": ["Happy", "Sad"]
                    },
                "string_2b": {
                    "type": "string",
                    "description": "Description in a second object is lost"
                    },
                },
            },
            "string_1": {"type": "string",
                         "description": "Not required gets a question mark"},
        },
        "required": ["object_1","placeholder_2"]
    }
}
]

```
