Skip to content

Validation errors for _GeminiResponse #1143

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

Closed
1 task done
torayeff opened this issue Mar 16, 2025 · 2 comments · Fixed by pydantic/pydantic#11559
Closed
1 task done

Validation errors for _GeminiResponse #1143

torayeff opened this issue Mar 16, 2025 · 2 comments · Fixed by pydantic/pydantic#11559
Assignees
Labels
bug Something isn't working

Comments

@torayeff
Copy link

Initial Checks

  • I confirm that I'm using the latest version of Pydantic AI

Description

I get the below error when trying to run simple agent with Gemini provider:

lib/python3.11/site-packages/pydantic/type_adapter.py", line 468, in validate_json
    return self.validator.validate_json(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 4 validation errors for _GeminiResponse
candidates.0.avgLogProbs
  Field required [type=missing, input_value={'content': {'parts': [{'...': -0.05566399544477463}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.11/v/missing
candidates.0.index
  Field required [type=missing, input_value={'content': {'parts': [{'...': -0.05566399544477463}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.11/v/missing
candidates.0.safetyRatings
  Field required [type=missing, input_value={'content': {'parts': [{'...': -0.05566399544477463}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.11/v/missing
promptFeedback
  Field required [type=missing, input_value={'candidates': [{'content...on': 'gemini-2.0-flash'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.11/v/missing

Example Code

from pydantic_ai import Agent

agent = Agent(model="google-gla:gemini-2.0-flash")
result = agent.run_sync("Hello, how are you?")
print(result.data)

Python, Pydantic AI & LLM client version

Python: 3.11.11
Pydantic: 2.11.0b1
Pydantic AI: 0.0.40
@torayeff
Copy link
Author

pip install pydantic==2.10.6 solved the problem for now.

@Kludex Kludex reopened this Mar 17, 2025
@Kludex
Copy link
Member

Kludex commented Mar 17, 2025

Thanks for pointing out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants