From 9a5a65e53905048d5417de960f0e31279b7b80f5 Mon Sep 17 00:00:00 2001 From: unclee Date: Thu, 5 Mar 2026 14:02:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=AE=B0=E5=BF=86=E6=8A=BD=E5=8F=96?= =?UTF-8?q?=E5=85=B3=E9=97=AD=20Qwen=20=E6=80=9D=E8=80=83=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=20+=20=E6=B5=8B=E8=AF=95=E6=A8=A1=E5=9E=8B=E4=B8=8E?= =?UTF-8?q?=E7=94=9F=E4=BA=A7=E9=85=8D=E7=BD=AE=E5=AF=B9=E9=BD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - extractor.ts 和测试中添加 enable_thinking: false,抽取是结构化输出任务不需要 CoT - 测试硬编码的 qwen3.5-plus 改为读取 MEMORY_EXTRACTION_MODEL 环境变量(默认 qwen3.5-flash) - quality.test.ts 抽取 case 超时从 120s 放宽到 240s(外部 API 兜底) - 实测 5 个抽取 case 总耗时从 >310s 降至 ~6s Co-Authored-By: Claude Opus 4.6 (1M context) --- src/memory/__tests__/integration.test.ts | 6 ++++-- src/memory/__tests__/quality.test.ts | 8 +++++--- src/memory/extractor.ts | 4 +++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/memory/__tests__/integration.test.ts b/src/memory/__tests__/integration.test.ts index 273fa455..5cd81d5c 100644 --- a/src/memory/__tests__/integration.test.ts +++ b/src/memory/__tests__/integration.test.ts @@ -445,13 +445,15 @@ describe('场景7: 记忆抽取 (Qwen)', () => { 我会在后续开发中注意这些约定。`; const response = await client.chat.completions.create({ - model: 'qwen3.5-plus', + model: process.env.MEMORY_EXTRACTION_MODEL || 'qwen3.5-flash', messages: [ { role: 'system', content: extractionPrompt }, { role: 'user', content: conversation }, ], temperature: 0.1, - }); + // DashScope extension: 关闭思考模式加速响应 + enable_thinking: false, + } as never); const rawContent = response.choices?.[0]?.message?.content ?? ''; console.log('\n🧠 Qwen 抽取原始输出:'); diff --git a/src/memory/__tests__/quality.test.ts b/src/memory/__tests__/quality.test.ts index ffbf7db9..7f5451a9 100644 --- a/src/memory/__tests__/quality.test.ts +++ b/src/memory/__tests__/quality.test.ts @@ -316,7 +316,7 @@ describe('Part 2: 抽取质量', () => { const scorecard: { name: string; expectedCount: number; actualCount: number; typeMatch: number; keywordMatch: number }[] = []; for (const tc of EXTRACTION_CASES) { - it(tc.name, { timeout: 120000 }, async () => { + it(tc.name, { timeout: 240000 }, async () => { if (!HAS_KEY) { console.log('⏭️ 跳过: 需要 DASHSCOPE_API_KEY'); return; @@ -351,13 +351,15 @@ describe('Part 2: 抽取质量', () => { `; const response = await client.chat.completions.create({ - model: 'qwen3.5-plus', + model: process.env.MEMORY_EXTRACTION_MODEL || 'qwen3.5-flash', messages: [ { role: 'system', content: extractionPrompt }, { role: 'user', content: tc.conversation }, ], temperature: 0.1, - }); + // DashScope extension: 关闭思考模式加速响应 + enable_thinking: false, + } as never); const rawContent = response.choices?.[0]?.message?.content ?? ''; const memories = parseExtractionResponse(rawContent); diff --git a/src/memory/extractor.ts b/src/memory/extractor.ts index f968f136..288af606 100644 --- a/src/memory/extractor.ts +++ b/src/memory/extractor.ts @@ -117,7 +117,9 @@ export async function extractMemories( { role: 'user', content: conversation }, ], temperature: 0.1, - }); + // DashScope extension: 记忆抽取是结构化输出任务,关闭思考模式加速响应 + enable_thinking: false, + } as never); const rawContent = response.choices?.[0]?.message?.content; if (!rawContent) return;