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

TypedDict in google.genai.types causes Pydantic error on Python <3.12 #189

Open
koxudaxi opened this issue Jan 24, 2025 · 0 comments
Open
Assignees
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@koxudaxi
Copy link

Environment details

  • Programming language: Python
  • OS: macOS 15.1.1
  • Language runtime version: Python 3.9
  • Package version: google-generativeai (latest) 0.6.0

Steps to reproduce

  1. I create Python file with below code:
from google.genai.types import GenerationConfigDict
from pydantic import BaseModel


class MyConfig(BaseModel):
    """My custom config for the Google call."""
    config: GenerationConfigDict
  1. When I run this file with Python 3.9, I get error like this:
pydantic.errors.PydanticUserError: Please use `typing_extensions.TypedDict` instead of `typing.TypedDict` on Python < 3.12.

For further information visit https://errors.pydantic.dev/2.10/u/typed-dict-version

Problem Description

I find problem when I try to use TypedDict class from google.genai.types with Pydantic model in Python version less than 3.12. Pydantic show error because it need typing_extensions.TypedDict not typing.TypedDict for Python version under 3.12.

I think solution is change TypedDict import in google.genai.types from typing.TypedDict to typing_extensions.TypedDict. But types.py is auto-generated file, so I cannot change directly.

I try to fix code generator but I cannot find build manual or code generator source code.

This problem happen to everyone who use TypedDict class from google.genai.types with Pydantic in Python version under 3.12. Please fix code generator.

Thanks!

@koxudaxi koxudaxi added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Jan 24, 2025
@sasha-gitg sasha-gitg self-assigned this Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

2 participants