From d1ee5f931a94da4e6e381db9f5e6a515379aa84d Mon Sep 17 00:00:00 2001 From: fdc310 <82008029+fdc310@users.noreply.github.com> Date: Sat, 31 Jan 2026 20:31:37 +0800 Subject: [PATCH] chore(deps): update dashscope version to 1.25.10 in pyproject.toml (#1951) feat: enable thinking feature in DashScopeAPIRunner for improved conversation handling --- pyproject.toml | 2 +- src/langbot/pkg/provider/runners/dashscopeapi.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 85221075..50e4d679 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,7 @@ dependencies = [ "certifi>=2025.4.26", "colorlog~=6.6.0", "cryptography>=44.0.3", - "dashscope>=1.23.2", + "dashscope>=1.25.10", "dingtalk-stream>=0.24.0", "discord-py>=2.5.2", "pynacl>=1.5.0", # Required for Discord voice support diff --git a/src/langbot/pkg/provider/runners/dashscopeapi.py b/src/langbot/pkg/provider/runners/dashscopeapi.py index d9cf25a5..0c914ee1 100644 --- a/src/langbot/pkg/provider/runners/dashscopeapi.py +++ b/src/langbot/pkg/provider/runners/dashscopeapi.py @@ -118,6 +118,7 @@ class DashScopeAPIRunner(runner.RequestRunner): stream=True, # 流式输出 incremental_output=True, # 增量输出,使用流式输出需要开启增量输出 session_id=query.session.using_conversation.uuid, # 会话ID用于,多轮对话 + enable_thinking=has_thoughts, has_thoughts=has_thoughts, # rag_options={ # 主要用于文件交互,暂不支持 # "session_file_ids": ["FILE_ID1"], # FILE_ID1 替换为实际的临时文件ID,逗号隔开多个 @@ -141,14 +142,14 @@ class DashScopeAPIRunner(runner.RequestRunner): # 获取流式传输的output stream_output = chunk.get('output', {}) stream_think = stream_output.get('thoughts', []) - if stream_think[0].get('thought'): + if stream_think and stream_think[0].get('thought'): if not think_start: think_start = True pending_content += f'\n{stream_think[0].get("thought")}' else: # 继续输出 reasoning_content pending_content += stream_think[0].get('thought') - elif stream_think[0].get('thought') == '' and not think_end: + elif (not stream_think or stream_think[0].get('thought') == '') and not think_end: think_end = True pending_content += '\n\n' if stream_output.get('text') is not None: