mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-08-06 10:54:29 +00:00
fix(llmproxy): fix openai chatgpt api response error (#871)
This commit is contained in:
parent
1a8616dab8
commit
711032c480
@ -175,7 +175,7 @@ def chatgpt_generate_stream(
|
|||||||
# logger.info(str(r))
|
# logger.info(str(r))
|
||||||
# Azure Openai reponse may have empty choices body in the first chunk
|
# Azure Openai reponse may have empty choices body in the first chunk
|
||||||
# to avoid index out of range error
|
# to avoid index out of range error
|
||||||
if not r.get("choices"):
|
if len(r.choices) == 0:
|
||||||
continue
|
continue
|
||||||
if r.choices[0].delta.content is not None:
|
if r.choices[0].delta.content is not None:
|
||||||
content = r.choices[0].delta.content
|
content = r.choices[0].delta.content
|
||||||
@ -191,7 +191,7 @@ def chatgpt_generate_stream(
|
|||||||
|
|
||||||
text = ""
|
text = ""
|
||||||
for r in res:
|
for r in res:
|
||||||
if not r.get("choices"):
|
if len(r.choices) == 0:
|
||||||
continue
|
continue
|
||||||
if r["choices"][0]["delta"].get("content") is not None:
|
if r["choices"][0]["delta"].get("content") is not None:
|
||||||
content = r["choices"][0]["delta"]["content"]
|
content = r["choices"][0]["delta"]["content"]
|
||||||
|
Loading…
Reference in New Issue
Block a user