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
+8 -5
View File
@@ -50,7 +50,7 @@ async function createNewSession(value: string) {
try {
const res = await createSessions(sessionData);
if (res.data && res.data.id) {
await navigateToSession(res.data.id, value, selectedKbs[0]);
await navigateToSession(res.data.id, value);
} else {
console.error("创建会话失败");
MessagePlugin.error("创建会话失败");
@@ -61,18 +61,21 @@ async function createNewSession(value: string) {
}
}
const navigateToSession = async (sessionId: string, value: string, kbId: string) => {
const navigateToSession = async (sessionId: string, value: string) => {
const now = new Date().toISOString();
let obj = {
title: '新会话',
path: `chat/${kbId}/${sessionId}`,
path: `chat/${sessionId}`,
id: sessionId,
isMore: false,
isNoTitle: true
isNoTitle: true,
created_at: now,
updated_at: now
};
usemenuStore.updataMenuChildren(obj);
usemenuStore.changeIsFirstSession(true);
usemenuStore.changeFirstQuery(value);
router.push(`/platform/chat/${kbId}/${sessionId}`);
router.push(`/platform/chat/${sessionId}`);
}
</script>