Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/openai/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@
AsyncAPIResponse,
extract_response_type,
)
from pydantic import ValidationError

def _parse_response(self, response_format, response):
try:
return response_format.model_validate(response)
except ValidationError as e:
raise ValueError(
f"Failed to parse response into {getattr(response_format, '__name__', str(response_format))}: {e}"
) from e

from ._constants import (
DEFAULT_TIMEOUT,
MAX_RETRY_DELAY,
Expand Down