google / generative-ai-docs

Documentation for Google's Gen AI site - including the Gemini API and Gemma
https://ai.google.dev
Apache License 2.0
1.46k stars 494 forks source link

Gemini rejects tool JSON schema with array of types #444

Closed ianb closed 4 days ago

ianb commented 1 month ago

Description of the bug:

I have a tool in my prompt that looks like this (abbreviated):

{
    "name": "describeProblem",
    "description": "Describe the problem in simpler terms for future analysis",
    "parameters": {
        "type": "object",
        "required": [
            "correctAnswerFields"
        ],
        "properties": {
            "correctAnswerFields": {
                "type": [
                    "string",
                    "array"
                ],
                "description": "Format it as a list of fields"
            }
        }
    }
}

I get an error like this:

Invalid JSON payload received. Unknown name \"type\" at 'tools[0].function_declarations[0].parameters.properties[2].value': Proto field is not repeating, cannot start list.", "status": "INVALID_ARGUMENT", "details": [ { "@type": "type.googleapis.com/google.rpc.BadRequest", "fieldViolations": [ { "field": "tools[0].function_declarations[0].parameters.properties[2].value", "description": "Invalid JSON payload received. Unknown name \"type\" at 'tools[0].function_declarations[0].parameters.properties[2].value': Proto field is not repeating, cannot start list." } ] } ] } } ]

A JSON schema is allowed to have an array of type. Both Gemini Flash and 1.5 behave the same way.

Actual vs expected behavior:

Actual behavior: returns error

Expected behavior: respects JSON schema

singhniraj08 commented 1 month ago

@ianb, Thank you reporting this issue. This repository is for issues related to website(https://ai.google.dev/) like documentation bugs or improvements. For issues related to Gemini, we would suggest you to use "Send Feedback" option in Gemini docs. Ref: Screenshot below. You can also post this issue on Discourse forum.

image

github-actions[bot] commented 2 weeks ago

Marking this issue as stale since it has been open for 14 days with no activity. This issue will be closed if no further activity occurs.

github-actions[bot] commented 4 days ago

This issue was closed because it has been inactive for 28 days. Please post a new issue if you need further assistance. Thanks!