This commit is contained in:
Nexus 2023-11-10 23:25:47 +00:00
parent 10bb416fa1
commit ff192c5b88
Signed by: nex
GPG key ID: 0FA334385D0B689F

View file

@ -97,7 +97,12 @@ async def ollama_stream_reader(response: httpx.Response) -> typing.AsyncGenerato
while not _buffer.endswith(b"}\n"): while not _buffer.endswith(b"}\n"):
async for char in stream: async for char in stream:
_buffer += char _buffer += char
print("Read {:,} bytes in chunk for a total of {:,} bytes in buffer.".format(len(char), len(_buffer)) print(
"Read {:,} bytes in chunk for a total of {:,} bytes in buffer.".format(
len(char),
len(_buffer)
)
)
_buffer = _buffer.rstrip() _buffer = _buffer.rstrip()
print("[ollama stream reader] Resolving %r" % (_buffer.decode())) print("[ollama stream reader] Resolving %r" % (_buffer.decode()))
chunk = json.loads(_buffer.decode("utf-8", "replace")) chunk = json.loads(_buffer.decode("utf-8", "replace"))