mirror of
https://github.com/xtekky/gpt4free.git
synced 2025-12-15 14:51:19 -08:00
Add unittests for async client (#1830)
* Add unittests for async client * Add pollyfill for anext * Update integration tests
This commit is contained in:
parent
35179fe843
commit
0b712c2bde
7 changed files with 82 additions and 15 deletions
|
|
@ -34,15 +34,13 @@ class StreamResponse:
|
|||
"""Asynchronously parse the JSON response content."""
|
||||
return json.loads(await self.inner.acontent(), **kwargs)
|
||||
|
||||
async def iter_lines(self) -> AsyncGenerator[bytes, None]:
|
||||
def iter_lines(self) -> AsyncGenerator[bytes, None]:
|
||||
"""Asynchronously iterate over the lines of the response."""
|
||||
async for line in self.inner.aiter_lines():
|
||||
yield line
|
||||
return self.inner.aiter_lines()
|
||||
|
||||
async def iter_content(self) -> AsyncGenerator[bytes, None]:
|
||||
def iter_content(self) -> AsyncGenerator[bytes, None]:
|
||||
"""Asynchronously iterate over the response content."""
|
||||
async for chunk in self.inner.aiter_content():
|
||||
yield chunk
|
||||
return self.inner.aiter_content()
|
||||
|
||||
async def __aenter__(self):
|
||||
"""Asynchronously enter the runtime context for the response object."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue