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

This commit is contained in:
takatost 2023-10-13 12:48:28 +08:00 committed by GitHub
parent e83e239faf
commit f4be2b8bcd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -211,6 +211,16 @@ class MinimaxChatLLM(BaseChatModel):
token = token.lstrip("data:").strip() token = token.lstrip("data:").strip()
data = json.loads(token) 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'] content = data['choices'][0]['delta']
chunk_kwargs = { chunk_kwargs = {