From 2a92f67363a496e93d27bd391ab654deea242228 Mon Sep 17 00:00:00 2001 From: shaohuzhang1 Date: Wed, 4 Jun 2025 15:46:40 +0800 Subject: [PATCH] feat: create application ui --- ui/src/api/type/application.ts | 39 +++++++------- .../component/CreateApplicationDialog.vue | 51 +++++++++++-------- ui/src/views/application/index.vue | 4 +- 3 files changed, 51 insertions(+), 43 deletions(-) diff --git a/ui/src/api/type/application.ts b/ui/src/api/type/application.ts index c423f11105a..fb45ae548c0 100644 --- a/ui/src/api/type/application.ts +++ b/ui/src/api/type/application.ts @@ -7,8 +7,8 @@ interface ApplicationFormType { model_id?: string dialogue_number?: number prologue?: string - dataset_id_list?: string[] - dataset_setting?: any + knowledge_id_list?: string[] + knowledge_setting?: any model_setting?: any problem_optimization?: boolean problem_optimization_prompt?: string @@ -24,6 +24,7 @@ interface ApplicationFormType { tts_type?: string tts_autoplay?: boolean stt_autosend?: boolean + folder_id?: string } interface Chunk { real_node_id: string @@ -118,7 +119,7 @@ export class ChatRecordManage { chat_record_id?: string, runtime_node_id?: string, child_node?: any, - real_node_id?: string + real_node_id?: string, ) { if (chunk_answer || reasoning_content) { const set_index = index != undefined ? index : this.chat.answer_text_list.length - 1 @@ -142,7 +143,7 @@ export class ChatRecordManage { chat_record_id, runtime_node_id, child_node, - real_node_id + real_node_id, }) } } @@ -167,7 +168,7 @@ export class ChatRecordManage { return this.write_node_info } const run_node = this.node_list.filter( - (item) => item.reasoning_content_buffer.length > 0 || item.buffer.length > 0 || !item.is_end + (item) => item.reasoning_content_buffer.length > 0 || item.buffer.length > 0 || !item.is_end, )[0] if (run_node) { @@ -185,7 +186,7 @@ export class ChatRecordManage { const none_index = this.findIndex( this.chat.answer_text_list, (item) => (item.length == 1 && item[0].content == '') || item.length == 0, - 'index' + 'index', ) if (none_index > -1) { answer_text_list_index = none_index @@ -196,7 +197,7 @@ export class ChatRecordManage { const none_index = this.findIndex( this.chat.answer_text_list, (item) => (item.length == 1 && item[0].content == '') || item.length == 0, - 'index' + 'index', ) if (none_index > -1) { answer_text_list_index = none_index @@ -208,7 +209,7 @@ export class ChatRecordManage { this.write_node_info = { current_node: run_node, current_up_node: current_up_node, - answer_text_list_index: answer_text_list_index + answer_text_list_index: answer_text_list_index, } return this.write_node_info @@ -241,7 +242,7 @@ export class ChatRecordManage { const last_index = this.findIndex( this.chat.answer_text_list, (item) => (item.length == 1 && item[0].content == '') || item.length == 0, - 'last' + 'last', ) if (last_index > 0) { this.chat.answer_text_list.splice(last_index, 1) @@ -274,13 +275,13 @@ export class ChatRecordManage { ? current_node.buffer.splice(0) : current_node.buffer.splice( 0, - current_node.is_end ? undefined : current_node.buffer.length - 20 + current_node.is_end ? undefined : current_node.buffer.length - 20, ) const reasoning_content = current_node.is_end ? current_node.reasoning_content_buffer.splice(0) : current_node.reasoning_content_buffer.splice( 0, - current_node.is_end ? undefined : current_node.reasoning_content_buffer.length - 20 + current_node.is_end ? undefined : current_node.reasoning_content_buffer.length - 20, ) this.append_answer( context.join(''), @@ -289,7 +290,7 @@ export class ChatRecordManage { current_node.chat_record_id, current_node.runtime_node_id, current_node.child_node, - current_node.real_node_id + current_node.real_node_id, ) } else if (this.is_close) { while (true) { @@ -305,7 +306,7 @@ export class ChatRecordManage { node_info.current_node.chat_record_id, node_info.current_node.runtime_node_id, node_info.current_node.child_node, - node_info.current_node.real_node_id + node_info.current_node.real_node_id, ) if ( @@ -327,7 +328,7 @@ export class ChatRecordManage { current_node.chat_record_id, current_node.runtime_node_id, current_node.child_node, - current_node.real_node_id + current_node.real_node_id, ) } if (reasoning_content !== undefined) { @@ -338,7 +339,7 @@ export class ChatRecordManage { current_node.chat_record_id, current_node.runtime_node_id, current_node.child_node, - current_node.real_node_id + current_node.real_node_id, ) } } @@ -383,7 +384,7 @@ export class ChatRecordManage { node_type: chunk.node_type, index: this.node_list.length, view_type: chunk.view_type, - is_end: false + is_end: false, } this.node_list.push(n) } @@ -395,7 +396,7 @@ export class ChatRecordManage { let set_index = this.findIndex( this.chat.answer_text_list, (item) => item.length == 1 && item[0].content == '', - 'index' + 'index', ) if (set_index <= -1) { set_index = 0 @@ -403,8 +404,8 @@ export class ChatRecordManage { this.chat.answer_text_list[set_index] = [ { content: answer_text_block, - reasoning_content: reasoning_content ? reasoning_content : '' - } + reasoning_content: reasoning_content ? reasoning_content : '', + }, ] } } diff --git a/ui/src/views/application/component/CreateApplicationDialog.vue b/ui/src/views/application/component/CreateApplicationDialog.vue index b242c34173f..b1fd56d30b6 100644 --- a/ui/src/views/application/component/CreateApplicationDialog.vue +++ b/ui/src/views/application/component/CreateApplicationDialog.vue @@ -121,11 +121,11 @@ const dialogVisible = ref(false) const applicationForm = ref({ name: '', desc: '', - model_id: '', + model_id: undefined, dialogue_number: 1, prologue: t('views.application.form.defaultPrologue'), - dataset_id_list: [], - dataset_setting: { + knowledge_id_list: [], + knowledge_setting: { top_n: 3, similarity: 0.6, max_paragraph_char_number: 5000, @@ -143,8 +143,8 @@ const applicationForm = ref({ model_params_setting: {}, problem_optimization: false, problem_optimization_prompt: optimizationPrompt, - stt_model_id: '', - tts_model_id: '', + stt_model_id: undefined, + tts_model_id: undefined, stt_model_enable: false, tts_model_enable: false, tts_type: 'BROWSER', @@ -175,11 +175,11 @@ watch(dialogVisible, (bool) => { applicationForm.value = { name: '', desc: '', - model_id: '', + model_id: undefined, dialogue_number: 1, prologue: t('views.application.form.defaultPrologue'), - dataset_id_list: [], - dataset_setting: { + knowledge_id_list: [], + knowledge_setting: { top_n: 3, similarity: 0.6, max_paragraph_char_number: 5000, @@ -197,8 +197,8 @@ watch(dialogVisible, (bool) => { model_params_setting: {}, problem_optimization: false, problem_optimization_prompt: optimizationPrompt, - stt_model_id: '', - tts_model_id: '', + stt_model_id: undefined, + tts_model_id: undefined, stt_model_enable: false, tts_model_enable: false, tts_type: 'BROWSER', @@ -208,7 +208,7 @@ watch(dialogVisible, (bool) => { } }) -const open = (folder: string, type?: sting) => { +const open = (folder: string, type?: string) => { currentFolder.value = folder applicationForm.value.type = type || 'SIMPLE' dialogVisible.value = true @@ -216,24 +216,31 @@ const open = (folder: string, type?: sting) => { const submitHandle = async (formEl: FormInstance | undefined) => { if (!formEl) return + console.log(applicationForm.value.type) await formEl.validate((valid) => { if (valid) { - applicationForm.value['folder_id'] = currentFolder.value if (isWorkFlow(applicationForm.value.type) && appTemplate.value === 'blank') { workflowDefault.value.nodes[0].properties.node_data.desc = applicationForm.value.desc workflowDefault.value.nodes[0].properties.node_data.name = applicationForm.value.name applicationForm.value['work_flow'] = workflowDefault.value } - applicationApi.postApplication('default', applicationForm.value, loading).then((res) => { - MsgSuccess(t('common.createSuccess')) - emit('refresh') - if (isWorkFlow(applicationForm.value.type)) { - router.push({ path: `/application/${res.data.id}/workflow` }) - } else { - router.push({ path: `/application/${res.data.id}/${res.data.type}/setting` }) - } - dialogVisible.value = false - }) + console.log(applicationForm.value.type) + applicationApi + .postApplication( + 'default', + { ...applicationForm.value, folder_id: currentFolder.value }, + loading, + ) + .then((res) => { + MsgSuccess(t('common.createSuccess')) + emit('refresh') + if (isWorkFlow(applicationForm.value.type)) { + router.push({ path: `/application/${res.data.id}/workflow` }) + } else { + router.push({ path: `/application/${res.data.id}/${res.data.type}/setting` }) + } + dialogVisible.value = false + }) } }) } diff --git a/ui/src/views/application/index.vue b/ui/src/views/application/index.vue index 948e33bdb61..52b733febc6 100644 --- a/ui/src/views/application/index.vue +++ b/ui/src/views/application/index.vue @@ -47,7 +47,7 @@