diff --git a/web/reducer.js b/web/reducer.js
deleted file mode 100644
index 5a8d5cc6f..000000000
--- a/web/reducer.js
+++ /dev/null
@@ -1,26 +0,0 @@
-import React, { useReducer } from 'react';
-const CHANGE_LOCALE = 'CHANGE_LOCALE';
-
-const mainContext = React.createContext();
-
-const reducer = (state, action) => {
- switch (action.type) {
- case CHANGE_LOCALE:
- return { ...state, locale: action.locale || 'zh' };
- default:
- return state;
- }
-};
-
-const ContextProvider = (props) => {
- const [state, dispatch] = useReducer(reducer, {
- locale: 'zh',
- });
- return (
-
- {props.children}
-
- );
-};
-
-export { ContextProvider, mainContext, reducer };
diff --git a/web/src/pages/chat/markdown-content/index.tsx b/web/src/pages/chat/markdown-content/index.tsx
index 5e0d30c20..d4acf95e6 100644
--- a/web/src/pages/chat/markdown-content/index.tsx
+++ b/web/src/pages/chat/markdown-content/index.tsx
@@ -20,9 +20,10 @@ import { useTranslation } from 'react-i18next';
import 'katex/dist/katex.min.css'; // `rehype-katex` does not import the CSS for you
+import { replaceTextByOldReg } from '../utils';
import styles from './index.less';
-const reg = /(#{2}\d+\${2})/g;
+const reg = /(#{2}\d+@{2})/g;
const curReg = /(~{2}\d+\${2})/g;
const getChunkIndex = (match: string) => Number(match.slice(2, -2));
@@ -156,7 +157,9 @@ const MarkdownContent = ({
const renderReference = useCallback(
(text: string) => {
- let replacedText = reactStringReplace(text, reg, (match, i) => {
+ const nextText = replaceTextByOldReg(text);
+
+ let replacedText = reactStringReplace(nextText, reg, (match, i) => {
const chunkIndex = getChunkIndex(match);
return (
diff --git a/web/src/pages/chat/utils.ts b/web/src/pages/chat/utils.ts
index 820bd2ca5..3c8bef706 100644
--- a/web/src/pages/chat/utils.ts
+++ b/web/src/pages/chat/utils.ts
@@ -41,3 +41,11 @@ export const buildMessageItemReference = (
return reference ?? { doc_aggs: [], chunks: [], total: 0 };
};
+
+const oldReg = /(#{2}\d+\${2})/g;
+
+export const replaceTextByOldReg = (text: string) => {
+ return text.replace(oldReg, function (substring) {
+ return `${substring.slice(0, -2)}@@`;
+ });
+};