From e68e5873c943db03884758f57e1b058123f6a937 Mon Sep 17 00:00:00 2001 From: shaohuzhang1 Date: Tue, 29 Oct 2024 17:29:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E6=97=A5=E5=BF=97=E5=BC=95=E7=94=A8=E5=88=86?= =?UTF-8?q?=E6=AE=B5=E5=AD=97=E6=AE=B5=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serializers/application_serializers.py | 1 + .../serializers/chat_serializers.py | 30 ++++++++++++------- .../dynamics-form/DemoConstructor.vue | 9 ++---- ui/src/components/markdown/MdRenderer.vue | 1 - ui/src/components/read-write/index.vue | 1 - .../component/FunctionDebugDrawer.vue | 1 - .../views/login/components/dingtalkQrCode.vue | 1 - ui/src/views/login/components/wecomQrCode.vue | 1 - .../template/component/AddParamDrawer.vue | 1 - .../template/component/ParamSettingDialog.vue | 2 -- 10 files changed, 23 insertions(+), 25 deletions(-) diff --git a/apps/application/serializers/application_serializers.py b/apps/application/serializers/application_serializers.py index 0be967621..dac49fae0 100644 --- a/apps/application/serializers/application_serializers.py +++ b/apps/application/serializers/application_serializers.py @@ -716,6 +716,7 @@ class ApplicationSerializer(serializers.Serializer): application.save() # 插入知识库关联关系 self.save_application_mapping(application_dataset_id_list, dataset_id_list, application.id) + chat_cache.clear_by_application_id(str(application.id)) work_flow_version = WorkFlowVersion(work_flow=work_flow, application=application, name=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'), publish_user_id=user_id, diff --git a/apps/application/serializers/chat_serializers.py b/apps/application/serializers/chat_serializers.py index efa80b091..822f60f4a 100644 --- a/apps/application/serializers/chat_serializers.py +++ b/apps/application/serializers/chat_serializers.py @@ -167,25 +167,35 @@ class ChatSerializers(serializers.Serializer): os.path.join(PROJECT_DIR, "apps", "application", 'sql', 'list_application_chat.sql')), with_table_name=False) + @staticmethod + def paragraph_list_to_string(paragraph_list): + return "\n**********\n".join( + [f"{paragraph.get('title')}:\n{paragraph.get('content')}" for paragraph in paragraph_list]) + @staticmethod def to_row(row: Dict): details = row.get('details') padding_problem_text = details.get('problem_padding').get( 'padding_problem_text') if 'problem_padding' in details and 'padding_problem_text' in details.get( 'problem_padding') else "" - paragraph_list = details.get('search_step').get( - 'paragraph_list') if 'search_step' in details and 'paragraph_list' in details.get('search_step') else [] - for key, node in details.items(): - if node.get('type') == 'search-dataset-node' and node.get('paragraph_list') is not None and len( - node.get('paragraph_list')) > 0: - paragraph_list = node.get('paragraph_list') + search_dataset_node_list = [(key, node) for key, node in details.items() if + node.get("type") == 'search-dataset-node' or node.get( + "step_type") == 'search_step'] + reference_paragraph_len = '\n'.join([str(len(node.get('paragraph_list', + []))) if key == 'search_step' else node.get( + 'name') + ':' + str(len(node.get('paragraph_list', []))) for + key, node in search_dataset_node_list]) + reference_paragraph = '\n----------\n'.join( + [ChatSerializers.Query.paragraph_list_to_string(node.get('paragraph_list', + [])) if key == 'search_step' else node.get( + 'name') + ':\n' + ChatSerializers.Query.paragraph_list_to_string(node.get('paragraph_list', + [])) for + key, node in search_dataset_node_list]) improve_paragraph_list = row.get('improve_paragraph_list') vote_status_map = {'-1': '未投票', '0': '赞同', '1': '反对'} return [str(row.get('chat_id')), row.get('abstract'), row.get('problem_text'), padding_problem_text, - row.get('answer_text'), vote_status_map.get(row.get('vote_status')), len(paragraph_list), "\n".join( - [f"{index}、{paragraph_list[index].get('title')}\n{paragraph_list[index].get('content')}" for index - in - range(len(paragraph_list))]), + row.get('answer_text'), vote_status_map.get(row.get('vote_status')), reference_paragraph_len, + reference_paragraph, "\n".join([ f"{improve_paragraph_list[index].get('title')}\n{improve_paragraph_list[index].get('content')}" for index in range(len(improve_paragraph_list))]), diff --git a/ui/src/components/dynamics-form/DemoConstructor.vue b/ui/src/components/dynamics-form/DemoConstructor.vue index aceecb503..b8e0b6082 100644 --- a/ui/src/components/dynamics-form/DemoConstructor.vue +++ b/ui/src/components/dynamics-form/DemoConstructor.vue @@ -46,15 +46,10 @@ const form_data = ref({}) const item = ref({}) const dynamicsFormRef = ref>() const validate = () => { - console.log('asda') dynamicsFormRef.value ?.validate() - .then((ok) => { - console.log('ok') - }) - .catch((e) => { - console.log(e) - }) + .then((ok) => {}) + .catch((e) => {}) } diff --git a/ui/src/components/markdown/MdRenderer.vue b/ui/src/components/markdown/MdRenderer.vue index 9a9952f46..ec7f03fac 100644 --- a/ui/src/components/markdown/MdRenderer.vue +++ b/ui/src/components/markdown/MdRenderer.vue @@ -80,7 +80,6 @@ const split_md_img = (result: Array) => { const split_md_img_ = (source: string) => { const temp_md_img_list = source.match(/(!\[.*?\]\(.*?\){.*?})|(!\[.*?\]\(.*?\))/g) - console.log(temp_md_img_list) const md_img_list = temp_md_img_list ? temp_md_img_list.filter((i) => i) : [] const split_img_value = source .split(/(!\[.*?\]\(.*?\){.*?})|(!\[.*?\]\(.*?\))/g) diff --git a/ui/src/components/read-write/index.vue b/ui/src/components/read-write/index.vue index 4306ba638..8a1318691 100644 --- a/ui/src/components/read-write/index.vue +++ b/ui/src/components/read-write/index.vue @@ -79,7 +79,6 @@ const writeValue = ref('') const loading = ref(false) watch(isEdit, (bool) => { - console.log(bool) if (!bool) { writeValue.value = '' emit('close') diff --git a/ui/src/views/function-lib/component/FunctionDebugDrawer.vue b/ui/src/views/function-lib/component/FunctionDebugDrawer.vue index 64aa3c626..1f80347ef 100644 --- a/ui/src/views/function-lib/component/FunctionDebugDrawer.vue +++ b/ui/src/views/function-lib/component/FunctionDebugDrawer.vue @@ -102,7 +102,6 @@ watch(debugVisible, (bool) => { }) const submit = async (formEl: FormInstance | undefined) => { - console.log(formEl) const validate = formEl ? formEl.validate() : Promise.resolve() validate.then(() => { functionLibApi.postFunctionLibDebug(form.value, loading).then((res) => { diff --git a/ui/src/views/login/components/dingtalkQrCode.vue b/ui/src/views/login/components/dingtalkQrCode.vue index 2e2897e25..5254886c1 100644 --- a/ui/src/views/login/components/dingtalkQrCode.vue +++ b/ui/src/views/login/components/dingtalkQrCode.vue @@ -87,7 +87,6 @@ const initActive = async () => { appSecret: props.config.app_secret, agent_id: props.config.agent_id } - console.log(props.config) const redirectUri = encodeURIComponent(window.location.origin) diff --git a/ui/src/views/login/components/wecomQrCode.vue b/ui/src/views/login/components/wecomQrCode.vue index 0313138ab..5487ef91a 100644 --- a/ui/src/views/login/components/wecomQrCode.vue +++ b/ui/src/views/login/components/wecomQrCode.vue @@ -46,7 +46,6 @@ const init = async () => { }, onCheckWeComLogin: obj.value, async onLoginSuccess({ code }: any) { - console.log('Login success:', code) user.wecomCallback(code).then(() => { setTimeout(() => { router.push({ name: 'home' }) diff --git a/ui/src/views/template/component/AddParamDrawer.vue b/ui/src/views/template/component/AddParamDrawer.vue index 34486b352..f1f6bd821 100644 --- a/ui/src/views/template/component/AddParamDrawer.vue +++ b/ui/src/views/template/component/AddParamDrawer.vue @@ -43,7 +43,6 @@ const currentIndex = ref(null) const emit = defineEmits(['refresh']) const open = (row: any, index: any) => { - // console.log(row, index) if (row) { currentItem.value = cloneDeep(row) currentIndex.value = index diff --git a/ui/src/views/template/component/ParamSettingDialog.vue b/ui/src/views/template/component/ParamSettingDialog.vue index df60d0170..1f6952be2 100644 --- a/ui/src/views/template/component/ParamSettingDialog.vue +++ b/ui/src/views/template/component/ParamSettingDialog.vue @@ -107,7 +107,6 @@ function deleteParam(index: any) { } function refresh(data: any, index: any) { - // console.log(data, index) for (let i = 0; i < modelParamsForm.value.length; i++) { let field = modelParamsForm.value[i].field let label = modelParamsForm.value[i].label @@ -136,7 +135,6 @@ function refresh(data: any, index: any) { } function submit() { - // console.log('submit: ', modelParamsForm.value) ModelApi.updateModelParamsForm(props.model.id, modelParamsForm.value, loading).then((ok) => { MsgSuccess('模型参数保存成功') close()