Fix stream reader

This commit is contained in:
Nexus 2023-11-10 22:43:10 +00:00
parent a5fce88e2a
commit f492f2e05f
Signed by: nex
GPG key ID: 0FA334385D0B689F

View file

@ -99,6 +99,7 @@ async def ollama_stream_reader(response: httpx.Response) -> typing.AsyncGenerato
while not _buffer.endswith(b"}\n"):
async for char in stream:
_buffer += char
_buffer = _buffer.rstrip()
log.debug("Resolving %r", _buffer.decode())
chunk = json.loads(_buffer.decode("utf-8", "replace"))
log.debug("%r -> %r", _buffer.decode(), chunk)