diff --git a/api/core/third_party/langchain/llms/minimax_llm.py b/api/core/third_party/langchain/llms/minimax_llm.py index c17c63a4a9..f8e777754e 100644 --- a/api/core/third_party/langchain/llms/minimax_llm.py +++ b/api/core/third_party/langchain/llms/minimax_llm.py @@ -211,6 +211,16 @@ class MinimaxChatLLM(BaseChatModel): token = token.lstrip("data:").strip() data = json.loads(token) + + if "base_resp" in data and data["base_resp"]["status_code"] > 0: + raise ValueError( + f"API {data['base_resp']['status_code']}" + f" error: {data['base_resp']['status_msg']}" + ) + + if not data['choices']: + continue + content = data['choices'][0]['delta'] chunk_kwargs = {