generative-ai-docs icon indicating copy to clipboard operation
generative-ai-docs copied to clipboard

Function schemas don't allow maxItems/minItems

Open ianb opened this issue 1 year ago • 1 comments

Description of the bug:

Using the Gemini Pro API, If you have a function definition like this:

{
  name: "myFunction",
  parameters: {
    type: "object",
    properties: {
      choices: {
        type: "array",
        minItems: 5,
        maxItems: 5,
        items: {type: "string"}
      }
    }
  }
}

the API will return an error about minItems and maxItems like:

Invalid JSON payload received. Unknown name "maxItems" at 'tools[0].function_declarations[0].parameters.properties[0].value': Cannot find field.
Invalid JSON payload received. Unknown name "minItems" at 'tools[0].function_declarations[0].parameters.properties[0].value': Cannot find field.

Actual vs expected behavior:

It should accept the maxItems/minItems properties, which are part of JSON/OpenAPI schemas.

ianb avatar Dec 31 '23 02:12 ianb

The proto that defined the API is here, and yes, this is clearly not currently supported.

https://github.com/googleapis/googleapis/blob/master/google/ai/generativelanguage/v1beta/content.proto#L186-L216

MarkDaoust avatar Jan 11 '24 18:01 MarkDaoust