Skip to content

Commit 91ed99a

Browse files
committed
Update .stream() and .stream_async() to return generators not ChatResponse
I don't it was necessary in the first place, and leads to inefficient use of memory
1 parent f78187f commit 91ed99a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

chatlas/_chat.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ def stream(
628628
*args: Content | str,
629629
echo: Literal["text", "all", "none"] = "none",
630630
kwargs: Optional[SubmitInputArgsT] = None,
631-
) -> ChatResponse:
631+
) -> Generator[Stringable, None, None]:
632632
"""
633633
Generate a response from the chat in a streaming fashion.
634634
@@ -666,14 +666,14 @@ def wrapper() -> Generator[Stringable, None, None]:
666666
for chunk in generator:
667667
yield chunk
668668

669-
return ChatResponse(wrapper())
669+
return wrapper()
670670

671671
async def stream_async(
672672
self,
673673
*args: Content | str,
674674
echo: Literal["text", "all", "none"] = "none",
675675
kwargs: Optional[SubmitInputArgsT] = None,
676-
) -> ChatResponseAsync:
676+
) -> AsyncGenerator[Stringable, None]:
677677
"""
678678
Generate a response from the chat in a streaming fashion asynchronously.
679679
@@ -709,7 +709,7 @@ async def wrapper() -> AsyncGenerator[Stringable, None]:
709709
):
710710
yield chunk
711711

712-
return ChatResponseAsync(wrapper())
712+
return wrapper()
713713

714714
def extract_data(
715715
self,

0 commit comments

Comments
 (0)