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 model_id?: string
dialogue_number?: number dialogue_number?: number
prologue?: string prologue?: string
dataset_id_list?: string[] knowledge_id_list?: string[]
dataset_setting?: any knowledge_setting?: any
model_setting?: any model_setting?: any
problem_optimization?: boolean problem_optimization?: boolean
problem_optimization_prompt?: string problem_optimization_prompt?: string
@ -24,6 +24,7 @@ interface ApplicationFormType {
tts_type?: string tts_type?: string
tts_autoplay?: boolean tts_autoplay?: boolean
stt_autosend?: boolean stt_autosend?: boolean
folder_id?: string
} }
interface Chunk { interface Chunk {
real_node_id: string real_node_id: string
@ -118,7 +119,7 @@ export class ChatRecordManage {
chat_record_id?: string, chat_record_id?: string,
runtime_node_id?: string, runtime_node_id?: string,
child_node?: any, child_node?: any,
real_node_id?: string real_node_id?: string,
) { ) {
if (chunk_answer || reasoning_content) { if (chunk_answer || reasoning_content) {
const set_index = index != undefined ? index : this.chat.answer_text_list.length - 1 const set_index = index != undefined ? index : this.chat.answer_text_list.length - 1
@ -142,7 +143,7 @@ export class ChatRecordManage {
chat_record_id, chat_record_id,
runtime_node_id, runtime_node_id,
child_node, child_node,
real_node_id real_node_id,
}) })
} }
} }
@ -167,7 +168,7 @@ export class ChatRecordManage {
return this.write_node_info return this.write_node_info
} }
const run_node = this.node_list.filter( 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] )[0]
if (run_node) { if (run_node) {
@ -185,7 +186,7 @@ export class ChatRecordManage {
const none_index = this.findIndex( const none_index = this.findIndex(
this.chat.answer_text_list, this.chat.answer_text_list,
(item) => (item.length == 1 && item[0].content == '') || item.length == 0, (item) => (item.length == 1 && item[0].content == '') || item.length == 0,
'index' 'index',
) )
if (none_index > -1) { if (none_index > -1) {
answer_text_list_index = none_index answer_text_list_index = none_index
@ -196,7 +197,7 @@ export class ChatRecordManage {
const none_index = this.findIndex( const none_index = this.findIndex(
this.chat.answer_text_list, this.chat.answer_text_list,
(item) => (item.length == 1 && item[0].content == '') || item.length == 0, (item) => (item.length == 1 && item[0].content == '') || item.length == 0,
'index' 'index',
) )
if (none_index > -1) { if (none_index > -1) {
answer_text_list_index = none_index answer_text_list_index = none_index
@ -208,7 +209,7 @@ export class ChatRecordManage {
this.write_node_info = { this.write_node_info = {
current_node: run_node, current_node: run_node,
current_up_node: current_up_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 return this.write_node_info
@ -241,7 +242,7 @@ export class ChatRecordManage {
const last_index = this.findIndex( const last_index = this.findIndex(
this.chat.answer_text_list, this.chat.answer_text_list,
(item) => (item.length == 1 && item[0].content == '') || item.length == 0, (item) => (item.length == 1 && item[0].content == '') || item.length == 0,
'last' 'last',
) )
if (last_index > 0) { if (last_index > 0) {
this.chat.answer_text_list.splice(last_index, 1) 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.buffer.splice( : current_node.buffer.splice(
0, 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 const reasoning_content = current_node.is_end
? current_node.reasoning_content_buffer.splice(0) ? current_node.reasoning_content_buffer.splice(0)
: current_node.reasoning_content_buffer.splice( : current_node.reasoning_content_buffer.splice(
0, 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( this.append_answer(
context.join(''), context.join(''),
@ -289,7 +290,7 @@ export class ChatRecordManage {
current_node.chat_record_id, current_node.chat_record_id,
current_node.runtime_node_id, current_node.runtime_node_id,
current_node.child_node, current_node.child_node,
current_node.real_node_id current_node.real_node_id,
) )
} else if (this.is_close) { } else if (this.is_close) {
while (true) { while (true) {
@ -305,7 +306,7 @@ export class ChatRecordManage {
node_info.current_node.chat_record_id, node_info.current_node.chat_record_id,
node_info.current_node.runtime_node_id, node_info.current_node.runtime_node_id,
node_info.current_node.child_node, node_info.current_node.child_node,
node_info.current_node.real_node_id node_info.current_node.real_node_id,
) )
if ( if (
@ -327,7 +328,7 @@ export class ChatRecordManage {
current_node.chat_record_id, current_node.chat_record_id,
current_node.runtime_node_id, current_node.runtime_node_id,
current_node.child_node, current_node.child_node,
current_node.real_node_id current_node.real_node_id,
) )
} }
if (reasoning_content !== undefined) { if (reasoning_content !== undefined) {
@ -338,7 +339,7 @@ export class ChatRecordManage {
current_node.chat_record_id, current_node.chat_record_id,
current_node.runtime_node_id, current_node.runtime_node_id,
current_node.child_node, 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, node_type: chunk.node_type,
index: this.node_list.length, index: this.node_list.length,
view_type: chunk.view_type, view_type: chunk.view_type,
is_end: false is_end: false,
} }
this.node_list.push(n) this.node_list.push(n)
} }
@ -395,7 +396,7 @@ export class ChatRecordManage {
let set_index = this.findIndex( let set_index = this.findIndex(
this.chat.answer_text_list, this.chat.answer_text_list,
(item) => item.length == 1 && item[0].content == '', (item) => item.length == 1 && item[0].content == '',
'index' 'index',
) )
if (set_index <= -1) { if (set_index <= -1) {
set_index = 0 set_index = 0
@ -403,8 +404,8 @@ export class ChatRecordManage {
this.chat.answer_text_list[set_index] = [ this.chat.answer_text_list[set_index] = [
{ {
content: answer_text_block, 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>({ const applicationForm = ref<ApplicationFormType>({
name: '', name: '',
desc: '', desc: '',
model_id: '', model_id: undefined,
dialogue_number: 1, dialogue_number: 1,
prologue: t('views.application.form.defaultPrologue'), prologue: t('views.application.form.defaultPrologue'),
dataset_id_list: [], knowledge_id_list: [],
dataset_setting: { knowledge_setting: {
top_n: 3, top_n: 3,
similarity: 0.6, similarity: 0.6,
max_paragraph_char_number: 5000, max_paragraph_char_number: 5000,
@ -143,8 +143,8 @@ const applicationForm = ref<ApplicationFormType>({
model_params_setting: {}, model_params_setting: {},
problem_optimization: false, problem_optimization: false,
problem_optimization_prompt: optimizationPrompt, problem_optimization_prompt: optimizationPrompt,
stt_model_id: '', stt_model_id: undefined,
tts_model_id: '', tts_model_id: undefined,
stt_model_enable: false, stt_model_enable: false,
tts_model_enable: false, tts_model_enable: false,
tts_type: 'BROWSER', tts_type: 'BROWSER',
@ -175,11 +175,11 @@ watch(dialogVisible, (bool) => {
applicationForm.value = { applicationForm.value = {
name: '', name: '',
desc: '', desc: '',
model_id: '', model_id: undefined,
dialogue_number: 1, dialogue_number: 1,
prologue: t('views.application.form.defaultPrologue'), prologue: t('views.application.form.defaultPrologue'),
dataset_id_list: [], knowledge_id_list: [],
dataset_setting: { knowledge_setting: {
top_n: 3, top_n: 3,
similarity: 0.6, similarity: 0.6,
max_paragraph_char_number: 5000, max_paragraph_char_number: 5000,
@ -197,8 +197,8 @@ watch(dialogVisible, (bool) => {
model_params_setting: {}, model_params_setting: {},
problem_optimization: false, problem_optimization: false,
problem_optimization_prompt: optimizationPrompt, problem_optimization_prompt: optimizationPrompt,
stt_model_id: '', stt_model_id: undefined,
tts_model_id: '', tts_model_id: undefined,
stt_model_enable: false, stt_model_enable: false,
tts_model_enable: false, tts_model_enable: false,
tts_type: 'BROWSER', 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 currentFolder.value = folder
applicationForm.value.type = type || 'SIMPLE' applicationForm.value.type = type || 'SIMPLE'
dialogVisible.value = true dialogVisible.value = true
@ -216,15 +216,22 @@ const open = (folder: string, type?: sting) => {
const submitHandle = async (formEl: FormInstance | undefined) => { const submitHandle = async (formEl: FormInstance | undefined) => {
if (!formEl) return if (!formEl) return
console.log(applicationForm.value.type)
await formEl.validate((valid) => { await formEl.validate((valid) => {
if (valid) { if (valid) {
applicationForm.value['folder_id'] = currentFolder.value
if (isWorkFlow(applicationForm.value.type) && appTemplate.value === 'blank') { 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.desc = applicationForm.value.desc
workflowDefault.value.nodes[0].properties.node_data.name = applicationForm.value.name workflowDefault.value.nodes[0].properties.node_data.name = applicationForm.value.name
applicationForm.value['work_flow'] = workflowDefault.value applicationForm.value['work_flow'] = workflowDefault.value
} }
applicationApi.postApplication('default', applicationForm.value, loading).then((res) => { console.log(applicationForm.value.type)
applicationApi
.postApplication(
'default',
{ ...applicationForm.value, folder_id: currentFolder.value },
loading,
)
.then((res) => {
MsgSuccess(t('common.createSuccess')) MsgSuccess(t('common.createSuccess'))
emit('refresh') emit('refresh')
if (isWorkFlow(applicationForm.value.type)) { if (isWorkFlow(applicationForm.value.type)) {

View File

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