From 46711ffec84e2e916ebc5215e2276d3c613a53ea Mon Sep 17 00:00:00 2001 From: MT-Mint <798521692@qq.com> Date: Wed, 6 May 2026 15:16:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=9B=BD=E9=99=85=E5=8C=96=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E4=BD=99=E9=A2=9D=E4=B8=8D=E8=B6=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../agents/middlewares/billing_middleware.py | 1 - .../workspace/messages/message-list-item.tsx | 17 +++++++++++++++-- frontend/src/core/i18n/locales/en-US.ts | 2 ++ frontend/src/core/i18n/locales/types.ts | 1 + frontend/src/core/i18n/locales/zh-CN.ts | 1 + 5 files changed, 19 insertions(+), 3 deletions(-) diff --git a/backend/packages/harness/deerflow/agents/middlewares/billing_middleware.py b/backend/packages/harness/deerflow/agents/middlewares/billing_middleware.py index 083f48ca..bfbebc14 100644 --- a/backend/packages/harness/deerflow/agents/middlewares/billing_middleware.py +++ b/backend/packages/harness/deerflow/agents/middlewares/billing_middleware.py @@ -174,7 +174,6 @@ def _extract_run_id(request: ModelRequest) -> str | None: # noqa: ARG001 def _reserve_failure_message(status_code: int | None) -> str: if status_code in _blocking_reserve_code_set(): - # TODO: 将账单错误文案迁移到国际化资源中,按语言返回提示。 return "The account balance is insufficient for this model call." return "Billing reservation failed. Please try again later." diff --git a/frontend/src/components/workspace/messages/message-list-item.tsx b/frontend/src/components/workspace/messages/message-list-item.tsx index c045b9a7..209af955 100644 --- a/frontend/src/components/workspace/messages/message-list-item.tsx +++ b/frontend/src/components/workspace/messages/message-list-item.tsx @@ -46,6 +46,13 @@ import { CopyButton } from "../copy-button"; import { MarkdownContent } from "./markdown-content"; +function localizeAssistantFixedCopy(content: string, localized: string): string { + if (content.includes("The account balance is insufficient for this model call.")) { + return localized; + } + return content; +} + export function MessageListItem({ className, message, @@ -176,8 +183,14 @@ function MessageContent_({ const cleaned = stripPriorityHintSuffix(stripUploadedFilesTag(rawContent)); return normalizeHumanMessageDisplayText(cleaned); } - return rawContent ?? ""; - }, [rawContent, isHuman]); + if (!rawContent) { + return ""; + } + return localizeAssistantFixedCopy( + rawContent, + t.threads.billingInsufficientBalance, + ); + }, [rawContent, isHuman, t.threads.billingInsufficientBalance]); const isSummaryMessage = useMemo( () => isHuman && isSummaryTemplateMessage(message), [isHuman, message], diff --git a/frontend/src/core/i18n/locales/en-US.ts b/frontend/src/core/i18n/locales/en-US.ts index 86a3894a..d3fb090d 100644 --- a/frontend/src/core/i18n/locales/en-US.ts +++ b/frontend/src/core/i18n/locales/en-US.ts @@ -319,6 +319,8 @@ export const enUS: Translations = { threads: { streamError: "Something went wrong.", + billingInsufficientBalance: + "The account balance is insufficient for this model call.", invalidThreadId: "Invalid thread id 'new'. Please refresh and retry.", staleReferencesRemoved: "Some referenced files were invalid and were removed automatically.", diff --git a/frontend/src/core/i18n/locales/types.ts b/frontend/src/core/i18n/locales/types.ts index ebd22bb6..33a6f062 100644 --- a/frontend/src/core/i18n/locales/types.ts +++ b/frontend/src/core/i18n/locales/types.ts @@ -245,6 +245,7 @@ export interface Translations { threads: { streamError: string; + billingInsufficientBalance: string; invalidThreadId: string; staleReferencesRemoved: string; uploadFailed: string; diff --git a/frontend/src/core/i18n/locales/zh-CN.ts b/frontend/src/core/i18n/locales/zh-CN.ts index 3a726e93..be9df575 100644 --- a/frontend/src/core/i18n/locales/zh-CN.ts +++ b/frontend/src/core/i18n/locales/zh-CN.ts @@ -306,6 +306,7 @@ export const zhCN: Translations = { threads: { streamError: "出现了某些错误。", + billingInsufficientBalance: "账户余额不足,无法完成本次模型调用。", invalidThreadId: "线程 ID 无效(new),请刷新后重试。", staleReferencesRemoved: "部分引用文件已失效,已自动移除并继续发送。", uploadFailed: "文件上传失败。",