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.19k stars 227 forks source link

Update pydantic import to fix b/343572011 in g3 #369

Open YuncongZhou opened 1 month ago

YuncongZhou commented 1 month ago

The commit is a mirror of cl/638491582 by ayzhou@

As indicated in b/343572011, the issue affect all Python SDK FC usage in g3 including the official function calling colab.

The issue is very similar to b/325114802, b/331534434, which are then fixed with cl/619453719.

Description of the change

Update pydantic import to fix b/343572011. It is a mirror of cl/638491582 by ayzhou@

Motivation

b/343572011

Type of change

Bug fix

Checklist

MarkDaoust commented 1 month ago

Thanks, I'll take a look.

MarkDaoust commented 1 month ago

Interesting.

  1. it looks like v1 isn't just a google thing. It's in the OSS installation too:
import pydantic

pydantic.version.VERSION
# 2.7.3
pydantic.v1.version.VERSION
# 1.10.15

So even if you have v2 you get v2 (that's why the tests here are failing)

I think we need a way to get the basics all running in v1 and ... the output is different?

MarkDaoust commented 1 month ago

Added a test workflow to test with pydantic-1.

If we want this to successfully close that bug, we need to get those tests working, or expolicitly choose some acceptable subset of them and tag the others with a skipif .

MarkDaoust commented 1 month ago
  1. It looks like pydantic1 handles the nested TypedDicts differently from pydantic2
  2. It looks like nullable is handled differently