balibabu
commited on
Commit
·
faaabea
1
Parent(s):
a432686
Feat: Exclude reference from the data returned by the conversation/get interface #3909 (#3962)
Browse files### 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)
web/src/components/message-item/index.tsx
CHANGED
|
@@ -39,7 +39,7 @@ const MessageItem = ({
|
|
| 39 |
item,
|
| 40 |
reference,
|
| 41 |
loading = false,
|
| 42 |
-
avatar
|
| 43 |
sendLoading = false,
|
| 44 |
clickDocumentButton,
|
| 45 |
index,
|
|
@@ -102,13 +102,7 @@ const MessageItem = ({
|
|
| 102 |
})}
|
| 103 |
>
|
| 104 |
{item.role === MessageType.User ? (
|
| 105 |
-
<Avatar
|
| 106 |
-
size={40}
|
| 107 |
-
src={
|
| 108 |
-
avatar ??
|
| 109 |
-
'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png'
|
| 110 |
-
}
|
| 111 |
-
/>
|
| 112 |
) : (
|
| 113 |
<AssistantIcon></AssistantIcon>
|
| 114 |
)}
|
|
|
|
| 39 |
item,
|
| 40 |
reference,
|
| 41 |
loading = false,
|
| 42 |
+
avatar,
|
| 43 |
sendLoading = false,
|
| 44 |
clickDocumentButton,
|
| 45 |
index,
|
|
|
|
| 102 |
})}
|
| 103 |
>
|
| 104 |
{item.role === MessageType.User ? (
|
| 105 |
+
<Avatar size={40} src={avatar ?? '/logo.svg'} />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
) : (
|
| 107 |
<AssistantIcon></AssistantIcon>
|
| 108 |
)}
|
web/src/pages/chat/utils.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import { MessageType } from '@/constants/chat';
|
| 2 |
import { IConversation, IReference } from '@/interfaces/database/chat';
|
|
|
|
| 3 |
import { EmptyConversationId } from './constants';
|
| 4 |
import { IMessage } from './interface';
|
| 5 |
|
|
@@ -34,9 +35,9 @@ export const buildMessageItemReference = (
|
|
| 34 |
const referenceIndex = assistantMessages.findIndex(
|
| 35 |
(x) => x.id === message.id,
|
| 36 |
);
|
| 37 |
-
const reference = message?.reference
|
| 38 |
? message?.reference
|
| 39 |
-
: (conversation?.reference ??
|
| 40 |
|
| 41 |
-
return reference;
|
| 42 |
};
|
|
|
|
| 1 |
import { MessageType } from '@/constants/chat';
|
| 2 |
import { IConversation, IReference } from '@/interfaces/database/chat';
|
| 3 |
+
import { isEmpty } from 'lodash';
|
| 4 |
import { EmptyConversationId } from './constants';
|
| 5 |
import { IMessage } from './interface';
|
| 6 |
|
|
|
|
| 35 |
const referenceIndex = assistantMessages.findIndex(
|
| 36 |
(x) => x.id === message.id,
|
| 37 |
);
|
| 38 |
+
const reference = !isEmpty(message?.reference)
|
| 39 |
? message?.reference
|
| 40 |
+
: (conversation?.reference ?? [])[referenceIndex];
|
| 41 |
|
| 42 |
+
return reference ?? { doc_aggs: [], chunks: [], total: 0 };
|
| 43 |
};
|
web/src/utils/chat.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import { EmptyConversationId, MessageType } from '@/constants/chat';
|
| 2 |
import { Message } from '@/interfaces/database/chat';
|
| 3 |
import { IMessage } from '@/pages/chat/interface';
|
|
|
|
| 4 |
import { v4 as uuid } from 'uuid';
|
| 5 |
|
| 6 |
export const isConversationIdExist = (conversationId: string) => {
|
|
@@ -27,7 +28,7 @@ export const getMessagePureId = (id?: string) => {
|
|
| 27 |
export const buildMessageListWithUuid = (messages?: Message[]) => {
|
| 28 |
return (
|
| 29 |
messages?.map((x: Message | IMessage) => ({
|
| 30 |
-
...x,
|
| 31 |
id: buildMessageUuid(x),
|
| 32 |
})) ?? []
|
| 33 |
);
|
|
|
|
| 1 |
import { EmptyConversationId, MessageType } from '@/constants/chat';
|
| 2 |
import { Message } from '@/interfaces/database/chat';
|
| 3 |
import { IMessage } from '@/pages/chat/interface';
|
| 4 |
+
import { omit } from 'lodash';
|
| 5 |
import { v4 as uuid } from 'uuid';
|
| 6 |
|
| 7 |
export const isConversationIdExist = (conversationId: string) => {
|
|
|
|
| 28 |
export const buildMessageListWithUuid = (messages?: Message[]) => {
|
| 29 |
return (
|
| 30 |
messages?.map((x: Message | IMessage) => ({
|
| 31 |
+
...omit(x, 'reference'),
|
| 32 |
id: buildMessageUuid(x),
|
| 33 |
})) ?? []
|
| 34 |
);
|