mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-14 19:25:54 +08:00
### What problem does this PR solve? Feat: Exclude reference from the data returned by the conversation/get interface #3909 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
parent
fc4e644e5f
commit
601d74160b
@ -39,7 +39,7 @@ const MessageItem = ({
|
|||||||
item,
|
item,
|
||||||
reference,
|
reference,
|
||||||
loading = false,
|
loading = false,
|
||||||
avatar = '',
|
avatar,
|
||||||
sendLoading = false,
|
sendLoading = false,
|
||||||
clickDocumentButton,
|
clickDocumentButton,
|
||||||
index,
|
index,
|
||||||
@ -102,13 +102,7 @@ const MessageItem = ({
|
|||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
{item.role === MessageType.User ? (
|
{item.role === MessageType.User ? (
|
||||||
<Avatar
|
<Avatar size={40} src={avatar ?? '/logo.svg'} />
|
||||||
size={40}
|
|
||||||
src={
|
|
||||||
avatar ??
|
|
||||||
'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png'
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
) : (
|
) : (
|
||||||
<AssistantIcon></AssistantIcon>
|
<AssistantIcon></AssistantIcon>
|
||||||
)}
|
)}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { MessageType } from '@/constants/chat';
|
import { MessageType } from '@/constants/chat';
|
||||||
import { IConversation, IReference } from '@/interfaces/database/chat';
|
import { IConversation, IReference } from '@/interfaces/database/chat';
|
||||||
|
import { isEmpty } from 'lodash';
|
||||||
import { EmptyConversationId } from './constants';
|
import { EmptyConversationId } from './constants';
|
||||||
import { IMessage } from './interface';
|
import { IMessage } from './interface';
|
||||||
|
|
||||||
@ -34,9 +35,9 @@ export const buildMessageItemReference = (
|
|||||||
const referenceIndex = assistantMessages.findIndex(
|
const referenceIndex = assistantMessages.findIndex(
|
||||||
(x) => x.id === message.id,
|
(x) => x.id === message.id,
|
||||||
);
|
);
|
||||||
const reference = message?.reference
|
const reference = !isEmpty(message?.reference)
|
||||||
? message?.reference
|
? message?.reference
|
||||||
: (conversation?.reference ?? {})[referenceIndex];
|
: (conversation?.reference ?? [])[referenceIndex];
|
||||||
|
|
||||||
return reference;
|
return reference ?? { doc_aggs: [], chunks: [], total: 0 };
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { EmptyConversationId, MessageType } from '@/constants/chat';
|
import { EmptyConversationId, MessageType } from '@/constants/chat';
|
||||||
import { Message } from '@/interfaces/database/chat';
|
import { Message } from '@/interfaces/database/chat';
|
||||||
import { IMessage } from '@/pages/chat/interface';
|
import { IMessage } from '@/pages/chat/interface';
|
||||||
|
import { omit } from 'lodash';
|
||||||
import { v4 as uuid } from 'uuid';
|
import { v4 as uuid } from 'uuid';
|
||||||
|
|
||||||
export const isConversationIdExist = (conversationId: string) => {
|
export const isConversationIdExist = (conversationId: string) => {
|
||||||
@ -27,7 +28,7 @@ export const getMessagePureId = (id?: string) => {
|
|||||||
export const buildMessageListWithUuid = (messages?: Message[]) => {
|
export const buildMessageListWithUuid = (messages?: Message[]) => {
|
||||||
return (
|
return (
|
||||||
messages?.map((x: Message | IMessage) => ({
|
messages?.map((x: Message | IMessage) => ({
|
||||||
...x,
|
...omit(x, 'reference'),
|
||||||
id: buildMessageUuid(x),
|
id: buildMessageUuid(x),
|
||||||
})) ?? []
|
})) ?? []
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user