From 3d8246cf6e946f40a46333bbdb54aa764292b734 Mon Sep 17 00:00:00 2001 From: wangdl Date: Sat, 6 Jun 2026 14:23:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20AI=20Gateway=20content=20safety=20?= =?UTF-8?q?=E7=A9=BA=E5=80=BC=E6=A3=80=E6=9F=A5=E5=AF=BC=E8=87=B4=E6=89=80?= =?UTF-8?q?=E6=9C=89=20AI=20=E8=BE=93=E5=87=BA=E8=A2=AB=E8=AF=AF=E6=8B=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit contentSafety 未注入时 safetyCheck 为 undefined,!undefined?.safe = true, 错误抛出 "AI output blocked by content safety",实际 DeepSeek 正常返回。 Co-Authored-By: Claude Opus 4.7 --- src/modules/ai/gateway/ai-gateway.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/ai/gateway/ai-gateway.service.ts b/src/modules/ai/gateway/ai-gateway.service.ts index bcf7c5e..d3ea50a 100644 --- a/src/modules/ai/gateway/ai-gateway.service.ts +++ b/src/modules/ai/gateway/ai-gateway.service.ts @@ -64,7 +64,7 @@ export class AiGatewayService { }); const safetyCheck = await this.contentSafety?.check(output.rawText, { contentType: 'ai_output' }).catch(() => ({ safe: true })); - if (!safetyCheck?.safe) throw new Error('AI output blocked by content safety'); + if (safetyCheck && !safetyCheck.safe) throw new Error('AI output blocked by content safety'); const parsed = this.parseJson(output.rawText, request.outputSchema); const estimatedCost = this.costCalculator.calculate(