From 7e154a467ba7afcf6e5ee308e6f0b423ffd385c9 Mon Sep 17 00:00:00 2001 From: yihong Date: Sun, 15 Dec 2024 17:16:04 +0800 Subject: [PATCH] fix: better error message for stream (#11635) Signed-off-by: yihong0618 --- .../model_providers/openai_api_compatible/llm/llm.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/api/core/model_runtime/model_providers/openai_api_compatible/llm/llm.py b/api/core/model_runtime/model_providers/openai_api_compatible/llm/llm.py index 26c090d30e..8e07d56f45 100644 --- a/api/core/model_runtime/model_providers/openai_api_compatible/llm/llm.py +++ b/api/core/model_runtime/model_providers/openai_api_compatible/llm/llm.py @@ -478,6 +478,10 @@ class OAIAPICompatLargeLanguageModel(_CommonOaiApiCompat, LargeLanguageModel): usage=usage, ) break + # handle the error here. for issue #11629 + if chunk_json.get("error") and chunk_json.get("choices") is None: + raise ValueError(chunk_json.get("error")) + if chunk_json: if u := chunk_json.get("usage"): usage = u