google-gemini / generative-ai-python

The official Python library for the Google Gemini API
https://pypi.org/project/google-generativeai/
Apache License 2.0
1.62k stars 322 forks source link

Issue #560 #580

Open mwigh opened 1 month ago

mwigh commented 1 month ago

Needs to set required fields as required

Description of the change

When feeding a response_schema of type TypedDict to a GenerationConfig, then we need to set the field as required if it is required. This codes does that. It also avoids setting optional fields (Optional and NotRequired) as required.

Motivation

It solves the issue described in #560

Type of change

Bug fix

Checklist

MarkDaoust commented 1 month ago

I don't think this fills both those requirements. I'll have to re-read this in more detail.

markmcd commented 1 month ago

Could you also add tests to cover the cases you're fixing? This way we insure against backsliding.

mwigh commented 1 month ago

@markmcd see comments in #560 I do not know what cases you want to cover