Skip to content

Commit bf7c91d

Browse files
committed
fix(zai): 修复非流式解析bug
1 parent 0ac6cc9 commit bf7c91d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

app/providers/zai_provider.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ async def _handle_stream_response(
657657
self.logger.info(f"🔧 初始化工具处理器: {len(transformed['body'].get('tools', []))} 个工具")
658658

659659
has_thinking = False
660-
thinking_signature = None
660+
delta_content = None
661661
buffer = ""
662662
line_count = 0
663663
self.logger.debug("📡 开始接收 SSE 流数据...")
@@ -813,6 +813,7 @@ async def _handle_non_stream_response(self, response: httpx.Response, chat_id: s
813813

814814
try:
815815
chunk = json.loads(data_str)
816+
self.logger.debug(f"💡非流式内容:{chunk}")
816817
except json.JSONDecodeError:
817818
continue
818819

@@ -836,10 +837,13 @@ async def _handle_non_stream_response(self, response: httpx.Response, chat_id: s
836837
)
837838
reasoning_content += cleaned
838839
elif phase == "answer":
839-
if edit_content and "</details>\n" in edit_content:
840-
final_content += edit_content.split("</details>\n")[-1]
840+
if edit_content and "</details>" in edit_content:
841+
reasoning_content += edit_content.split(cleaned)[-1].replace("</details>","")
841842
elif delta_content:
842843
final_content += delta_content
844+
elif phase == "other":
845+
if edit_content:
846+
final_content += edit_content
843847

844848
except Exception as e:
845849
self.logger.error(f"❌ 非流式响应处理错误: {e}")

0 commit comments

Comments
 (0)