-
Notifications
You must be signed in to change notification settings - Fork 1k
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
"response_schema" results in KeyError #221
Comments
Hi @ganjigajanan, I have tried in the similar way passing the model = genai.GenerativeModel(
model_name="gemini-1.5-pro-latest",
generation_config={"response_mime_type": "application/json", "response_schema": TextSummary},
) Thanks |
Hi, I have the same error. Running Python 3.10.2 on Mac. Was there a resolution to this? Could it be to do with Pydantic version? Cheers, David |
Update: I did a check on my pydantic install, which was as follows: Upgrading pydantic yielded: With this the KeyError issue is removed and the Gemini API performs as expected. (Now I need to check for any dependencies on my project to the Pydantic v1...) |
Marking this issue as stale since it has been open for 14 days with no activity. This issue will be closed if no further activity occurs. |
I'm also having an issue with response_schema not working as intended. It appears to ignore all keys of a Dict except the first one. This is my class: class SubtitleObject(typing.TypedDict):
index: str
content: str This is the response I'm getting: [{'index': '0'}, {'index': '1'}, {'index': '2'}, {'index': '3'}, {'index': '4'}, {'index': '5'}, {'index': '6'}, {'index': '7'}, {'index': '8'}, {'index': '9'}, {'index': '10'}] Even the official docs show the same bug: |
Marking this issue as stale since it has been open for 14 days with no activity. This issue will be closed if no further activity occurs. |
Description of the bug:
Hello, I'm trying to recreate the example at: https://github.com/google-gemini/cookbook/blob/main/examples/json_capabilities/Text_Summarization.ipynb. After specifying the classes and creating the
generation_config
, while invoking thegenai.GenerativeModel
model withgeneration_config
results in aKeyError
.Actual vs expected behavior:
No response
Any other information you'd like to share?
No response
The text was updated successfully, but these errors were encountered: