Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Response Schema with list in gemini 2.0 #388

Open
nicornejo opened this issue Dec 27, 2024 · 1 comment
Open

Response Schema with list in gemini 2.0 #388

nicornejo opened this issue Dec 27, 2024 · 1 comment
Assignees
Labels
type:bug Something isn't working

Comments

@nicornejo
Copy link
Contributor

nicornejo commented Dec 27, 2024

Description of the bug:

In the example notebook provided in get_started.ipynb of gemini-2, there is a code snippet demonstrating controlled JSON generation. The prompt requests “List 3 popular cookie recipes and their ingredients.” However, the response_schema in the example is defined as Recipe, which is designed to return only a single object.

When I attempt to modify the response_schema to list[Recipe] or List[Recipe] (to align with the prompt’s intent to output three recipes), it results in the following error:

AttributeError: 'dict' object has no attribute 'upper'

This suggests that the SDK does not properly handle list-based schemas or that the example is misleading.

Actual vs expected behavior:

Actual behavior:
• The example, as written, outputs only one recipe, even though the prompt requests three.
• Modifying the response_schema to handle a list of recipes results in an error.

Expected behavior:
• The example should correctly define the response_schema to allow the generation of multiple recipes.
• The SDK should support list-based schemas (list[Recipe] or List[Recipe]) without throwing errors.

Any other information you'd like to share?

No response

@Giom-V Giom-V self-assigned this Dec 30, 2024
@Giom-V Giom-V added the type:bug Something isn't working label Dec 30, 2024
@Giom-V
Copy link
Collaborator

Giom-V commented Dec 30, 2024

Hello @nicornejo,

Thanks for reporting the issue. I am also suffering from it and reported it a while ago to the team working on the SDK. This is one of their top issues so it should hopefully be fixed soon.

In the meantime, unless you are using one of the new Gemini 2.0 features like the live API, I'd recommend using the former SDK which still works with the news models.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants