fix: AI Gateway content safety 空值检查导致所有 AI 输出被误拦
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 41s
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 41s
contentSafety 未注入时 safetyCheck 为 undefined,!undefined?.safe = true, 错误抛出 "AI output blocked by content safety",实际 DeepSeek 正常返回。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
55221116b7
commit
3d8246cf6e
@ -64,7 +64,7 @@ export class AiGatewayService {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const safetyCheck = await this.contentSafety?.check(output.rawText, { contentType: 'ai_output' }).catch(() => ({ safe: true }));
|
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 parsed = this.parseJson(output.rawText, request.outputSchema);
|
||||||
const estimatedCost = this.costCalculator.calculate(
|
const estimatedCost = this.costCalculator.calculate(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user