diff --git a/web/src/pages/chat/markdown-content/index.tsx b/web/src/pages/chat/markdown-content/index.tsx index 61b27347d..2d6393d42 100644 --- a/web/src/pages/chat/markdown-content/index.tsx +++ b/web/src/pages/chat/markdown-content/index.tsx @@ -31,7 +31,7 @@ import classNames from 'classnames'; import { pipe } from 'lodash/fp'; 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. const MarkdownContent = ({ reference, @@ -121,7 +121,7 @@ const MarkdownContent = ({ document, }; }, - [fileThumbnails, reference?.chunks, reference?.doc_aggs], + [fileThumbnails, reference], ); const getPopoverContent = useCallback( diff --git a/web/src/pages/chat/utils.ts b/web/src/pages/chat/utils.ts index a36f08f3e..aa5cadd09 100644 --- a/web/src/pages/chat/utils.ts +++ b/web/src/pages/chat/utils.ts @@ -29,9 +29,9 @@ export const buildMessageItemReference = ( conversation: { message: IMessage[]; reference: IReference[] }, message: IMessage, ) => { - const assistantMessages = conversation.message?.filter( - (x) => x.role === MessageType.Assistant, - ); + const assistantMessages = conversation.message + ?.filter((x) => x.role === MessageType.Assistant) + .slice(1); const referenceIndex = assistantMessages.findIndex( (x) => x.id === message.id, ); @@ -47,11 +47,7 @@ export const currentReg = /\[ID:(\d+)\]/g; // To be compatible with the old index matching mode export const replaceTextByOldReg = (text: string) => { - return ( - text - // ?.replace(currentReg, transformReg) - .replace(oldReg, (substring: string) => { - return `[ID:${substring.slice(2, -2)}]`; - }) - ); + return text.replace(oldReg, (substring: string) => { + return `[ID:${substring.slice(2, -2)}]`; + }); };