From 937048e5fb711a583ee6f070862107a720bd08a6 Mon Sep 17 00:00:00 2001 From: balibabu <cike8899@users.noreply.github.com> Date: Thu, 14 Mar 2024 19:22:39 +0800 Subject: [PATCH] feat: remove loading from document table and fixed the issue where gif images could not be uploaded on the configuration page (#122) * feat: fixed the issue where gif images could not be uploaded on the configuration page * feat: remove loading from document table --- .../components/knowledge-file/index.tsx | 18 +++++++++--------- .../knowledge-setting/configuration.tsx | 5 +++-- .../chat-configuration-modal/model-setting.tsx | 10 ++-------- web/src/pages/chat/chat-container/index.less | 1 + .../user-setting/setting-profile/index.tsx | 8 ++++++-- web/src/utils/fileUtil.ts | 6 ++++-- 6 files changed, 25 insertions(+), 23 deletions(-) diff --git a/web/src/pages/add-knowledge/components/knowledge-file/index.tsx b/web/src/pages/add-knowledge/components/knowledge-file/index.tsx index 713196d..fe71ee3 100644 --- a/web/src/pages/add-knowledge/components/knowledge-file/index.tsx +++ b/web/src/pages/add-knowledge/components/knowledge-file/index.tsx @@ -227,14 +227,6 @@ const KnowledgeFile = () => { return parserList.find((x) => x.value === text)?.label; }, }, - { - title: 'Parsing Status', - dataIndex: 'run', - key: 'run', - render: (text, record) => { - return <ParsingStatusCell record={record}></ParsingStatusCell>; - }, - }, { title: 'Enabled', key: 'status', @@ -250,6 +242,14 @@ const KnowledgeFile = () => { </> ), }, + { + title: 'Parsing Status', + dataIndex: 'run', + key: 'run', + render: (text, record) => { + return <ParsingStatusCell record={record}></ParsingStatusCell>; + }, + }, { title: 'Action', key: 'action', @@ -301,7 +301,7 @@ const KnowledgeFile = () => { rowKey="id" columns={finalColumns} dataSource={data} - loading={loading} + // loading={loading} pagination={pagination} scroll={{ scrollToFirstRowOnChange: true, x: 1300, y: 'fill' }} /> diff --git a/web/src/pages/add-knowledge/components/knowledge-setting/configuration.tsx b/web/src/pages/add-knowledge/components/knowledge-setting/configuration.tsx index e57e7ea..f0e7e70 100644 --- a/web/src/pages/add-knowledge/components/knowledge-setting/configuration.tsx +++ b/web/src/pages/add-knowledge/components/knowledge-setting/configuration.tsx @@ -55,7 +55,7 @@ const Configuration = () => { const embeddingModelOptions = useSelectLlmOptions(); const onFinish = async (values: any) => { - const avatar = getBase64FromUploadFileList(values.avatar); + const avatar = await getBase64FromUploadFileList(values.avatar); dispatch({ type: 'kSModel/updateKb', payload: { @@ -123,6 +123,7 @@ const Configuration = () => { <Upload listType="picture-card" maxCount={1} + beforeUpload={() => false} showUploadList={{ showPreviewIcon: false, showRemoveIcon: false }} > <button style={{ border: 0, background: 'none' }} type="button"> @@ -184,7 +185,7 @@ const Configuration = () => { {({ getFieldValue }) => { const parserId = getFieldValue('parser_id'); - if (parserId === 'general') { + if (parserId === 'naive') { return ( <Form.Item label="Chunk token number" tooltip="xxx"> <Flex gap={20} align="center"> diff --git a/web/src/pages/chat/chat-configuration-modal/model-setting.tsx b/web/src/pages/chat/chat-configuration-modal/model-setting.tsx index 2f4c666..1324441 100644 --- a/web/src/pages/chat/chat-configuration-modal/model-setting.tsx +++ b/web/src/pages/chat/chat-configuration-modal/model-setting.tsx @@ -18,18 +18,12 @@ const ModelSetting = ({ show, form }: ISegmentedContentProps) => { value: x, })); - const parameters: ModelVariableType = Form.useWatch('parameters', form); - const modelOptions = useSelectLlmOptions(); const handleParametersChange = (value: ModelVariableType) => { - console.info(value); - }; - - useEffect(() => { - const variable = settledModelVariableMap[parameters]; + const variable = settledModelVariableMap[value]; form.setFieldsValue({ llm_setting: variable }); - }, [parameters, form]); + }; useEffect(() => { const values = Object.keys(variableEnabledFieldMap).reduce< diff --git a/web/src/pages/chat/chat-container/index.less b/web/src/pages/chat/chat-container/index.less index ada0de0..14556a1 100644 --- a/web/src/pages/chat/chat-container/index.less +++ b/web/src/pages/chat/chat-container/index.less @@ -27,6 +27,7 @@ .messageText { padding: 0 14px; background-color: rgba(249, 250, 251, 1); + word-break: break-all; } .messageEmpty { width: 300px; diff --git a/web/src/pages/user-setting/setting-profile/index.tsx b/web/src/pages/user-setting/setting-profile/index.tsx index 29f4be2..daf9212 100644 --- a/web/src/pages/user-setting/setting-profile/index.tsx +++ b/web/src/pages/user-setting/setting-profile/index.tsx @@ -45,8 +45,8 @@ const UserSettingProfile = () => { const loading = useGetUserInfoLoading(); const { form, submittable } = useValidateSubmittable(); - const onFinish = (values: any) => { - const avatar = getBase64FromUploadFileList(values.avatar); + const onFinish = async (values: any) => { + const avatar = await getBase64FromUploadFileList(values.avatar); saveSetting({ ...values, avatar }); }; @@ -112,6 +112,10 @@ const UserSettingProfile = () => { <Upload listType="picture-card" maxCount={1} + accept="image/*" + beforeUpload={() => { + return false; + }} showUploadList={{ showPreviewIcon: false, showRemoveIcon: false }} > <button style={{ border: 0, background: 'none' }} type="button"> diff --git a/web/src/utils/fileUtil.ts b/web/src/utils/fileUtil.ts index 537abb4..44e43c6 100644 --- a/web/src/utils/fileUtil.ts +++ b/web/src/utils/fileUtil.ts @@ -46,9 +46,11 @@ export const getUploadFileListFromBase64 = (avatar: string) => { return fileList; }; -export const getBase64FromUploadFileList = (fileList?: UploadFile[]) => { +export const getBase64FromUploadFileList = async (fileList?: UploadFile[]) => { if (Array.isArray(fileList) && fileList.length > 0) { - return fileList[0].thumbUrl; + const base64 = await transformFile2Base64(fileList[0].originFileObj); + return base64; + // return fileList[0].thumbUrl; TODO: Even JPG files will be converted to base64 parameters in png format } return ''; -- GitLab