Skip to content

Commit

Permalink
chore: patch streaming
Browse files Browse the repository at this point in the history
  • Loading branch information
gradenr committed May 22, 2024
1 parent 5056621 commit 9dcba61
Show file tree
Hide file tree
Showing 6 changed files with 374 additions and 117 deletions.
4 changes: 4 additions & 0 deletions src/groq/_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ def __stream__(self) -> Iterator[_T]:
iterator = self._iter_events()

for sse in iterator:
if sse.data.startswith("[DONE]"):
break
yield process_data(data=sse.json(), cast_to=cast_to, response=response)

# Ensure the entire stream is consumed
Expand Down Expand Up @@ -119,6 +121,8 @@ async def __stream__(self) -> AsyncIterator[_T]:
iterator = self._iter_events()

async for sse in iterator:
if sse.data.startswith("[DONE]"):
break
yield process_data(data=sse.json(), cast_to=cast_to, response=response)

# Ensure the entire stream is consumed
Expand Down
110 changes: 0 additions & 110 deletions src/groq/lib/chat_completion_chunk.py

This file was deleted.

Loading

0 comments on commit 9dcba61

Please sign in to comment.