Skip to content

Commit 4367b1c

Browse files
feat: Create workflow applications that support template selection
1 parent 6b72611 commit 4367b1c

File tree

5 files changed

+99
-28
lines changed

5 files changed

+99
-28
lines changed

ui/src/locales/lang/en-US/views/application.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ export default {
4646
simplePlaceholder: 'Suitable for beginners to create assistant.',
4747
workflowPlaceholder: 'Suitable for advanced users to customize the workflow of assistant'
4848
},
49+
appTemplate: {
50+
blankApp: 'Blank APP',
51+
assistantApp: 'Knowledge Assistant'
52+
},
4953
aiModel: {
5054
label: 'AI Model',
5155
placeholder: 'Please select an AI model'
@@ -110,7 +114,7 @@ export default {
110114
reasoningContent: {
111115
label: 'Output Thinking',
112116
tooltip:
113-
'Please set the thinking label based on the model\'s return, and the content in the middle of the label will be recognized as the thinking process.',
117+
"Please set the thinking label based on the model's return, and the content in the middle of the label will be recognized as the thinking process.",
114118
start: 'Start',
115119
end: 'End'
116120
}
@@ -211,7 +215,7 @@ export default {
211215
slackSetting: {
212216
title: 'Slack Configuration',
213217
signingSecretPlaceholder: 'Please enter signing secret',
214-
botUserTokenPlaceholder: 'Please enter bot user token',
218+
botUserTokenPlaceholder: 'Please enter bot user token'
215219
},
216220
copyUrl: 'Copy the link and fill it in'
217221
},

ui/src/locales/lang/zh-CN/views/application.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ export default {
4141
simplePlaceholder: '适合新手创建小助手',
4242
workflowPlaceholder: '适合高级用户自定义小助手的工作流'
4343
},
44+
appTemplate: {
45+
blankApp: '空白应用',
46+
assistantApp: '知识库问答助手'
47+
},
4448
aiModel: {
4549
label: 'AI 模型',
4650
placeholder: '请选择 AI 模型'
@@ -198,7 +202,7 @@ export default {
198202
slackSetting: {
199203
title: 'Slack 应用配置',
200204
signingSecretPlaceholder: '请输入 Signing Secret',
201-
botUserTokenPlaceholder: '请输入 Bot User Token',
205+
botUserTokenPlaceholder: '请输入 Bot User Token'
202206
},
203207
copyUrl: '复制链接填入到'
204208
},

ui/src/locales/lang/zh-Hant/views/application.ts

+4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ export default {
4141
simplePlaceholder: '適合新手建立小助手',
4242
workflowPlaceholder: '適合高階用戶自訂小助手的工作流程'
4343
},
44+
appTemplate: {
45+
blankApp: '空白應用',
46+
assistantApp: '知識庫問答助手'
47+
},
4448
aiModel: {
4549
label: 'AI 模型',
4650
placeholder: '請選擇 AI 模型'

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

+56-11
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,7 @@
3838
<el-radio-group v-model="applicationForm.type" class="card__radio">
3939
<el-row :gutter="16">
4040
<el-col :span="12">
41-
<el-card
42-
shadow="never"
43-
class="mb-16"
44-
:class="applicationForm.type === 'SIMPLE' ? 'active' : ''"
45-
>
41+
<el-card shadow="never" :class="applicationForm.type === 'SIMPLE' ? 'active' : ''">
4642
<el-radio value="SIMPLE" size="large">
4743
<p class="mb-4">{{ $t('views.application.simple') }}</p>
4844
<el-text type="info">{{
@@ -52,11 +48,7 @@
5248
</el-card>
5349
</el-col>
5450
<el-col :span="12">
55-
<el-card
56-
shadow="never"
57-
class="mb-16"
58-
:class="isWorkFlow(applicationForm.type) ? 'active' : ''"
59-
>
51+
<el-card shadow="never" :class="isWorkFlow(applicationForm.type) ? 'active' : ''">
6052
<el-radio value="WORK_FLOW" size="large">
6153
<p class="mb-4">{{ $t('views.application.workflow') }}</p>
6254
<el-text type="info">{{
@@ -68,6 +60,35 @@
6860
</el-row>
6961
</el-radio-group>
7062
</el-form-item>
63+
<el-form-item
64+
:label="$t('views.document.upload.template')"
65+
v-if="applicationForm.type === 'WORK_FLOW'"
66+
>
67+
<div class="w-full">
68+
<el-row :gutter="16">
69+
<el-col :span="12">
70+
<el-card
71+
class="radio-card cursor"
72+
shadow="never"
73+
@click="selectedType('blank')"
74+
:class="appTemplate === 'blank' ? 'active' : ''"
75+
>
76+
{{ $t('views.application.applicationForm.form.appTemplate.blankApp') }}
77+
</el-card>
78+
</el-col>
79+
<el-col :span="12">
80+
<el-card
81+
class="radio-card cursor"
82+
shadow="never"
83+
:class="appTemplate === 'assistant' ? 'active' : ''"
84+
@click="selectedType('assistant')"
85+
>
86+
{{ $t('views.application.applicationForm.form.appTemplate.assistantApp') }}
87+
</el-card>
88+
</el-col>
89+
</el-row>
90+
</div>
91+
</el-form-item>
7192
</el-form>
7293
<template #footer>
7394
<span class="dialog-footer">
@@ -89,6 +110,7 @@ import type { FormInstance, FormRules } from 'element-plus'
89110
import applicationApi from '@/api/application'
90111
import { MsgSuccess, MsgAlert } from '@/utils/message'
91112
import { isWorkFlow } from '@/utils/application'
113+
import { baseNodes } from '@/workflow/common/data'
92114
import { t } from '@/locales'
93115
const router = useRouter()
94116
const emit = defineEmits(['refresh'])
@@ -106,6 +128,12 @@ const optimizationPrompt =
106128
'<data></data>' +
107129
t('views.application.applicationForm.dialog.defaultPrompt2')
108130
131+
const workflowDefault = ref<any>({
132+
edges: [],
133+
nodes: baseNodes
134+
})
135+
const appTemplate = ref('blank')
136+
109137
const applicationFormRef = ref()
110138
111139
const loading = ref(false)
@@ -207,6 +235,11 @@ const submitHandle = async (formEl: FormInstance | undefined) => {
207235
if (!formEl) return
208236
await formEl.validate((valid) => {
209237
if (valid) {
238+
if (isWorkFlow(applicationForm.value.type) && appTemplate.value === 'blank') {
239+
workflowDefault.value.nodes[0].properties.node_data.desc = applicationForm.value.desc
240+
workflowDefault.value.nodes[0].properties.node_data.name = applicationForm.value.name
241+
applicationForm.value['work_flow'] = workflowDefault.value
242+
}
210243
applicationApi.postApplication(applicationForm.value, loading).then((res) => {
211244
MsgSuccess(t('common.createSuccess'))
212245
if (isWorkFlow(applicationForm.value.type)) {
@@ -220,6 +253,18 @@ const submitHandle = async (formEl: FormInstance | undefined) => {
220253
})
221254
}
222255
256+
function selectedType(type: string) {
257+
appTemplate.value = type
258+
}
259+
223260
defineExpose({ open })
224261
</script>
225-
<style lang="scss" scope></style>
262+
<style lang="scss" scope>
263+
.radio-card {
264+
line-height: 22px;
265+
&.active {
266+
border-color: var(--el-color-primary);
267+
color: var(--el-color-primary);
268+
}
269+
}
270+
</style>

ui/src/workflow/common/data.ts

+28-14
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import { t } from '@/locales'
44
export const startNode = {
55
id: WorkflowType.Start,
66
type: WorkflowType.Start,
7-
x: 180,
8-
y: 720,
7+
x: 480,
8+
y: 3340,
99
properties: {
10-
height: 200,
10+
height: 364,
1111
stepName: t('views.applicationWorkflow.nodes.startNode.label'),
1212
config: {
1313
fields: [
@@ -20,29 +20,45 @@ export const startNode = {
2020
{
2121
value: 'time',
2222
label: t('views.applicationWorkflow.nodes.startNode.currentTime')
23+
},
24+
{
25+
value: 'history_context',
26+
label: t('views.application.applicationForm.form.historyRecord.label')
27+
},
28+
{
29+
value: 'chat_id',
30+
label: t('chat.chatId')
2331
}
2432
]
25-
}
33+
},
34+
fields: [{ label: t('views.applicationWorkflow.nodes.startNode.question'), value: 'question' }],
35+
globalFields: [
36+
{ label: t('views.applicationWorkflow.nodes.startNode.currentTime'), value: 'time' }
37+
],
38+
showNode: true
2639
}
2740
}
2841
export const baseNode = {
2942
id: WorkflowType.Base,
3043
type: WorkflowType.Base,
31-
x: 200,
32-
y: 270,
44+
x: 360,
45+
y: 2761.3875,
3346
text: '',
3447
properties: {
35-
width: 420,
36-
height: 200,
48+
height: 728.375,
3749
stepName: t('views.applicationWorkflow.nodes.baseNode.label'),
3850
input_field_list: [],
3951
node_data: {
4052
name: '',
4153
desc: '',
4254
// @ts-ignore
43-
prologue: t('views.application.applicationForm.form.defaultPrologue')
55+
prologue: t('views.application.applicationForm.form.defaultPrologue'),
56+
tts_type: 'BROWSER'
4457
},
45-
config: {}
58+
config: {},
59+
showNode: true,
60+
user_input_config: { title: t('chat.userInput') },
61+
user_input_field_list: []
4662
}
4763
}
4864
/**
@@ -246,9 +262,7 @@ export const variableAssignNode = {
246262
height: 252,
247263
properties: {
248264
stepName: t('views.applicationWorkflow.nodes.variableAssignNode.label'),
249-
config: {
250-
251-
}
265+
config: {}
252266
}
253267
}
254268

@@ -415,7 +429,7 @@ export const nodeDict: any = {
415429
[WorkflowType.TextToSpeechNode]: textToSpeechNode,
416430
[WorkflowType.SpeechToTextNode]: speechToTextNode,
417431
[WorkflowType.ImageGenerateNode]: imageGenerateNode,
418-
[WorkflowType.VariableAssignNode]: variableAssignNode,
432+
[WorkflowType.VariableAssignNode]: variableAssignNode
419433
}
420434
export function isWorkFlow(type: string | undefined) {
421435
return type === 'WORK_FLOW'

0 commit comments

Comments
 (0)