Skip to content

Fix raising validation errors when streaming #24

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

Merged
merged 1 commit into from
Apr 22, 2025
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion any_llm_client/clients/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ async def _iter_response_chunks(self, response: httpx.Response) -> typing.AsyncI
validated_response = ChatCompletionsStreamingEvent.model_validate_json(event.data)
except pydantic.ValidationError as validation_error:
raise LLMResponseValidationError(
response_content=response.content, original_error=validation_error
response_content=event.data.encode(), original_error=validation_error
) from validation_error

if not (
Expand Down
2 changes: 1 addition & 1 deletion any_llm_client/clients/yandexgpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ async def _iter_response_chunks(self, response: httpx.Response) -> typing.AsyncI
validated_response = YandexGPTResponse.model_validate_json(one_line)
except pydantic.ValidationError as validation_error:
raise LLMResponseValidationError(
response_content=response.content, original_error=validation_error
response_content=one_line.encode(), original_error=validation_error
) from validation_error

response_text = validated_response.result.alternatives[0].message.text
Expand Down