feat: Enhance chat and knowledge base functionalities with multi-KB support

- Updated agentChat API to accept optional knowledge_base_ids and agent_enabled parameters.
- Introduced getSession API to retrieve session details.
- Modified useStream to validate knowledge_base_ids for agent-chat requests and prepare POST body accordingly.
- Enhanced createKnowledgeBase API to include additional configuration options.
- Refactored chat routing to remove knowledge base ID from the chat path, allowing for dynamic knowledge base selection.
- Improved session management by preventing duplicate session entries in the menu store.
- Updated UI components for better session handling and display.
- Added context management for agent conversations to improve state persistence across sessions.
This commit is contained in:
wizardchen
2025-11-06 21:12:26 +08:00
parent 602e8a3b88
commit 266b9a5943
41 changed files with 3188 additions and 1746 deletions
+5 -1
View File
@@ -25,7 +25,11 @@ export const useMenuStore = defineStore('menuStore', {
this.menuArr[1].children = reactive<object[]>([]);
},
updatemenuArr(obj: any) {
this.menuArr[1].children?.push(obj);
// 检查是否已存在相同 ID 的 session,避免重复添加
const exists = this.menuArr[1].children?.some((item: any) => item.id === obj.id);
if (!exists) {
this.menuArr[1].children?.push(obj);
}
},
updataMenuChildren(item: object) {
this.menuArr[1].children?.unshift(item)
+12 -4
View File
@@ -3,7 +3,8 @@ import { defineStore } from 'pinia'
export const useUIStore = defineStore('ui', {
state: () => ({
showSettingsModal: false,
showKBSettingsModal: false,
showKBEditorModal: false,
kbEditorMode: 'create' as 'create' | 'edit',
currentKBId: null as string | null,
settingsInitialSection: null as string | null,
settingsInitialSubSection: null as string | null
@@ -28,11 +29,18 @@ export const useUIStore = defineStore('ui', {
openKBSettings(kbId: string) {
this.currentKBId = kbId
this.showKBSettingsModal = true
this.kbEditorMode = 'edit'
this.showKBEditorModal = true
},
closeKBSettings() {
this.showKBSettingsModal = false
openCreateKB() {
this.currentKBId = null
this.kbEditorMode = 'create'
this.showKBEditorModal = true
},
closeKBEditor() {
this.showKBEditorModal = false
this.currentKBId = null
}
}