import { ApiOutlined, DatabaseOutlined, DeleteOutlined, EditOutlined, PlusOutlined, ToolOutlined } from '@ant-design/icons'; import { Button, Card, Collapse, Input, List, Popconfirm, Space, Tag } from 'antd'; import { Agent } from '../../../../api'; import { STATUS_TAG } from '../../constants'; interface KnowledgeSettingsPanelProps { agent: Agent | null; beforeUploadKnowledge: (file: any) => Promise; onDeleteKnowledge: (fileId: string) => Promise; onCreateSkill: () => void; onEditSkill: (skillId: string) => void; onDeleteSkill: (skillId: string) => Promise; onCreateExternalTool: () => void; onEditExternalTool: (pluginId: string) => void; onDeleteExternalTool: (pluginId: string) => Promise; } export default function KnowledgeSettingsPanel({ agent, beforeUploadKnowledge, onDeleteKnowledge, onCreateSkill, onEditSkill, onDeleteSkill, onCreateExternalTool, onEditExternalTool, onDeleteExternalTool, }: KnowledgeSettingsPanelProps) { const skills = agent?.skills ?? []; const plugins = agent?.plugins ?? []; return ( 知识库 ({agent?.knowledge?.length ?? 0}) ), children: (
上传文档以增强 AI 知识 { const files = event.target.files; if (!files) return; for (let index = 0; index < files.length; index++) { await beforeUploadKnowledge(files[index]); } event.target.value = ''; }} />
( onDeleteKnowledge(item.id)}> , ]} >
{item.originalName} {item.size ? `${(item.size / 1024).toFixed(1)} KB` : ''} ·{' '} {item.status === 'indexing' ? ( 索引中… ) : ( {STATUS_TAG[item.status as keyof typeof STATUS_TAG]?.text || item.status || '未知'} )}
)} />
), }, { key: 'skills', label: (
技能 & 工具 ({skills.length + plugins.length})
), children: (
Markdown 技能与外部 API 工具集分别管理
Skills {skills.length}
( } onClick={() => onEditSkill(item.id)}> 编辑 , onDeleteSkill(item.id)}> , ]} > {item.filename || item.name}} description={
{item.description || '暂无描述'}
{item.filename && item.filename !== item.name &&
{item.name}
}
} /> {item.type} {item.enabled ? '已启用' : '未启用'}
)} />
外部工具集 {plugins.length}
{plugins.length === 0 ? (
暂无外部工具集
) : ( {plugins.map((plugin) => ( {plugin.name} {plugin.enabled ? '已启用' : '未启用'} } extra={ onDeleteExternalTool(plugin.id)}> } >
{plugin.description || '暂无描述'}
{plugin.authType || 'none'} {plugin.baseUrl} {plugin.apis?.length ?? 0} 个 API ({ key: api.id || api.name, label: ( {api.method} {api.name} {api.path} ), children: (
{api.description || '暂无描述'}
headers
{JSON.stringify(api.headers || {}, null, 2)}
parametersSchema
{JSON.stringify(api.parametersSchema || {}, null, 2)}
), })) || []} /> ))} )}
), }, ]} /> ); }