mirror of
https://github.com/langbot-app/LangBot.git
synced 2025-11-25 11:29:39 +08:00
fix: i18n and mcp test
This commit is contained in:
@@ -605,13 +605,80 @@ export default function PluginConfigPage() {
|
||||
.testMCPServer(form.getValues('name'))
|
||||
.then((res) => {
|
||||
console.log(res);
|
||||
toast.success(t('models.testSuccess'));
|
||||
if (res.task_id) {
|
||||
const taskId = res.task_id;
|
||||
|
||||
const interval = setInterval(() => {
|
||||
httpClient
|
||||
.getAsyncTask(taskId)
|
||||
.then((taskResp) => {
|
||||
console.log('Test task response:', taskResp);
|
||||
|
||||
if (taskResp.runtime && taskResp.runtime.done) {
|
||||
clearInterval(interval);
|
||||
setMcpTesting(false);
|
||||
|
||||
if (taskResp.runtime.exception) {
|
||||
toast.error(
|
||||
t('mcp.testError') +
|
||||
': ' +
|
||||
(taskResp.runtime.exception || t('mcp.unknownError')),
|
||||
);
|
||||
} else if (taskResp.runtime.result) {
|
||||
try {
|
||||
let result: {
|
||||
status?: string;
|
||||
tools_count?: number;
|
||||
tools_names_lists?: string[];
|
||||
error?: string;
|
||||
};
|
||||
|
||||
const rawResult: unknown = taskResp.runtime.result;
|
||||
if (typeof rawResult === 'string') {
|
||||
result = JSON.parse(rawResult.replace(/'/g, '"'));
|
||||
} else {
|
||||
result = rawResult as typeof result;
|
||||
}
|
||||
|
||||
if (
|
||||
result.tools_names_lists &&
|
||||
result.tools_names_lists.length > 0
|
||||
) {
|
||||
toast.success(
|
||||
t('mcp.testSuccess') +
|
||||
' - ' +
|
||||
result.tools_names_lists.length +
|
||||
' ' +
|
||||
t('mcp.toolsFound'),
|
||||
);
|
||||
} else {
|
||||
toast.error(t('mcp.testError') + ': ' + t('mcp.noToolsFound'));
|
||||
}
|
||||
} catch (parseError) {
|
||||
console.error('Failed to parse test result:', parseError);
|
||||
toast.error(t('mcp.testError') + ': ' + t('mcp.parseResultFailed'));
|
||||
}
|
||||
} else {
|
||||
toast.error(t('mcp.testError') + ': ' + t('mcp.noResultReturned'));
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('获取测试任务状态失败:', err);
|
||||
clearInterval(interval);
|
||||
setMcpTesting(false);
|
||||
toast.error(t('mcp.testError') + ': ' + (err.message || t('mcp.getTaskFailed')));
|
||||
});
|
||||
}, 1000);
|
||||
} else {
|
||||
setMcpTesting(false);
|
||||
toast.error(t('mcp.testError') + ': ' + t('mcp.noTaskId'));
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
toast.error(t('mcp.testError'));
|
||||
})
|
||||
.finally(() => {
|
||||
.catch((err) => {
|
||||
console.error('启动测试失败:', err);
|
||||
setMcpTesting(false);
|
||||
toast.error(t('mcp.testError') + ': ' + (err.message || t('mcp.unknownError')));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -321,6 +321,12 @@ const enUS = {
|
||||
connectionSuccess: 'Connection successful',
|
||||
connectionFailed: 'Connection failed',
|
||||
toolsFound: 'tools',
|
||||
unknownError: 'Unknown error',
|
||||
noToolsFound: 'No tools found',
|
||||
parseResultFailed: 'Failed to parse test result',
|
||||
noResultReturned: 'Test returned no result',
|
||||
getTaskFailed: 'Failed to get task status',
|
||||
noTaskId: 'No task ID obtained',
|
||||
deleteSuccess: 'Deleted successfully',
|
||||
deleteError: 'Delete failed: ',
|
||||
saveSuccess: 'Saved successfully',
|
||||
|
||||
@@ -323,6 +323,12 @@ const jaJP = {
|
||||
connectionSuccess: '接続に成功しました',
|
||||
connectionFailed: '接続に失敗しました',
|
||||
toolsFound: '個のツール',
|
||||
unknownError: '不明なエラー',
|
||||
noToolsFound: 'ツールが見つかりません',
|
||||
parseResultFailed: 'テスト結果の解析に失敗しました',
|
||||
noResultReturned: 'テスト結果が返されませんでした',
|
||||
getTaskFailed: 'タスクステータスの取得に失敗しました',
|
||||
noTaskId: 'タスクIDを取得できませんでした',
|
||||
deleteSuccess: '削除に成功しました',
|
||||
deleteError: '削除に失敗しました:',
|
||||
saveSuccess: '保存に成功しました',
|
||||
|
||||
@@ -310,6 +310,12 @@ const zhHans = {
|
||||
connectionSuccess: '连接成功',
|
||||
connectionFailed: '连接失败',
|
||||
toolsFound: '个工具',
|
||||
unknownError: '未知错误',
|
||||
noToolsFound: '未找到任何工具',
|
||||
parseResultFailed: '解析测试结果失败',
|
||||
noResultReturned: '测试未返回结果',
|
||||
getTaskFailed: '获取任务状态失败',
|
||||
noTaskId: '未获取到任务ID',
|
||||
deleteSuccess: '删除成功',
|
||||
deleteError: '删除失败:',
|
||||
saveSuccess: '保存成功',
|
||||
|
||||
@@ -307,6 +307,12 @@ const zhHant = {
|
||||
connectionSuccess: '連接成功',
|
||||
connectionFailed: '連接失敗',
|
||||
toolsFound: '個工具',
|
||||
unknownError: '未知錯誤',
|
||||
noToolsFound: '未找到任何工具',
|
||||
parseResultFailed: '解析測試結果失敗',
|
||||
noResultReturned: '測試未返回結果',
|
||||
getTaskFailed: '獲取任務狀態失敗',
|
||||
noTaskId: '未獲取到任務ID',
|
||||
deleteSuccess: '刪除成功',
|
||||
deleteError: '刪除失敗:',
|
||||
saveSuccess: '儲存成功',
|
||||
|
||||
Reference in New Issue
Block a user