Feat: Exclude reference from the data returned by the conversation/get interface #3909 (#3962)

### 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:
balibabu
2024-12-10 16:46:47 +08:00
committed by GitHub
parent fc4e644e5f
commit 601d74160b
3 changed files with 8 additions and 12 deletions

View File

@ -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 };
};