Skip to content

Commit 28c09ae

Browse files
authored
feat: create application ui (#3190)
1 parent bfa15c2 commit 28c09ae

File tree

3 files changed

+51
-43
lines changed

3 files changed

+51
-43
lines changed

ui/src/api/type/application.ts

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ interface ApplicationFormType {
77
model_id?: string
88
dialogue_number?: number
99
prologue?: string
10-
dataset_id_list?: string[]
11-
dataset_setting?: any
10+
knowledge_id_list?: string[]
11+
knowledge_setting?: any
1212
model_setting?: any
1313
problem_optimization?: boolean
1414
problem_optimization_prompt?: string
@@ -24,6 +24,7 @@ interface ApplicationFormType {
2424
tts_type?: string
2525
tts_autoplay?: boolean
2626
stt_autosend?: boolean
27+
folder_id?: string
2728
}
2829
interface Chunk {
2930
real_node_id: string
@@ -118,7 +119,7 @@ export class ChatRecordManage {
118119
chat_record_id?: string,
119120
runtime_node_id?: string,
120121
child_node?: any,
121-
real_node_id?: string
122+
real_node_id?: string,
122123
) {
123124
if (chunk_answer || reasoning_content) {
124125
const set_index = index != undefined ? index : this.chat.answer_text_list.length - 1
@@ -142,7 +143,7 @@ export class ChatRecordManage {
142143
chat_record_id,
143144
runtime_node_id,
144145
child_node,
145-
real_node_id
146+
real_node_id,
146147
})
147148
}
148149
}
@@ -167,7 +168,7 @@ export class ChatRecordManage {
167168
return this.write_node_info
168169
}
169170
const run_node = this.node_list.filter(
170-
(item) => item.reasoning_content_buffer.length > 0 || item.buffer.length > 0 || !item.is_end
171+
(item) => item.reasoning_content_buffer.length > 0 || item.buffer.length > 0 || !item.is_end,
171172
)[0]
172173

173174
if (run_node) {
@@ -185,7 +186,7 @@ export class ChatRecordManage {
185186
const none_index = this.findIndex(
186187
this.chat.answer_text_list,
187188
(item) => (item.length == 1 && item[0].content == '') || item.length == 0,
188-
'index'
189+
'index',
189190
)
190191
if (none_index > -1) {
191192
answer_text_list_index = none_index
@@ -196,7 +197,7 @@ export class ChatRecordManage {
196197
const none_index = this.findIndex(
197198
this.chat.answer_text_list,
198199
(item) => (item.length == 1 && item[0].content == '') || item.length == 0,
199-
'index'
200+
'index',
200201
)
201202
if (none_index > -1) {
202203
answer_text_list_index = none_index
@@ -208,7 +209,7 @@ export class ChatRecordManage {
208209
this.write_node_info = {
209210
current_node: run_node,
210211
current_up_node: current_up_node,
211-
answer_text_list_index: answer_text_list_index
212+
answer_text_list_index: answer_text_list_index,
212213
}
213214

214215
return this.write_node_info
@@ -241,7 +242,7 @@ export class ChatRecordManage {
241242
const last_index = this.findIndex(
242243
this.chat.answer_text_list,
243244
(item) => (item.length == 1 && item[0].content == '') || item.length == 0,
244-
'last'
245+
'last',
245246
)
246247
if (last_index > 0) {
247248
this.chat.answer_text_list.splice(last_index, 1)
@@ -274,13 +275,13 @@ export class ChatRecordManage {
274275
? current_node.buffer.splice(0)
275276
: current_node.buffer.splice(
276277
0,
277-
current_node.is_end ? undefined : current_node.buffer.length - 20
278+
current_node.is_end ? undefined : current_node.buffer.length - 20,
278279
)
279280
const reasoning_content = current_node.is_end
280281
? current_node.reasoning_content_buffer.splice(0)
281282
: current_node.reasoning_content_buffer.splice(
282283
0,
283-
current_node.is_end ? undefined : current_node.reasoning_content_buffer.length - 20
284+
current_node.is_end ? undefined : current_node.reasoning_content_buffer.length - 20,
284285
)
285286
this.append_answer(
286287
context.join(''),
@@ -289,7 +290,7 @@ export class ChatRecordManage {
289290
current_node.chat_record_id,
290291
current_node.runtime_node_id,
291292
current_node.child_node,
292-
current_node.real_node_id
293+
current_node.real_node_id,
293294
)
294295
} else if (this.is_close) {
295296
while (true) {
@@ -305,7 +306,7 @@ export class ChatRecordManage {
305306
node_info.current_node.chat_record_id,
306307
node_info.current_node.runtime_node_id,
307308
node_info.current_node.child_node,
308-
node_info.current_node.real_node_id
309+
node_info.current_node.real_node_id,
309310
)
310311

311312
if (
@@ -327,7 +328,7 @@ export class ChatRecordManage {
327328
current_node.chat_record_id,
328329
current_node.runtime_node_id,
329330
current_node.child_node,
330-
current_node.real_node_id
331+
current_node.real_node_id,
331332
)
332333
}
333334
if (reasoning_content !== undefined) {
@@ -338,7 +339,7 @@ export class ChatRecordManage {
338339
current_node.chat_record_id,
339340
current_node.runtime_node_id,
340341
current_node.child_node,
341-
current_node.real_node_id
342+
current_node.real_node_id,
342343
)
343344
}
344345
}
@@ -383,7 +384,7 @@ export class ChatRecordManage {
383384
node_type: chunk.node_type,
384385
index: this.node_list.length,
385386
view_type: chunk.view_type,
386-
is_end: false
387+
is_end: false,
387388
}
388389
this.node_list.push(n)
389390
}
@@ -395,16 +396,16 @@ export class ChatRecordManage {
395396
let set_index = this.findIndex(
396397
this.chat.answer_text_list,
397398
(item) => item.length == 1 && item[0].content == '',
398-
'index'
399+
'index',
399400
)
400401
if (set_index <= -1) {
401402
set_index = 0
402403
}
403404
this.chat.answer_text_list[set_index] = [
404405
{
405406
content: answer_text_block,
406-
reasoning_content: reasoning_content ? reasoning_content : ''
407-
}
407+
reasoning_content: reasoning_content ? reasoning_content : '',
408+
},
408409
]
409410
}
410411
}

ui/src/views/application/component/CreateApplicationDialog.vue

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,11 @@ const dialogVisible = ref<boolean>(false)
121121
const applicationForm = ref<ApplicationFormType>({
122122
name: '',
123123
desc: '',
124-
model_id: '',
124+
model_id: undefined,
125125
dialogue_number: 1,
126126
prologue: t('views.application.form.defaultPrologue'),
127-
dataset_id_list: [],
128-
dataset_setting: {
127+
knowledge_id_list: [],
128+
knowledge_setting: {
129129
top_n: 3,
130130
similarity: 0.6,
131131
max_paragraph_char_number: 5000,
@@ -143,8 +143,8 @@ const applicationForm = ref<ApplicationFormType>({
143143
model_params_setting: {},
144144
problem_optimization: false,
145145
problem_optimization_prompt: optimizationPrompt,
146-
stt_model_id: '',
147-
tts_model_id: '',
146+
stt_model_id: undefined,
147+
tts_model_id: undefined,
148148
stt_model_enable: false,
149149
tts_model_enable: false,
150150
tts_type: 'BROWSER',
@@ -175,11 +175,11 @@ watch(dialogVisible, (bool) => {
175175
applicationForm.value = {
176176
name: '',
177177
desc: '',
178-
model_id: '',
178+
model_id: undefined,
179179
dialogue_number: 1,
180180
prologue: t('views.application.form.defaultPrologue'),
181-
dataset_id_list: [],
182-
dataset_setting: {
181+
knowledge_id_list: [],
182+
knowledge_setting: {
183183
top_n: 3,
184184
similarity: 0.6,
185185
max_paragraph_char_number: 5000,
@@ -197,8 +197,8 @@ watch(dialogVisible, (bool) => {
197197
model_params_setting: {},
198198
problem_optimization: false,
199199
problem_optimization_prompt: optimizationPrompt,
200-
stt_model_id: '',
201-
tts_model_id: '',
200+
stt_model_id: undefined,
201+
tts_model_id: undefined,
202202
stt_model_enable: false,
203203
tts_model_enable: false,
204204
tts_type: 'BROWSER',
@@ -208,32 +208,39 @@ watch(dialogVisible, (bool) => {
208208
}
209209
})
210210
211-
const open = (folder: string, type?: sting) => {
211+
const open = (folder: string, type?: string) => {
212212
currentFolder.value = folder
213213
applicationForm.value.type = type || 'SIMPLE'
214214
dialogVisible.value = true
215215
}
216216
217217
const submitHandle = async (formEl: FormInstance | undefined) => {
218218
if (!formEl) return
219+
console.log(applicationForm.value.type)
219220
await formEl.validate((valid) => {
220221
if (valid) {
221-
applicationForm.value['folder_id'] = currentFolder.value
222222
if (isWorkFlow(applicationForm.value.type) && appTemplate.value === 'blank') {
223223
workflowDefault.value.nodes[0].properties.node_data.desc = applicationForm.value.desc
224224
workflowDefault.value.nodes[0].properties.node_data.name = applicationForm.value.name
225225
applicationForm.value['work_flow'] = workflowDefault.value
226226
}
227-
applicationApi.postApplication('default', applicationForm.value, loading).then((res) => {
228-
MsgSuccess(t('common.createSuccess'))
229-
emit('refresh')
230-
if (isWorkFlow(applicationForm.value.type)) {
231-
router.push({ path: `/application/${res.data.id}/workflow` })
232-
} else {
233-
router.push({ path: `/application/${res.data.id}/${res.data.type}/setting` })
234-
}
235-
dialogVisible.value = false
236-
})
227+
console.log(applicationForm.value.type)
228+
applicationApi
229+
.postApplication(
230+
'default',
231+
{ ...applicationForm.value, folder_id: currentFolder.value },
232+
loading,
233+
)
234+
.then((res) => {
235+
MsgSuccess(t('common.createSuccess'))
236+
emit('refresh')
237+
if (isWorkFlow(applicationForm.value.type)) {
238+
router.push({ path: `/application/${res.data.id}/workflow` })
239+
} else {
240+
router.push({ path: `/application/${res.data.id}/${res.data.type}/setting` })
241+
}
242+
dialogVisible.value = false
243+
})
237244
}
238245
})
239246
}

ui/src/views/application/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
</el-button>
4848
<template #dropdown>
4949
<el-dropdown-menu class="create-dropdown">
50-
<el-dropdown-item @click="openCreateDialog">
50+
<el-dropdown-item @click="openCreateDialog('SIMPLE')">
5151
<div class="flex">
5252
<el-avatar shape="square" class="avatar-blue mt-4" :size="36">
5353
<img
@@ -248,7 +248,7 @@ import useStore from '@/stores'
248248
import { numberFormat } from '@/utils/common'
249249
import { t } from '@/locales'
250250
import { useRouter } from 'vue-router'
251-
251+
import { isWorkFlow } from '@/utils/application'
252252
const router = useRouter()
253253
const { folder } = useStore()
254254

0 commit comments

Comments
 (0)