type object 'dummy' has no attribute 'model_json_schema' #655
Labels
component:python sdk
Issue/PR related to Python SDK
status:awaiting user response
Awaiting a response from the author
type:help
Support-related issues
Description of the bug:
When using Pydantic BaseModel or TypedDict from typing_extensions as the response_schema in model.generate_content_async, the following error is raised:
This error occurs consistently, regardless of whether I use Pydantic BaseModel or TypedDict.
Steps to Reproduce
Actual vs expected behavior:
Expected Behavior
The response_schema should validate the generated content against the specified schema (Pydantic BaseModel or TypedDict) without throwing an error like the example in https://ai.google.dev/gemini-api/docs/structured-output?lang=python and in https://discuss.ai.google.dev/t/response-schema-from-pydantic/50028
Actual Behavior
An AttributeError is raised:
type object 'dummy' has no attribute 'model_json_schema
Any other information you'd like to share?
Environment
Workaround
Remove the
response_schema
from theGenerationConfig
or useresponse_schema
with JSON schema instead of Pydantic or TypedDict.The text was updated successfully, but these errors were encountered: