Skip to content

Commit

Permalink
fix(llmproxy): fix openai chatgpt api response error (#871)
Browse files Browse the repository at this point in the history
  • Loading branch information
csunny authored Nov 30, 2023
1 parent 1a8616d commit 711032c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pilot/model/proxy/llms/chatgpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def chatgpt_generate_stream(
# logger.info(str(r))
# Azure Openai reponse may have empty choices body in the first chunk
# to avoid index out of range error
if not r.get("choices"):
if len(r.choices) == 0:
continue
if r.choices[0].delta.content is not None:
content = r.choices[0].delta.content
Expand All @@ -191,7 +191,7 @@ def chatgpt_generate_stream(

text = ""
for r in res:
if not r.get("choices"):
if len(r.choices) == 0:
continue
if r["choices"][0]["delta"].get("content") is not None:
content = r["choices"][0]["delta"]["content"]
Expand Down

0 comments on commit 711032c

Please sign in to comment.