mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-04 23:00:30 +08:00
Fix: Deleting temporary chat resulted in an error. (#17694)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { currentReg, parseCitationIndex } from '@/utils/chat';
|
||||
|
||||
export const extractNumbersFromMessageContent = (content: string) => {
|
||||
const matches = content.match(currentReg);
|
||||
const matches = content?.match(currentReg);
|
||||
if (matches) {
|
||||
const list = matches
|
||||
.map((match) => {
|
||||
|
||||
@@ -15,7 +15,7 @@ export const useFindPrologueFromDialogList = () => {
|
||||
const { data } = useFetchChatList();
|
||||
|
||||
const prologue = useMemo(() => {
|
||||
return data.chats.find((x) => x.id === dialogId)?.prompt_config?.prologue;
|
||||
return data?.chats.find((x) => x.id === dialogId)?.prompt_config?.prologue;
|
||||
}, [dialogId, data]);
|
||||
|
||||
return prologue;
|
||||
@@ -74,7 +74,14 @@ export const useSelectDerivedConversationList = () => {
|
||||
// When you first enter the page, select the top conversation card
|
||||
|
||||
useEffect(() => {
|
||||
setList([...conversationList]);
|
||||
setList((prevList) => {
|
||||
const tempItems = prevList.filter((item) => item.is_new);
|
||||
const existingTempIds = new Set(tempItems.map((t) => t.id));
|
||||
const newItems = conversationList.filter(
|
||||
(item) => !existingTempIds.has(item.id),
|
||||
);
|
||||
return [...tempItems, ...newItems];
|
||||
});
|
||||
}, [conversationList]);
|
||||
|
||||
return {
|
||||
|
||||
@@ -34,7 +34,8 @@ export const buildMessageItemReference = (
|
||||
const assistantMessages = conversation.messages
|
||||
?.filter(
|
||||
(x) =>
|
||||
x.role === MessageType.Assistant && !x.content.startsWith('**ERROR**:'), // Exclude error messages
|
||||
x.role === MessageType.Assistant &&
|
||||
!x.content?.startsWith('**ERROR**:'), // Exclude error messages
|
||||
)
|
||||
.slice(1);
|
||||
const referenceIndex = assistantMessages.findIndex(
|
||||
|
||||
Reference in New Issue
Block a user