fix stream chat for ollama (#816)

### What problem does this PR solve?

#709

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
KevinHuSh
2024-05-17 12:07:00 +08:00
committed by GitHub
parent 05fa3aeb08
commit d1614107e2
2 changed files with 46 additions and 5 deletions

View File

@ -248,8 +248,8 @@ class OllamaChat(Base):
)
for resp in response:
if resp["done"]:
return resp["prompt_eval_count"] + resp["eval_count"]
ans = resp["message"]["content"]
yield resp.get("prompt_eval_count", 0) + resp.get("eval_count", 0)
ans += resp["message"]["content"]
yield ans
except Exception as e:
yield ans + "\n**ERROR**: " + str(e)