### 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
3 changed files with 8 additions and 12 deletions
|
|
@ -39,7 +39,7 @@ const MessageItem = ({
|
|||
item,
|
||||
reference,
|
||||
loading = false,
|
||||
avatar = '',
|
||||
avatar,
|
||||
sendLoading = false,
|
||||
clickDocumentButton,
|
||||
index,
|
||||
|
|
@ -102,13 +102,7 @@ const MessageItem = ({
|
|||
})}
|
||||
>
|
||||
{item.role === MessageType.User ? (
|
||||
<Avatar
|
||||
size={40}
|
||||
src={
|
||||
avatar ??
|
||||
'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png'
|
||||
}
|
||||
/>
|
||||
<Avatar size={40} src={avatar ?? '/logo.svg'} />
|
||||
) : (
|
||||
<AssistantIcon></AssistantIcon>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { MessageType } from '@/constants/chat';
|
||||
import { IConversation, IReference } from '@/interfaces/database/chat';
|
||||
import { isEmpty } from 'lodash';
|
||||
import { EmptyConversationId } from './constants';
|
||||
import { IMessage } from './interface';
|
||||
|
||||
|
|
@ -34,9 +35,9 @@ export const buildMessageItemReference = (
|
|||
const referenceIndex = assistantMessages.findIndex(
|
||||
(x) => x.id === message.id,
|
||||
);
|
||||
const reference = message?.reference
|
||||
const reference = !isEmpty(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 { Message } from '@/interfaces/database/chat';
|
||||
import { IMessage } from '@/pages/chat/interface';
|
||||
import { omit } from 'lodash';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
|
||||
export const isConversationIdExist = (conversationId: string) => {
|
||||
|
|
@ -27,7 +28,7 @@ export const getMessagePureId = (id?: string) => {
|
|||
export const buildMessageListWithUuid = (messages?: Message[]) => {
|
||||
return (
|
||||
messages?.map((x: Message | IMessage) => ({
|
||||
...x,
|
||||
...omit(x, 'reference'),
|
||||
id: buildMessageUuid(x),
|
||||
})) ?? []
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue