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

{t('code.uploadFile')}

{desc}

-
+
{isDragActive ?

{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" />
diff --git a/src/frontend/src/pages/SkillChatPage/components/ChatMessage.tsx b/src/frontend/src/pages/SkillChatPage/components/ChatMessage.tsx index a0bf81bec..468a522f6 100644 --- a/src/frontend/src/pages/SkillChatPage/components/ChatMessage.tsx +++ b/src/frontend/src/pages/SkillChatPage/components/ChatMessage.tsx @@ -11,6 +11,7 @@ import { CodeBlock } from "../../../modals/formModal/chatMessage/codeBlock"; import { ChatMessageType } from "../../../types/chat"; import { downloadFile } from "../../../util/utils"; import { checkSassUrl } from "./FileView"; +import Thumbs from "./Thumbs"; // 颜色列表 const colorList = [ @@ -29,6 +30,7 @@ const colorList = [ export const ChatMessage = ({ chat, userName, onSource }: { chat: ChatMessageType, userName: string, onSource: () => void }) => { // const { user } = useContext(userContext); + console.log('chat :>> ', chat); const textRef = useRef(null) const { t } = useTranslation() @@ -205,12 +207,14 @@ export const ChatMessage = ({ chat, userName, onSource }: { chat: ChatMessageTyp
{chat.sender &&
{chat.sender}
} -
+
{chat.message.toString() ? mkdown : } {/* @user */} {chat.receiver &&

@ {chat.receiver.user_name}

} {/* 光标 */} {chat.message.toString() && !chat.end &&
} + {/* 赞 踩 */} + {chat.chat_id && }
{chat.source && source}
diff --git a/src/frontend/src/pages/SkillChatPage/components/ChatPanne.tsx b/src/frontend/src/pages/SkillChatPage/components/ChatPanne.tsx index 0aac1a49a..8cb7ac9c6 100644 --- a/src/frontend/src/pages/SkillChatPage/components/ChatPanne.tsx +++ b/src/frontend/src/pages/SkillChatPage/components/ChatPanne.tsx @@ -385,12 +385,12 @@ const useWebsocket = (chatId, flow, setChatHistory, libId, version) => { setTimeout(heartbeat, 30000); } - function getWebSocketUrl(_chatId, isDevelopment = false) { + function getWebSocketUrl(flowId, isDevelopment = false) { const isSecureProtocol = window.location.protocol === "https:"; const webSocketProtocol = isSecureProtocol ? "wss" : "ws"; const host = window.location.host // isDevelopment ? "localhost:7860" : window.location.host; - const chatEndpoint = version === 'v1' ? `/api/v1/chat/${_chatId}?type=L1&chat_id=${_chatId}` - : `/api/v2/chat/ws/${_chatId}?type=L1&chat_id=${_chatId}${libId ? '&knowledge_id=' + libId : ''}` + const chatEndpoint = version === 'v1' ? `/api/v1/chat/${flowId}?type=L1&chat_id=${chatId}` + : `/api/v2/chat/ws/${flowId}?type=L1&chat_id=${chatId}${libId ? '&knowledge_id=' + libId : ''}` return `${webSocketProtocol}://${host}${chatEndpoint}`; } diff --git a/src/frontend/src/pages/SkillChatPage/components/Thumbs.tsx b/src/frontend/src/pages/SkillChatPage/components/Thumbs.tsx new file mode 100644 index 000000000..4f13ba09c --- /dev/null +++ b/src/frontend/src/pages/SkillChatPage/components/Thumbs.tsx @@ -0,0 +1,34 @@ +import { ThumbsDown, ThumbsUp } from "lucide-react"; +import { useState } from "react"; +import { classNames } from "../../../utils"; + +const enum ThumbsState { + Default = 0, + ThumbsUp, + ThumbsDown +} + +export default function Thumbs({ id, className, data }) { + + const [state, setState] = useState(data) + + const handleClick = (type: ThumbsState) => { + setState(_type => { + const newType = type === _type ? ThumbsState.Default : type + // api + console.log('newType :>> ', newType); + return newType + }) + } + + return
+ handleClick(ThumbsState.ThumbsUp)} /> + handleClick(ThumbsState.ThumbsDown)} /> +
+} diff --git a/src/frontend/src/pages/SkillPage/components/FormSet.tsx b/src/frontend/src/pages/SkillPage/components/FormSet.tsx index 1ee1b9f36..2050c3f27 100644 --- a/src/frontend/src/pages/SkillPage/components/FormSet.tsx +++ b/src/frontend/src/pages/SkillPage/components/FormSet.tsx @@ -58,9 +58,9 @@ export default forwardRef(function FormSet({ id }: any, ref) { } } - return
+ return

{t('report.formSettings')}

-
+
{(provided) => ( diff --git a/src/frontend/src/pages/SkillPage/l2Edit.tsx b/src/frontend/src/pages/SkillPage/l2Edit.tsx index db915138b..c9738b1c0 100644 --- a/src/frontend/src/pages/SkillPage/l2Edit.tsx +++ b/src/frontend/src/pages/SkillPage/l2Edit.tsx @@ -123,7 +123,7 @@ export default function l2Edit() { const isForm = useHasForm(flow) return
-
+
{/* form */} -
+

{t('skills.skillSettings')}

-
-

{t('skills.basicInfo')} +

+

+ {t('skills.basicInfo')}

{/* base form */} -
+
- - + +
- -