Files
ragflow/web/src/pages/data-flow/utils/chat.ts
balibabu cb14dafaca Feat: Initialize the data pipeline canvas. #9869 (#9870)
### What problem does this PR solve?
Feat: Initialize the data pipeline canvas. #9869

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
2025-09-02 15:47:33 +08:00

22 lines
727 B
TypeScript

import { MessageType } from '@/constants/chat';
import { IReference } from '@/interfaces/database/chat';
import { IMessage } from '@/pages/chat/interface';
import { isEmpty } from 'lodash';
export const buildAgentMessageItemReference = (
conversation: { message: IMessage[]; reference: IReference[] },
message: IMessage,
) => {
const assistantMessages = conversation.message?.filter(
(x) => x.role === MessageType.Assistant,
);
const referenceIndex = assistantMessages.findIndex(
(x) => x.id === message.id,
);
const reference = !isEmpty(message?.reference)
? message?.reference
: (conversation?.reference ?? [])[referenceIndex];
return reference ?? { doc_aggs: [], chunks: [], total: 0 };
};