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

Validate chatcompletion to avoid unexpected bugs #551

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sambhav
Copy link

@sambhav sambhav commented Dec 26, 2024

Fixes #527

This PR addresses the incorrect handling of error responses from the API when a rate limit is exceeded. The changes include:

  • Adding a check for the presence of a timestamp in the API response and raising an appropriate error if it is missing.
  • Updating the _process_response method in pydantic_ai/models/openai.py to handle the absence of a timestamp.
  • Adding new tests in tests/models/test_openai.py to ensure proper error handling when the timestamp is missing from the response.

These changes ensure that the appropriate error message is surfaced when a rate limit is exceeded, instead of throwing a date-time parsing exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Error responses are not handled correctly for google openapi/openrouter
1 participant