- {result.tools_count !== undefined && (
-
- 可用工具数:
- {result.tools_count}
-
- )}
- {result.response_time_ms !== undefined && (
-
- 响应时间:
- {result.response_time_ms}ms
-
- )}
+
+
+
可用工具数
+
{result.tools_count || 0}
+
+
+
总响应时间
+
{result.response_time_ms?.toFixed(0) || 0}ms
+
+
+
+ {aiChoice && (
+
+ 🤖 AI选择的工具
+ {aiChoice}
+ {callTime && {callTime}}
)}
-
+ {paramsStr && (
+
+
📝 调用参数
+
+ {(() => { try { return JSON.stringify(JSON.parse(paramsStr), null, 2); } catch { return paramsStr; } })()}
+
+
+ )}
+
+ {resultStr && (
+
+
📊 返回结果预览
+
+ {resultStr}
+
+
+ )}
+
+
),
});
@@ -248,7 +358,7 @@ export default function MCPPluginsPage() {
),
});
}
- } catch (error: any) {
+ } catch {
message.error('测试插件失败');
} finally {
setTestingPluginId(null);
@@ -260,17 +370,181 @@ export default function MCPPluginsPage() {
const result = await mcpPluginApi.getPluginTools(pluginId);
setViewingTools({ pluginId, tools: result.tools });
} catch (error) {
+ console.error('Get tools failed:', error);
message.error('获取工具列表失败');
}
};
- const handleSubmit = async (values: any) => {
+ const handleCheckFunctionCalling = async () => {
+ // 从设置中获取当前配置
+ setCheckingFunctionCalling(true);
+ try {
+ const settings = await settingsApi.getSettings();
+
+ if (!settings.api_key || !settings.llm_model) {
+ message.warning('请先在设置页面配置 API Key 和模型');
+ return;
+ }
+
+ const result = await settingsApi.checkFunctionCalling({
+ api_key: settings.api_key,
+ api_base_url: settings.api_base_url || '',
+ provider: settings.api_provider || 'openai',
+ llm_model: settings.llm_model,
+ });
+
+ // 无论成功失败,都缓存当前测试的配置和状态
+ const configToCache = {
+ provider: settings.api_provider,
+ baseUrl: settings.api_base_url,
+ model: settings.llm_model,
+ status: result.success && result.supported ? 'supported' : 'unsupported',
+ testedAt: new Date().toISOString()
+ };
+ localStorage.setItem('mcp_verified_config', JSON.stringify(configToCache));
+
+ if (result.success && result.supported) {
+ setModelSupportStatus('supported');
+
+ modal.success({
+ title: '✅ Function Calling 支持检测',
+ centered: true,
+ width: isMobile ? '95%' : 700,
+ content: (
+
+
+
+ ✓ {result.message}
+
+
+
+
+
+
API 提供商
+
{result.provider}
+
+
+
响应时间
+
{result.response_time_ms?.toFixed(0) || 0}ms
+
+
+
+
+ 🔧 模型信息
+ {result.model}
+ {result.details?.finish_reason && (
+ finish_reason: {result.details.finish_reason}
+ )}
+
+
+ {result.details && (
+
+
📊 检测详情
+
+
✓ 工具调用数量: {result.details.tool_call_count || 0}
+
✓ 测试工具: {result.details.test_tool || 'N/A'}
+
✓ 响应类型: {result.details.response_type || 'N/A'}
+
+
+ )}
+
+ {result.tool_calls && result.tool_calls.length > 0 && (
+
+
🔨 工具调用示例
+
+ {JSON.stringify(result.tool_calls[0], null, 2)}
+
+
+ )}
+
+ {result.suggestions && result.suggestions.length > 0 && (
+
+
💡 建议
+
+ {result.suggestions.map((s: string, i: number) => (
+ - {s}
+ ))}
+
+
+ )}
+
+ ),
+ });
+ } else {
+ setModelSupportStatus('unsupported');
+ modal.warning({
+ title: '❌ Function Calling 支持检测',
+ centered: true,
+ width: isMobile ? '95%' : 700,
+ content: (
+
+
+
+ {result.error && (
+
+ 错误信息:
+
+ {result.error}
+
+
+ )}
+
+ {result.response_preview && (
+
+
📝 模型返回内容(前200字符)
+
+ {result.response_preview}
+
+
+ )}
+
+ {result.suggestions && result.suggestions.length > 0 && (
+
+
💡 建议:
+
+ {result.suggestions.map((s: string, i: number) => (
+ - {s}
+ ))}
+
+
+ )}
+
+ ),
+ });
+ }
+ } catch (error) {
+ console.error('Check function calling failed:', error);
+ message.error('检测失败,请稍后重试');
+ setModelSupportStatus('unsupported');
+ } finally {
+ setCheckingFunctionCalling(false);
+ }
+ };
+
+ const handleSubmit = async (values: { config_json: string; enabled: boolean; category?: string }) => {
setLoading(true);
try {
// 验证JSON格式
try {
JSON.parse(values.config_json);
- } catch (e) {
+ } catch {
message.error('配置JSON格式错误,请检查');
setLoading(false);
return;
@@ -289,8 +563,9 @@ export default function MCPPluginsPage() {
setModalVisible(false);
form.resetFields();
loadPlugins();
- } catch (error: any) {
- const errorMsg = error?.response?.data?.detail || '操作失败';
+ } catch (error: unknown) {
+ const err = error as { response?: { data?: { detail?: string } } };
+ const errorMsg = err?.response?.data?.detail || '操作失败';
message.error(errorMsg);
} finally {
setLoading(false);
@@ -407,38 +682,104 @@ export default function MCPPluginsPage() {
- {/* 使用提示 */}
-