feat: 支持多语言提示词本地化和界面优化
- 添加 prompt_locale 参数支持简体中文、繁体中文和英文提示词本地化 - 移除内置 agents 配置以简化系统架构 - 更新 ContextBuilder 使用动态提示词模板而非硬编码内容 - 在 AgentLoop、Web 接口和 AgentService 中传递 locale 参数 - 添加输出语言指令确保用户界面内容按指定语言生成 - 扩展前端 LanguageSwitcher 组件支持三种语言选项 - 优化 Header 和侧边栏组件的响应式布局和文本截断处理 - 更新测试用例验证不同语言环境下的提示词正确性
This commit is contained in:
@ -51,7 +51,7 @@ import type {
|
||||
UiMcpServerDescriptor,
|
||||
WsEvent,
|
||||
} from '@/types';
|
||||
import { getCurrentAppLocale, pickAppText } from '@/lib/i18n/core';
|
||||
import { getCurrentAppLocale, pickAppText, type AppLocale } from '@/lib/i18n/core';
|
||||
|
||||
const API_URL = process.env.NEXT_PUBLIC_API_URL?.trim();
|
||||
const WS_URL = process.env.NEXT_PUBLIC_WS_URL?.trim();
|
||||
@ -62,6 +62,15 @@ const REQUEST_TIMEOUT_MS = 8000;
|
||||
const OUTLOOK_REQUEST_TIMEOUT_MS = 45000;
|
||||
const SKILL_LEARNING_REQUEST_TIMEOUT_MS = 120000;
|
||||
|
||||
export type PromptLocale = 'zh-Hans' | 'zh-Hant' | 'en';
|
||||
|
||||
export function promptLocaleForAppLocale(locale: AppLocale): PromptLocale {
|
||||
if (locale === 'zh-Hant') {
|
||||
return 'zh-Hant';
|
||||
}
|
||||
return locale === 'en-US' ? 'en' : 'zh-Hans';
|
||||
}
|
||||
|
||||
function isBrowser(): boolean {
|
||||
return typeof window !== 'undefined';
|
||||
}
|
||||
@ -271,6 +280,7 @@ export async function sendMessage(
|
||||
replyToScheduledRunId?: string;
|
||||
scheduledReplyIntent?: 'revise_once' | 'update_future' | 'continue_task';
|
||||
thinkingEnabled?: boolean;
|
||||
promptLocale?: PromptLocale;
|
||||
}
|
||||
): Promise<{
|
||||
response?: string;
|
||||
@ -281,7 +291,11 @@ export async function sendMessage(
|
||||
task_status?: string | null;
|
||||
evidence_status?: string | null;
|
||||
}> {
|
||||
const body: Record<string, unknown> = { message, session_id: sessionId };
|
||||
const body: Record<string, unknown> = {
|
||||
message,
|
||||
session_id: sessionId,
|
||||
prompt_locale: options?.promptLocale || promptLocaleForAppLocale(getCurrentAppLocale()),
|
||||
};
|
||||
if (attachments && attachments.length > 0) {
|
||||
body.attachments = attachments;
|
||||
}
|
||||
@ -356,7 +370,11 @@ export function streamMessage(
|
||||
const res = await fetch(buildApiUrl('/api/chat/stream'), {
|
||||
method: 'POST',
|
||||
headers: authHeaders(),
|
||||
body: JSON.stringify({ message, session_id: sessionId }),
|
||||
body: JSON.stringify({
|
||||
message,
|
||||
session_id: sessionId,
|
||||
prompt_locale: promptLocaleForAppLocale(getCurrentAppLocale()),
|
||||
}),
|
||||
signal: controller.signal,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user