Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: raise error in minimax stream generate (#1336)

takatostf4be2b8bcdd7
diff --git a/api/core/third_party/langchain/llms/minimax_llm.py b/api/core/third_party/langchain/llms/minimax_llm.py
index c17c63a4a9b..f8e777754e1 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 = {