diff --git a/src/icons/icons.js b/src/icons/icons.js
index 364ba22..fa296b6 100644
--- a/src/icons/icons.js
+++ b/src/icons/icons.js
@@ -120,4 +120,6 @@ export const icons = {
plus: ``,
+ building: ``,
+ group:``
};
diff --git a/src/pages/Chat/ChatWindow.jsx b/src/pages/Chat/ChatWindow.jsx
index a2ecbff..fe1782c 100644
--- a/src/pages/Chat/ChatWindow.jsx
+++ b/src/pages/Chat/ChatWindow.jsx
@@ -254,24 +254,22 @@ export default function ChatWindow({ chatId, knowledgeBaseId }) {
) : (
)}
+ {message.is_streaming && (
+
+
+
+
+
+ )}
{message.created_at && new Date(message.created_at).toLocaleTimeString()}
+ {message.is_streaming && ' · 正在生成...'}
))}
- {sendStatus === 'loading' && (
-
- )}
-
diff --git a/src/pages/Chat/NewChat.jsx b/src/pages/Chat/NewChat.jsx
index 08d76dd..69ede59 100644
--- a/src/pages/Chat/NewChat.jsx
+++ b/src/pages/Chat/NewChat.jsx
@@ -74,6 +74,9 @@ export default function NewChat() {
try {
setIsNavigating(true);
+ // 打印调试信息
+ console.log('选中的知识库ID:', selectedDatasetIds);
+
// 检查是否已存在包含所有选中知识库的聊天记录
// 注意:这里的逻辑简化了,实际可能需要更复杂的匹配算法
const existingChat = chatHistory.find((chat) => {
@@ -110,30 +113,49 @@ export default function NewChat() {
// 创建新的聊天记录
const formattedIds = selectedDatasetIds.map((id) => id.replace(/-/g, ''));
- const response = await dispatch(
- createChatRecord({
- dataset_id_list: formattedIds,
- question: '选择当前知识库,创建聊天',
- })
- ).unwrap();
+ console.log('格式化后的知识库ID:', formattedIds);
- if (response && response.conversation_id) {
- // 使用第一个知识库ID作为URL参数
- const primaryDatasetId = selectedDatasetIds[0];
- console.log(`创建成功,导航到 /chat/${primaryDatasetId}/${response.conversation_id}`);
- navigate(`/chat/${primaryDatasetId}/${response.conversation_id}`);
- } else {
- throw new Error('未能获取会话ID');
+ try {
+ // 尝试创建聊天记录
+ const response = await dispatch(
+ createChatRecord({
+ dataset_id_list: formattedIds,
+ question: '选择当前知识库,创建聊天',
+ })
+ ).unwrap();
+
+ console.log('创建聊天响应:', response);
+
+ if (response && response.conversation_id) {
+ // 使用第一个知识库ID作为URL参数
+ const primaryDatasetId = selectedDatasetIds[0];
+ console.log(`创建成功,导航到 /chat/${primaryDatasetId}/${response.conversation_id}`);
+ navigate(`/chat/${primaryDatasetId}/${response.conversation_id}`);
+ } else {
+ throw new Error('未能获取会话ID:' + JSON.stringify(response));
+ }
+ } catch (apiError) {
+ // 专门处理API调用错误
+ console.error('API调用失败:', apiError);
+ throw new Error(`API调用失败: ${apiError.message || '未知错误'}`);
}
}
} catch (error) {
console.error('导航或创建聊天失败:', error);
+
+ // 添加更详细的错误日志
+ if (error.stack) {
+ console.error('错误堆栈:', error.stack);
+ }
+
+ // 显示更友好的错误消息
dispatch(
showNotification({
message: `创建聊天失败: ${error.message || '请重试'}`,
type: 'danger',
})
);
+ } finally {
setIsNavigating(false);
}
};
diff --git a/src/pages/KnowledgeBase/components/KnowledgeCard.jsx b/src/pages/KnowledgeBase/components/KnowledgeCard.jsx
index 8fe7ed2..9649023 100644
--- a/src/pages/KnowledgeBase/components/KnowledgeCard.jsx
+++ b/src/pages/KnowledgeBase/components/KnowledgeCard.jsx
@@ -58,6 +58,9 @@ export default function KnowledgeCard({
)}
+
+ {department || ''} {group || 'N/A'}
+
{description}
@@ -95,6 +98,7 @@ export default function KnowledgeCard({
)}
{access === 'full' || access === 'read' ? (
<>>
+ ) : (
//
// 新聊天
//
- ) : (