generative-ai-python icon indicating copy to clipboard operation
generative-ai-python copied to clipboard

Issue #560

Open mwigh opened this issue 1 year ago • 3 comments
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.

mwigh avatar Oct 02 '24 16:10 mwigh

  • We should try and make sure that the behavior is consistent between TypedDict, Dataclass, and Pydantic.
  • 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.

MarkDaoust avatar Oct 03 '24 19:10 MarkDaoust

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

markmcd avatar Oct 08 '24 23:10 markmcd

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

mwigh avatar Oct 09 '24 09:10 mwigh