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

Support for minItems and maxItems for FunctionDeclarationSchemaType.ARRAY?

Open louislamlam opened this issue 1 year ago • 1 comments

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

louislamlam avatar Jul 03 '24 23:07 louislamlam

We meet the same issues:

  • https://github.com/lobehub/lobe-chat/issues/2847
  • https://github.com/lobehub/lobe-chat/issues/2537

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

arvinxx avatar Jul 07 '24 10:07 arvinxx