mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
fix: Alibaba Cloud Bailian Stream Response (#4266)
This commit is contained in:
parent
267bdae924
commit
03e4bda814
|
|
@ -1,5 +1,5 @@
|
|||
# coding=utf-8
|
||||
|
||||
import datetime
|
||||
from typing import Dict, Optional, Any, Iterator
|
||||
|
||||
import requests
|
||||
|
|
@ -13,6 +13,7 @@ from models_provider.base_model_provider import MaxKBBaseModel
|
|||
from models_provider.impl.base_chat_open_ai import BaseChatOpenAI
|
||||
import json
|
||||
|
||||
|
||||
class QwenVLChatModel(MaxKBBaseModel, BaseChatOpenAI):
|
||||
|
||||
@staticmethod
|
||||
|
|
@ -116,7 +117,7 @@ class QwenVLChatModel(MaxKBBaseModel, BaseChatOpenAI):
|
|||
**self.extra_body,
|
||||
"stream": True,
|
||||
}
|
||||
response = requests.post(url, headers=headers, json=data)
|
||||
response = requests.post(url, headers=headers, json=data, stream=True)
|
||||
if response.status_code != 200:
|
||||
raise Exception(f"Failed to get response: {response.text}")
|
||||
for line in response.iter_lines():
|
||||
|
|
@ -138,7 +139,6 @@ class QwenVLChatModel(MaxKBBaseModel, BaseChatOpenAI):
|
|||
delta = chunk_data['choices'][0].get('delta', {})
|
||||
content = delta.get('content', '')
|
||||
if content:
|
||||
print(content)
|
||||
yield AIMessage(content=content)
|
||||
except json.JSONDecodeError:
|
||||
# 忽略无法解析的行
|
||||
|
|
|
|||
Loading…
Reference in New Issue