diff --git a/src/frontend/public/locales/en/bs.json b/src/frontend/public/locales/en/bs.json index e3b4e9294..4f90ec4eb 100644 --- a/src/frontend/public/locales/en/bs.json +++ b/src/frontend/public/locales/en/bs.json @@ -254,7 +254,8 @@ "file": "File", "sizeExceedsLimit": "Size exceeds 50MB", "editDictionary": "Edit Dictionary", - "exportCodeDialogTip": "Generate code to integrate the workflow into an external application (please make sure to build the skill before opening this page)." + "exportCodeDialogTip": "Generate code to integrate the workflow into an external application (please make sure to build the skill before opening this page).", + "chunkOverlap": "Chunk Overlap" }, "report": { "reportTemplate": "Report Template", diff --git a/src/frontend/public/locales/zh/bs.json b/src/frontend/public/locales/zh/bs.json index 9921a83d3..fe742b57d 100644 --- a/src/frontend/public/locales/zh/bs.json +++ b/src/frontend/public/locales/zh/bs.json @@ -250,7 +250,8 @@ "file": "文件", "sizeExceedsLimit": "超过50M", "editDictionary": "编辑词典", - "exportCodeDialogTip": "生成代码,将流程集成到外部应用程序中 (打开此页面前请先build技能)。" + "exportCodeDialogTip": "生成代码,将流程集成到外部应用程序中 (打开此页面前请先build技能)。", + "chunkOverlap": "切分文本重叠长度" }, "report": { "reportTemplate": "报告模板", diff --git a/src/frontend/src/i18n.js b/src/frontend/src/i18n.js index 7b8f8657e..9f7be5ec7 100644 --- a/src/frontend/src/i18n.js +++ b/src/frontend/src/i18n.js @@ -4,12 +4,16 @@ import { } from "react-i18next"; import Backend from 'i18next-http-backend'; +const userLanguage = (localStorage.getItem('language') || + navigator.language || + navigator.userLanguage || 'en').substring(0, 2) + i18n.use(Backend) .use(initReactI18next) .init({ partialBundledLanguages: true, ns: ['bs'], - lng: 'en', + lng: userLanguage === 'zh' ? userLanguage : 'en', // 除中文即英文 backend: { loadPath: '/locales/{{lng}}/{{ns}}.json' }, diff --git a/src/frontend/src/layout/MainLayout.tsx b/src/frontend/src/layout/MainLayout.tsx index aee6cf976..d95279a99 100755 --- a/src/frontend/src/layout/MainLayout.tsx +++ b/src/frontend/src/layout/MainLayout.tsx @@ -167,6 +167,7 @@ const useLanguage = (user: User) => { const ln = language === 'zh' ? 'en' : 'zh' setLanguage(ln) localStorage.setItem('language-' + user.user_id, ln) + localStorage.setItem('language', ln) i18next.changeLanguage(ln) } return { diff --git a/src/frontend/src/modals/UploadModal/index.tsx b/src/frontend/src/modals/UploadModal/index.tsx index 03ea12638..714506434 100755 --- a/src/frontend/src/modals/UploadModal/index.tsx +++ b/src/frontend/src/modals/UploadModal/index.tsx @@ -21,6 +21,7 @@ export default function UploadModal({ id, accept, open, desc = '', children = nu // 符号 const [symbol, setSymbol] = useState('\\n\\n') const chunkType = useRef('smart') + const [overlap, setOverlap] = useState('100') const [progressList, setProgressList] = useState([]) const progressCountRef = useRef(0) @@ -68,11 +69,11 @@ export default function UploadModal({ id, accept, open, desc = '', children = nu const [loading, setLoading] = useState(false) const handleSubmit = async () => { const errorList = []; - if (!/^\d+$/.test(size)) errorList.push(t('code.setSplitSize')); + // if (!/^\d+$/.test(size)) errorList.push(t('code.setSplitSize')); if (!filePathsRef.current.length) errorList.push(t('code.selectFileToUpload')); if (errorList.length) return setErrorData({ title: t('prompt'), list: errorList }); setLoading(true); - const params = { + const params: any = { file_path: filePathsRef.current, knowledge_id: Number(id), auto: true @@ -87,8 +88,9 @@ export default function UploadModal({ id, accept, open, desc = '', children = nu 'b': '\b' }[capture]; })); - params.chunck_size = Number(size); + params.chunck_size = Number(/^\d+$/.test(size) ? size : '1000'); params.auto = false; + // params.overlap = /^\d+$/.test(overlap) ? overlap : '100' // 异常值使用默认值 } await subUploadLibFile(params); setOpen(false); @@ -161,7 +163,7 @@ export default function UploadModal({ id, accept, open, desc = '', children = nu
{desc}
{t('code.dropFileHere')}
:{t('code.clickOrDragHere')}
} @@ -188,6 +190,8 @@ export default function UploadModal({ id, accept, open, desc = '', children = nu setSymbol(e.target.value)} placeholder={t('code.delimiterPlaceholder')} className="col-span-3" /> setSize(e.target.value)} placeholder={t('code.splitSizePlaceholder')} className="col-span-3" /> + + setOverlap(e.target.value)} placeholder={t('code.chunkOverlap')} className="col-span-3" />@ {chat.receiver.user_name}
} {/* 光标 */} {chat.message.toString() && !chat.end && } + {/* 赞 踩 */} + {chat.chat_id &&{t('report.formSettings')}
{t('skills.skillSettings')}
-{t('skills.basicInfo')} +
+ {t('skills.basicInfo')}
{t('skills.parameterInfo')} + // L2 form + isL2 &&
+ {t('skills.parameterInfo')}