feat: Implement manual knowledge editing and enhance knowledge base features

- Added functionality for manual knowledge entry, allowing users to create and edit Markdown content directly in the browser.
- Introduced new API endpoints for creating and updating manual knowledge entries.
- Enhanced UI components to support the new manual knowledge editor, including integration with existing knowledge base features.
- Updated knowledge retrieval logic to accommodate manual entries, ensuring seamless user experience across knowledge types.
- Improved agent configuration to support custom system prompts, enhancing flexibility in agent responses.
This commit is contained in:
wizardchen
2025-11-12 21:27:56 +08:00
parent a342a0aa14
commit 69f3f30d83
36 changed files with 3495 additions and 412 deletions
+45 -6
View File
@@ -39,13 +39,20 @@
{{ kb.name }}
</div>
</div>
<t-popup overlayInnerClassName="upload-popup" class="placement top center" content="上传知识"
<t-popup overlayInnerClassName="upload-popup" class="placement top center" content="上传文档 / 在线编辑(支持拖拽上传)"
placement="top" show-arrow destroy-on-close>
<div class="upload-file-wrap" @click.stop="uploadFile" variant="outline"
v-if="item.path === 'knowledge-bases' && $route.name === 'knowledgeBaseDetail'">
<img class="upload-file-icon" :class="[item.path == currentpath ? 'active-upload' : '']"
:src="getImgSrc(fileAddIcon)" alt="">
</div>
<t-dropdown
v-if="item.path === 'knowledge-bases' && $route.name === 'knowledgeBaseDetail'"
trigger="click"
:options="uploadActionOptions"
placement="right"
@click="handleUploadAction"
>
<div class="upload-file-wrap" variant="outline">
<img class="upload-file-icon" :class="[item.path == currentpath ? 'active-upload' : '']"
:src="getImgSrc(fileAddIcon)" alt="">
</div>
</t-dropdown>
</t-popup>
</div>
<div ref="submenuscrollContainer" @scroll="handleScroll" class="submenu" v-if="item.children">
@@ -262,6 +269,10 @@ const kbMenuItem = computed(() => {
})
const loading = ref(false)
const uploadActionOptions = [
{ content: '上传文档', value: 'upload' },
{ content: '在线编辑', value: 'manual' },
]
const uploadFile = async () => {
// 获取当前知识库ID
const currentKbId = await getCurrentKbId();
@@ -287,6 +298,34 @@ const uploadFile = async () => {
uploadInput.value.click()
}
const openManualEditor = async () => {
const currentKbId = await getCurrentKbId();
if (!currentKbId) {
MessagePlugin.warning("请选择知识库");
return;
}
uiStore.openManualEditor({
mode: 'create',
kbId: currentKbId,
status: 'draft',
onSuccess: ({ kbId }) => {
if (kbId) {
window.dispatchEvent(new CustomEvent('knowledgeFileUploaded', {
detail: { kbId }
}));
}
},
});
}
const handleUploadAction = async (data: { value: string }) => {
if (data.value === 'upload') {
uploadFile();
return;
}
if (data.value === 'manual') {
openManualEditor();
}
}
const upload = async (e: any) => {
const file = e.target.files[0];
if (!file) return;