Skip to content

Commit

Permalink
fix: streaming
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertCraigie committed Jan 13, 2025
1 parent d76a748 commit b0e8922
Showing 1 changed file with 0 additions and 19 deletions.
19 changes: 0 additions & 19 deletions src/openai/_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,25 +76,6 @@ def __stream__(self) -> Iterator[_T]:

yield process_data(data=data, cast_to=cast_to, response=response)

else:
data = sse.json()

if sse.event == "error" and is_mapping(data) and data.get("error"):
message = None
error = data.get("error")
if is_mapping(error):
message = error.get("message")
if not message or not isinstance(message, str):
message = "An error occurred during streaming"

raise APIError(
message=message,
request=self.response.request,
body=data["error"],
)

yield process_data(data={"data": data, "event": sse.event}, cast_to=cast_to, response=response)

# Ensure the entire stream is consumed
for _sse in iterator:
...
Expand Down

0 comments on commit b0e8922

Please sign in to comment.