Skip to content

Commit

Permalink
fix: avoid JSONDecodeError for empty line stream response
Browse files Browse the repository at this point in the history
  • Loading branch information
johnny0120 authored Dec 25, 2024
1 parent 7d1e002 commit 94b6ebf
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ollama/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ def inner():
raise ResponseError(e.response.text, e.response.status_code) from None

for line in r.iter_lines():
if not line:
continue
part = json.loads(line)
if err := part.get('error'):
raise ResponseError(err)
Expand Down

0 comments on commit 94b6ebf

Please sign in to comment.