mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-08-10 13:10:57 +00:00
fix(dashscopeapi): fix null value check in reasoning content processing logic (#2128)
This commit is contained in:
@@ -107,7 +107,7 @@ class DashScopeAPIRunner(runner.RequestRunner):
|
|||||||
|
|
||||||
plain_text, image_ids = await self._preprocess_user_message(query)
|
plain_text, image_ids = await self._preprocess_user_message(query)
|
||||||
has_thoughts = True # 获取思考过程
|
has_thoughts = True # 获取思考过程
|
||||||
remove_think = self.pipeline_config['output'].get('misc', '').get('remove-think')
|
remove_think = self.pipeline_config['output'].get('misc', {}).get('remove-think')
|
||||||
if remove_think:
|
if remove_think:
|
||||||
has_thoughts = False
|
has_thoughts = False
|
||||||
# 发送对话请求
|
# 发送对话请求
|
||||||
@@ -141,7 +141,7 @@ class DashScopeAPIRunner(runner.RequestRunner):
|
|||||||
idx_chunk += 1
|
idx_chunk += 1
|
||||||
# 获取流式传输的output
|
# 获取流式传输的output
|
||||||
stream_output = chunk.get('output', {})
|
stream_output = chunk.get('output', {})
|
||||||
stream_think = stream_output.get('thoughts', [])
|
stream_think = stream_output.get('thoughts') or []
|
||||||
if stream_think and stream_think[0].get('thought'):
|
if stream_think and stream_think[0].get('thought'):
|
||||||
if not think_start:
|
if not think_start:
|
||||||
think_start = True
|
think_start = True
|
||||||
@@ -149,7 +149,7 @@ class DashScopeAPIRunner(runner.RequestRunner):
|
|||||||
else:
|
else:
|
||||||
# 继续输出 reasoning_content
|
# 继续输出 reasoning_content
|
||||||
pending_content += stream_think[0].get('thought')
|
pending_content += stream_think[0].get('thought')
|
||||||
elif (not stream_think or stream_think[0].get('thought') == '') and not think_end:
|
elif think_start and (not stream_think or stream_think[0].get('thought') == '') and not think_end:
|
||||||
think_end = True
|
think_end = True
|
||||||
pending_content += '\n</think>\n'
|
pending_content += '\n</think>\n'
|
||||||
if stream_output.get('text') is not None:
|
if stream_output.get('text') is not None:
|
||||||
@@ -188,15 +188,15 @@ class DashScopeAPIRunner(runner.RequestRunner):
|
|||||||
idx_chunk += 1
|
idx_chunk += 1
|
||||||
# 获取流式传输的output
|
# 获取流式传输的output
|
||||||
stream_output = chunk.get('output', {})
|
stream_output = chunk.get('output', {})
|
||||||
stream_think = stream_output.get('thoughts', [])
|
stream_think = stream_output.get('thoughts') or []
|
||||||
if stream_think[0].get('thought'):
|
if stream_think and stream_think[0].get('thought'):
|
||||||
if not think_start:
|
if not think_start:
|
||||||
think_start = True
|
think_start = True
|
||||||
pending_content += f'<think>\n{stream_think[0].get("thought")}'
|
pending_content += f'<think>\n{stream_think[0].get("thought")}'
|
||||||
else:
|
else:
|
||||||
# 继续输出 reasoning_content
|
# 继续输出 reasoning_content
|
||||||
pending_content += stream_think[0].get('thought')
|
pending_content += stream_think[0].get('thought')
|
||||||
elif stream_think[0].get('thought') == '' and not think_end:
|
elif think_start and (not stream_think or stream_think[0].get('thought') == '') and not think_end:
|
||||||
think_end = True
|
think_end = True
|
||||||
pending_content += '\n</think>\n'
|
pending_content += '\n</think>\n'
|
||||||
if stream_output.get('text') is not None:
|
if stream_output.get('text') is not None:
|
||||||
|
|||||||
Reference in New Issue
Block a user