fix:国际化配置余额不足

This commit is contained in:
肖应宇 2026-05-06 15:16:35 +08:00
parent 345a143e38
commit 46711ffec8
5 changed files with 19 additions and 3 deletions

View File

@ -174,7 +174,6 @@ def _extract_run_id(request: ModelRequest) -> str | None: # noqa: ARG001
def _reserve_failure_message(status_code: int | None) -> str: def _reserve_failure_message(status_code: int | None) -> str:
if status_code in _blocking_reserve_code_set(): if status_code in _blocking_reserve_code_set():
# TODO: 将账单错误文案迁移到国际化资源中,按语言返回提示。
return "The account balance is insufficient for this model call." return "The account balance is insufficient for this model call."
return "Billing reservation failed. Please try again later." return "Billing reservation failed. Please try again later."

View File

@ -46,6 +46,13 @@ import { CopyButton } from "../copy-button";
import { MarkdownContent } from "./markdown-content"; 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({ export function MessageListItem({
className, className,
message, message,
@ -176,8 +183,14 @@ function MessageContent_({
const cleaned = stripPriorityHintSuffix(stripUploadedFilesTag(rawContent)); const cleaned = stripPriorityHintSuffix(stripUploadedFilesTag(rawContent));
return normalizeHumanMessageDisplayText(cleaned); return normalizeHumanMessageDisplayText(cleaned);
} }
return rawContent ?? ""; if (!rawContent) {
}, [rawContent, isHuman]); return "";
}
return localizeAssistantFixedCopy(
rawContent,
t.threads.billingInsufficientBalance,
);
}, [rawContent, isHuman, t.threads.billingInsufficientBalance]);
const isSummaryMessage = useMemo( const isSummaryMessage = useMemo(
() => isHuman && isSummaryTemplateMessage(message), () => isHuman && isSummaryTemplateMessage(message),
[isHuman, message], [isHuman, message],

View File

@ -319,6 +319,8 @@ export const enUS: Translations = {
threads: { threads: {
streamError: "Something went wrong.", streamError: "Something went wrong.",
billingInsufficientBalance:
"The account balance is insufficient for this model call.",
invalidThreadId: "Invalid thread id 'new'. Please refresh and retry.", invalidThreadId: "Invalid thread id 'new'. Please refresh and retry.",
staleReferencesRemoved: staleReferencesRemoved:
"Some referenced files were invalid and were removed automatically.", "Some referenced files were invalid and were removed automatically.",

View File

@ -245,6 +245,7 @@ export interface Translations {
threads: { threads: {
streamError: string; streamError: string;
billingInsufficientBalance: string;
invalidThreadId: string; invalidThreadId: string;
staleReferencesRemoved: string; staleReferencesRemoved: string;
uploadFailed: string; uploadFailed: string;

View File

@ -306,6 +306,7 @@ export const zhCN: Translations = {
threads: { threads: {
streamError: "出现了某些错误。", streamError: "出现了某些错误。",
billingInsufficientBalance: "账户余额不足,无法完成本次模型调用。",
invalidThreadId: "线程 ID 无效new请刷新后重试。", invalidThreadId: "线程 ID 无效new请刷新后重试。",
staleReferencesRemoved: "部分引用文件已失效,已自动移除并继续发送。", staleReferencesRemoved: "部分引用文件已失效,已自动移除并继续发送。",
uploadFailed: "文件上传失败。", uploadFailed: "文件上传失败。",