feat: create application ui (#3190)

This commit is contained in:
shaohuzhang1 2025-06-04 15:47:31 +08:00 committed by GitHub
parent bfa15c2221
commit 28c09ae220
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 51 additions and 43 deletions

View File

@ -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 : '',
},
]
}
}

View File

@ -121,11 +121,11 @@ const dialogVisible = ref<boolean>(false)
const applicationForm = ref<ApplicationFormType>({
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<ApplicationFormType>({
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
})
}
})
}

View File

@ -47,7 +47,7 @@
</el-button>
<template #dropdown>
<el-dropdown-menu class="create-dropdown">
<el-dropdown-item @click="openCreateDialog">
<el-dropdown-item @click="openCreateDialog('SIMPLE')">
<div class="flex">
<el-avatar shape="square" class="avatar-blue mt-4" :size="36">
<img
@ -248,7 +248,7 @@ import useStore from '@/stores'
import { numberFormat } from '@/utils/common'
import { t } from '@/locales'
import { useRouter } from 'vue-router'
import { isWorkFlow } from '@/utils/application'
const router = useRouter()
const { folder } = useStore()