google-gemini / generative-ai-js

The official Node.js / Typescript library for the Google Gemini API
https://www.npmjs.com/package/@google/generative-ai
Apache License 2.0
562 stars 105 forks source link

Support for minItems and maxItems for FunctionDeclarationSchemaType.ARRAY? #200

Open louislamlam opened 3 weeks ago

louislamlam commented 3 weeks ago

Description of the feature request:

choices: { type: FunctionDeclarationSchemaType.OBJECT, properties: { list: { type: FunctionDeclarationSchemaType.ARRAY, items: { type: FunctionDeclarationSchemaType.STRING, }, minItems: 1, maxItems: 3, }, }, required: ['list'], },

Error logged in Cloud console: Invalid JSON payload received. Unknown name "maxItems" at 'generation_config.response_schema.properties[1].value.properties[0].value': Cannot find field. [{"@type":"type.googleapis.com/google.rpc.BadRequest","fieldViolations":[{"field":"generation_config.response_schema.properties[0].value.properties[0].value","description":"Invalid JSON payload received. Unknown name \"minItems\" at 'generation_config.response_schema.properties[0].value.properties[0].value': Cannot find field."},{"field":"generation_config.response_schema.properties[0].value.properties[0].value","description":"Invalid JSON payload received. Unknown name \"maxItems\" at 'generation_config.response_schema.properties[0].value.properties[0].value': Cannot find field."}]}]

What problem are you trying to solve with this feature?

Allowing setting min and max length of return array is pretty useful for many cases.

Any other information you'd like to share?

No response

arvinxx commented 2 weeks ago

We meet the same issues:

our dalle plugin has a schema of maxItems and minItems, but Gemini's function calling currently does not support it. so it will cause an error