You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Best practices for function declarations
...
properties > type: Use strongly typed parameters to reduce model hallucinations. For example, if the parameter values are from a finite set, use an enum field instead of listing the values in the description (e.g., "type": "enum", "values": ["now_playing", "upcoming"]). If the parameter value is always an integer, set the type to integer rather than number.
...
However, using the "enum" type with a values array sent, results in errors. Error: [GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp:streamGenerateContent?alt=sse: [400 Bad Request] Invalid value at 'tools.function_declarations[1].parameters.properties[1].value.type' (type.googleapis.com/google.ai.generativelanguage.v1beta.Type), "enum"
Invalid value at 'tools.function_declarations[2].parameters.properties[1].value.type' (type.googleapis.com/google.ai.generativelanguage.v1beta.Type), "enum" Invalid JSON payload received. Unknown name "values" at 'tools.function_declarations[2].parameters.properties[1].value': Cannot find field.
The text was updated successfully, but these errors were encountered:
Description of the bug:
According to the documentation at https://ai.google.dev/gemini-api/docs/function-calling
Best practices for function declarations
...
properties > type: Use strongly typed parameters to reduce model hallucinations. For example, if the parameter values are from a finite set, use an enum field instead of listing the values in the description (e.g., "type": "enum", "values": ["now_playing", "upcoming"]). If the parameter value is always an integer, set the type to integer rather than number.
...
However, using the "enum" type with a values array sent, results in errors.
Error: [GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp:streamGenerateContent?alt=sse: [400 Bad Request] Invalid value at 'tools.function_declarations[1].parameters.properties[1].value.type' (type.googleapis.com/google.ai.generativelanguage.v1beta.Type), "enum"
Invalid value at 'tools.function_declarations[2].parameters.properties[1].value.type' (type.googleapis.com/google.ai.generativelanguage.v1beta.Type), "enum"
Invalid JSON payload received. Unknown name "values" at 'tools.function_declarations[2].parameters.properties[1].value': Cannot find field.
The text was updated successfully, but these errors were encountered: