Debug ollama more!

This commit is contained in:
Nexus 2023-11-10 23:43:32 +00:00
parent 0848cdcc0b
commit 9784b65b1c
Signed by: nex
GPG key ID: 0FA334385D0B689F

View file

@ -93,7 +93,9 @@ async def ollama_stream_reader(response: httpx.Response) -> typing.AsyncGenerato
async for chunk in response.aiter_bytes(8192): async for chunk in response.aiter_bytes(8192):
# Each chunk is a JSON string # Each chunk is a JSON string
try: try:
yield json.loads(chunk.strip().decode("utf-8", "replace")) loaded = json.loads(chunk.strip().decode("utf-8", "replace"))
print("Loaded chunk: %r", loaded)
yield loaded
except json.JSONDecodeError as e: except json.JSONDecodeError as e:
print("Failed to decode chunk %r: %r" % (chunk, e), file=sys.stderr) print("Failed to decode chunk %r: %r" % (chunk, e), file=sys.stderr)
pass pass