generative-ai-python
generative-ai-python copied to clipboard
Issue #560
trafficstars
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
- [x] I have performed a self-review of my code.
- [x] I have added detailed comments to my code where applicable.
- [x] I have verified that my change does not break existing code.
- [x] My PR is based on the latest changes of the main branch (if unsure, please run
git pull --rebase upstream main). - [x] I am familiar with the Google Style Guide for the language I have coded in.
- [x] I have read through the Contributing Guide and signed the Contributor License Agreement.
- We should try and make sure that the behavior is consistent between
TypedDict,Dataclass, andPydantic. - We should be sure the behavior is consistent between function definitions and response_schema.
I don't think this fills both those requirements. I'll have to re-read this in more detail.
Could you also add tests to cover the cases you're fixing? This way we insure against backsliding.
@markmcd see comments in #560 I do not know what cases you want to cover