refactor: Update chat and knowledge base handling for improved flexibility

- Removed validation for empty knowledge_base_ids in useStream, allowing backend to manage this case.
- Adjusted routing in KnowledgeBase.vue to decouple session creation from knowledge base ID.
- Updated getCurrentKbId function to simplify knowledge base ID retrieval from the route.
- Enhanced comments for clarity regarding knowledge base handling in chat components.
This commit is contained in:
wizardchen
2025-11-07 01:06:25 +08:00
parent 4fb12545c1
commit 288dfbd19e
4 changed files with 15 additions and 40 deletions
+4 -7
View File
@@ -47,14 +47,11 @@ export function useStream() {
}
// Validate knowledge_base_ids for agent-chat requests
// Note: knowledge_base_ids can be empty if user hasn't selected any, but we allow it
// The backend will handle the case when no knowledge bases are selected
const isAgentChat = params.url === '/api/v1/agent-chat';
if (isAgentChat && params.method === 'POST') {
if (!params.knowledge_base_ids || params.knowledge_base_ids.length === 0) {
error.value = "请至少选择一个知识库";
stopStream();
return;
}
}
// Removed validation - allow empty knowledge_base_ids array
// The backend should handle this case appropriately
try {
let url =