Skip to content

Commit

Permalink
🐛 fix error from cohere api
Browse files Browse the repository at this point in the history
🐛 fix cohere api errro

🐛 fix error

🐛 error
  • Loading branch information
bruceunx committed May 2, 2024
1 parent 0844538 commit 63ad40b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions gpt_server/routers/cohere.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@


async def get_content(data):
signal = False
async with aiohttp.ClientSession(headers=headers) as sess:
async with sess.post(url, json=data) as res:
async for chunk in res.content:
if chunk:
tmp = json.loads(chunk.decode("utf-8"))
if 'text' not in tmp:
continue
if tmp["is_finished"]:
signal = True
yield "[DONE]"
else:
yield json.dumps({
Expand All @@ -41,6 +45,8 @@ async def get_content(data):
yield '{"choices":[{"index":0,"delta":{"content":"error from claude"}}]}'
yield "[DONE]"
break
if not signal:
yield "[DONE]"


@router.post("/chat", status_code=200)
Expand Down

0 comments on commit 63ad40b

Please sign in to comment.