Fix: Wrong Citation Display #8594 #8474 (#8671)

### What problem does this PR solve?

Fix: Wrong Citation Display #8594 #8474

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
balibabu
2025-07-04 19:12:13 +08:00
committed by GitHub
parent 7f707ef5ed
commit 39799469d1
2 changed files with 8 additions and 12 deletions

View File

@ -31,7 +31,7 @@ import classNames from 'classnames';
import { pipe } from 'lodash/fp'; import { pipe } from 'lodash/fp';
import styles from './index.less'; import styles from './index.less';
const getChunkIndex = (match: string) => Number(match.slice(2, -2)); const getChunkIndex = (match: string) => Number(match);
// TODO: The display of the table is inconsistent with the display previously placed in the MessageItem. // TODO: The display of the table is inconsistent with the display previously placed in the MessageItem.
const MarkdownContent = ({ const MarkdownContent = ({
reference, reference,
@ -121,7 +121,7 @@ const MarkdownContent = ({
document, document,
}; };
}, },
[fileThumbnails, reference?.chunks, reference?.doc_aggs], [fileThumbnails, reference],
); );
const getPopoverContent = useCallback( const getPopoverContent = useCallback(

View File

@ -29,9 +29,9 @@ export const buildMessageItemReference = (
conversation: { message: IMessage[]; reference: IReference[] }, conversation: { message: IMessage[]; reference: IReference[] },
message: IMessage, message: IMessage,
) => { ) => {
const assistantMessages = conversation.message?.filter( const assistantMessages = conversation.message
(x) => x.role === MessageType.Assistant, ?.filter((x) => x.role === MessageType.Assistant)
); .slice(1);
const referenceIndex = assistantMessages.findIndex( const referenceIndex = assistantMessages.findIndex(
(x) => x.id === message.id, (x) => x.id === message.id,
); );
@ -47,11 +47,7 @@ export const currentReg = /\[ID:(\d+)\]/g;
// To be compatible with the old index matching mode // To be compatible with the old index matching mode
export const replaceTextByOldReg = (text: string) => { export const replaceTextByOldReg = (text: string) => {
return ( return text.replace(oldReg, (substring: string) => {
text return `[ID:${substring.slice(2, -2)}]`;
// ?.replace(currentReg, transformReg) });
.replace(oldReg, (substring: string) => {
return `[ID:${substring.slice(2, -2)}]`;
})
);
}; };