balibabu commited on
Commit
48dcb0f
·
1 Parent(s): 7e0ad60

fix: fixed the problem that the api will be called directly after selecting the chat assistant picture (#1034)

Browse files

### 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 CHANGED
@@ -31,6 +31,7 @@ def set_dialog():
31
  req = request.json
32
  dialog_id = req.get("dialog_id")
33
  name = req.get("name", "New Dialog")
 
34
  description = req.get("description", "A helpful Dialog")
35
  top_n = req.get("top_n", 6)
36
  top_k = req.get("top_k", 1024)
@@ -90,7 +91,8 @@ def set_dialog():
90
  "top_k": top_k,
91
  "rerank_id": rerank_id,
92
  "similarity_threshold": similarity_threshold,
93
- "vector_similarity_weight": vector_similarity_weight
 
94
  }
95
  if not DialogService.save(**dia):
96
  return get_data_error_result(retmsg="Fail to new a dialog!")
 
31
  req = request.json
32
  dialog_id = req.get("dialog_id")
33
  name = req.get("name", "New Dialog")
34
+ icon = req.get("icon", "")
35
  description = req.get("description", "A helpful Dialog")
36
  top_n = req.get("top_n", 6)
37
  top_k = req.get("top_k", 1024)
 
91
  "top_k": top_k,
92
  "rerank_id": rerank_id,
93
  "similarity_threshold": similarity_threshold,
94
+ "vector_similarity_weight": vector_similarity_weight,
95
+ "icon": icon,
96
  }
97
  if not DialogService.save(**dia):
98
  return get_data_error_result(retmsg="Fail to new a dialog!")
web/src/pages/chat/chat-configuration-modal/assistant-setting.tsx CHANGED
@@ -24,12 +24,10 @@ const AssistantSetting = ({ show }: ISegmentedContentProps) => {
24
 
25
  const uploadButtion = (
26
  <button style={{ border: 0, background: 'none' }} type="button">
27
- <PlusOutlined />
28
- <div style={{ marginTop: 8 }}>
29
- {t('upload', { keyPrefix: 'common' })}
30
- </div>
31
- </button>
32
- )
33
 
34
  return (
35
  <section
@@ -53,6 +51,7 @@ const AssistantSetting = ({ show }: ISegmentedContentProps) => {
53
  <Upload
54
  listType="picture-card"
55
  maxCount={1}
 
56
  showUploadList={{ showPreviewIcon: false, showRemoveIcon: false }}
57
  >
58
  {show ? uploadButtion : null}
 
24
 
25
  const uploadButtion = (
26
  <button style={{ border: 0, background: 'none' }} type="button">
27
+ <PlusOutlined />
28
+ <div style={{ marginTop: 8 }}>{t('upload', { keyPrefix: 'common' })}</div>
29
+ </button>
30
+ );
 
 
31
 
32
  return (
33
  <section
 
51
  <Upload
52
  listType="picture-card"
53
  maxCount={1}
54
+ beforeUpload={() => false}
55
  showUploadList={{ showPreviewIcon: false, showRemoveIcon: false }}
56
  >
57
  {show ? uploadButtion : null}
web/src/pages/chat/chat-configuration-modal/index.tsx CHANGED
@@ -19,6 +19,7 @@ import ModelSetting from './model-setting';
19
  import PromptEngine from './prompt-engine';
20
 
21
  import { useTranslate } from '@/hooks/commonHooks';
 
22
  import styles from './index.less';
23
 
24
  const layout = {
@@ -82,12 +83,7 @@ const ChatConfigurationModal = ({
82
  ]);
83
  const emptyResponse = nextValues.prompt_config?.empty_response ?? '';
84
 
85
- const fileList = values.icon;
86
- let icon;
87
-
88
- if (Array.isArray(fileList) && fileList.length > 0) {
89
- icon = fileList[0].thumbUrl;
90
- }
91
 
92
  const finalValues = {
93
  dialog_id: initialDialog.id,
 
19
  import PromptEngine from './prompt-engine';
20
 
21
  import { useTranslate } from '@/hooks/commonHooks';
22
+ import { getBase64FromUploadFileList } from '@/utils/fileUtil';
23
  import styles from './index.less';
24
 
25
  const layout = {
 
83
  ]);
84
  const emptyResponse = nextValues.prompt_config?.empty_response ?? '';
85
 
86
+ const icon = await getBase64FromUploadFileList(values.icon);
 
 
 
 
 
87
 
88
  const finalValues = {
89
  dialog_id: initialDialog.id,