From 9517a278446c3cfbda4c1d18dfc90f6ec4152efc Mon Sep 17 00:00:00 2001 From: balibabu Date: Mon, 3 Jun 2024 13:42:56 +0800 Subject: [PATCH] fix: fixed the problem that the api will be called directly after selecting the chat assistant picture (#1034) ### What problem does this PR solve? fix: fixed the problem that the api will be called directly after selecting the chat assistant picture #1033 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- api/apps/dialog_app.py | 4 +++- .../chat-configuration-modal/assistant-setting.tsx | 11 +++++------ web/src/pages/chat/chat-configuration-modal/index.tsx | 8 ++------ 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/api/apps/dialog_app.py b/api/apps/dialog_app.py index b59b02638..0ec90f016 100644 --- a/api/apps/dialog_app.py +++ b/api/apps/dialog_app.py @@ -31,6 +31,7 @@ def set_dialog(): req = request.json dialog_id = req.get("dialog_id") name = req.get("name", "New Dialog") + icon = req.get("icon", "") description = req.get("description", "A helpful Dialog") top_n = req.get("top_n", 6) top_k = req.get("top_k", 1024) @@ -90,7 +91,8 @@ def set_dialog(): "top_k": top_k, "rerank_id": rerank_id, "similarity_threshold": similarity_threshold, - "vector_similarity_weight": vector_similarity_weight + "vector_similarity_weight": vector_similarity_weight, + "icon": icon, } if not DialogService.save(**dia): return get_data_error_result(retmsg="Fail to new a dialog!") diff --git a/web/src/pages/chat/chat-configuration-modal/assistant-setting.tsx b/web/src/pages/chat/chat-configuration-modal/assistant-setting.tsx index 97d998f5c..b15d6fdf9 100644 --- a/web/src/pages/chat/chat-configuration-modal/assistant-setting.tsx +++ b/web/src/pages/chat/chat-configuration-modal/assistant-setting.tsx @@ -24,12 +24,10 @@ const AssistantSetting = ({ show }: ISegmentedContentProps) => { const uploadButtion = ( - ) + +
{t('upload', { keyPrefix: 'common' })}
+ + ); return (
{ false} showUploadList={{ showPreviewIcon: false, showRemoveIcon: false }} > {show ? uploadButtion : null} diff --git a/web/src/pages/chat/chat-configuration-modal/index.tsx b/web/src/pages/chat/chat-configuration-modal/index.tsx index 9465c0a80..27effe309 100644 --- a/web/src/pages/chat/chat-configuration-modal/index.tsx +++ b/web/src/pages/chat/chat-configuration-modal/index.tsx @@ -19,6 +19,7 @@ import ModelSetting from './model-setting'; import PromptEngine from './prompt-engine'; import { useTranslate } from '@/hooks/commonHooks'; +import { getBase64FromUploadFileList } from '@/utils/fileUtil'; import styles from './index.less'; const layout = { @@ -82,12 +83,7 @@ const ChatConfigurationModal = ({ ]); const emptyResponse = nextValues.prompt_config?.empty_response ?? ''; - const fileList = values.icon; - let icon; - - if (Array.isArray(fileList) && fileList.length > 0) { - icon = fileList[0].thumbUrl; - } + const icon = await getBase64FromUploadFileList(values.icon); const finalValues = { dialog_id: initialDialog.id,