feat: 工作编排

This commit is contained in:
wangdan-fit2cloud 2024-06-11 16:31:13 +08:00
parent 4d1bc1e40b
commit 6f14abcd56
7 changed files with 73 additions and 38 deletions

View File

@ -38,8 +38,8 @@
<script setup lang="ts">
import { ref, onMounted, onBeforeUnmount, computed } from 'vue'
import Workflow from '@/workflow/index.vue'
import { menuNodes } from '@/workflow/common/data.ts'
import { iconComponent } from '@/workflow/icons/utils.ts'
import { menuNodes } from '@/workflow/common/data'
import { iconComponent } from '@/workflow/icons/utils'
const workflowRef = ref()

View File

@ -162,3 +162,17 @@ export const menuNodes = [
}
}
]
export const compareList = [
{ value: 'contain', label: '包含' },
{ value: 'eq', label: '等于' },
{ value: 'ge', label: '大于等于' },
{ value: 'gt', label: '大于' },
{ value: 'le', label: '小于等于' },
{ value: 'len_eq', label: '长度等于' },
{ value: 'len_ge', label: '长度大于等于' },
{ value: 'len_gt', label: '长度大于' },
{ value: 'len_le', label: '长度小于等于' },
{ value: 'len_lt', label: '长度小于' },
{ value: 'lt', label: '小于' }
]

View File

@ -56,7 +56,8 @@ const graphData = {
similarity: 0.6,
max_paragraph_char_number: 5000,
search_mode: 'embedding'
}
},
question_reference_address: []
}
}
},
@ -76,16 +77,19 @@ const graphData = {
{
conditions: [{ field: [], compare: '', value: '' }],
id: '2391',
type: 'IF',
condition: 'and'
},
{
conditions: [{ field: [], compare: '', value: '' }],
id: '1143',
type: 'IF ELSE 1',
condition: 'and'
},
{
conditions: [{ field: [], compare: '', value: '' }],
id: '9208',
type: 'ELSE',
condition: 'and'
}
]

View File

@ -83,9 +83,9 @@
</el-select>
</el-form-item>
<el-form-item label="角色设定">
<el-input v-model="chat_data.role" placeholder="角色设定" />
<el-input v-model="chat_data.system" placeholder="角色设定" />
</el-form-item>
<el-form-item label="提示词" prop="model_setting.prompt">
<el-form-item label="提示词" prop="prompt">
<template #label>
<div class="flex align-center">
<div class="flex-between mr-4">
@ -101,7 +101,7 @@
</div>
</template>
<el-input
v-model="chat_data.model_setting.prompt"
v-model="chat_data.prompt"
:rows="6"
type="textarea"
maxlength="2048"
@ -110,8 +110,8 @@
</el-form-item>
<el-form-item label="历史聊天记录">
<el-input-number
v-model="chat_data.record"
:min="1"
v-model="chat_data.dialogue_number"
:min="0"
controls-position="right"
class="w-full"
/>
@ -152,11 +152,9 @@ const defaultPrompt =
'已知信息:\n{data}\n回答要求\n- 请使用简洁且专业的语言来回答用户的问题。\n- 如果你不知道答案,请回答“没有在知识库中查找到相关信息,建议咨询相关技术支持或参考官方文档进行操作”。\n- 避免提及你是从已知信息中获得的知识。\n- 请保证答案与已知信息中描述的一致。\n- 请使用 Markdown 语法优化答案的格式。\n- 已知信息中的图片、链接地址和脚本语言请直接返回。\n- 请使用与问题相同的语言来回答。\n问题\n{question}'
const form = {
model_id: '',
role: '',
model_setting: {
prompt: defaultPrompt
},
record: 1
system: '',
prompt: defaultPrompt,
dialogue_number: 1
}
const chat_data = computed({

View File

@ -13,7 +13,17 @@
>
<template v-for="(item, index) in form_data.branch" :key="index">
<el-card shadow="never" class="card-never mb-8" style="--el-card-padding: 12px">
<p class="lighter">{{ judgeLabel(index) }}</p>
<div class="flex-between lighter">
{{ item.type }}
<div class="info" v-if="item.conditions.length > 1">
<span>符合以下</span>
<el-select v-model="item.condition" size="small" style="width: 60px; margin: 0 8px">
<el-option label="所有" value="and" />
<el-option label="任一" value="or" />
</el-select>
<span>条件</span>
</div>
</div>
<div v-if="index !== form_data.branch.length - 1" class="mt-8">
<template v-for="(condition, cIndex) in item.conditions" :key="cIndex">
<el-row :gutter="8">
@ -45,8 +55,9 @@
}"
>
<el-select v-model="condition.compare" placeholder="请选择条件" clearable>
<el-option label="Zone one" value="shanghai" />
<el-option label="Zone two" value="beijing" />
<template v-for="(item, index) in compareList" :key="index">
<el-option :label="item.label" :value="item.value" />
</template>
</el-select>
</el-form-item>
</el-col>
@ -63,7 +74,13 @@
</el-form-item>
</el-col>
<el-col :span="1">
<el-button link type="info" class="mt-4" @click="deleteCondition(index, cIndex)">
<el-button
:disabled="index === 0 && cIndex === 0"
link
type="info"
class="mt-4"
@click="deleteCondition(index, cIndex)"
>
<el-icon><Delete /></el-icon>
</el-button>
</el-col>
@ -94,6 +111,7 @@ import NodeCascader from '@/workflow/common/NodeCascader.vue'
import type { FormInstance } from 'element-plus'
import { ref, computed, onMounted } from 'vue'
import { randomId } from '@/utils/utils'
import { compareList } from '@/workflow/common/data'
const props = defineProps<{ nodeModel: any }>()
const form = {
branch: [
@ -106,11 +124,13 @@ const form = {
}
],
id: randomId(),
type: 'IF',
condition: 'and'
},
{
conditions: [],
id: randomId(),
type: 'ELSE',
condition: 'and'
}
]
@ -136,15 +156,15 @@ const validate = () => {
ConditionNodeFormRef.value?.validate()
}
const judgeLabel = (index: number) => {
if (index === 0) {
return 'IF'
} else if (index === form_data.value.branch.length - 1) {
return 'ELSE'
} else {
return 'ELSE IF ' + index
}
}
// const judgeLabel = (index: number) => {
// if (index === 0) {
// return 'IF'
// } else if (index === form_data.value.branch.length - 1) {
// return 'ELSE'
// } else {
// return 'ELSE IF ' + index
// }
// }
function addBranch() {
const list = cloneDeep(props.nodeModel.properties.node_data.branch)
@ -156,6 +176,7 @@ function addBranch() {
value: ''
}
],
type: 'ELSE IF ' + (list.length - 1),
id: randomId(),
condition: 'and'
}

View File

@ -83,9 +83,9 @@
</el-select>
</el-form-item>
<el-form-item label="角色设定">
<el-input v-model="chat_data.role" placeholder="角色设定" />
<el-input v-model="chat_data.system" placeholder="角色设定" />
</el-form-item>
<el-form-item label="提示词" prop="model_setting.prompt">
<el-form-item label="提示词" prop="prompt">
<template #label>
<div class="flex align-center">
<div class="flex-between mr-4">
@ -102,7 +102,7 @@
</div>
</template>
<el-input
v-model="chat_data.model_setting.prompt"
v-model="chat_data.prompt"
:rows="6"
type="textarea"
maxlength="2048"
@ -111,8 +111,8 @@
</el-form-item>
<el-form-item label="历史聊天记录">
<el-input-number
v-model="chat_data.record"
:min="1"
v-model="chat_data.dialogue_number"
:min="0"
controls-position="right"
class="w-full"
/>
@ -153,11 +153,9 @@ const defaultPrompt =
'已知信息:\n{data}\n回答要求\n- 请使用简洁且专业的语言来回答用户的问题。\n- 如果你不知道答案,请回答“没有在知识库中查找到相关信息,建议咨询相关技术支持或参考官方文档进行操作”。\n- 避免提及你是从已知信息中获得的知识。\n- 请保证答案与已知信息中描述的一致。\n- 请使用 Markdown 语法优化答案的格式。\n- 已知信息中的图片、链接地址和脚本语言请直接返回。\n- 请使用与问题相同的语言来回答。\n问题\n{question}'
const form = {
model_id: '',
role: '',
model_setting: {
prompt: defaultPrompt
},
record: 1
system: '',
prompt: defaultPrompt,
dialogue_number: 1
}
const chat_data = computed({

View File

@ -81,7 +81,7 @@
:nodeModel="nodeModel"
class="w-full"
placeholder="请选择检索问题输入"
v-model="form_data.fields"
v-model="form_data.question_reference_address"
/>
</el-form-item>
</el-form>
@ -126,7 +126,7 @@ const form = {
max_paragraph_char_number: 5000,
search_mode: 'embedding'
},
fields: []
question_reference_address: []
}
const form_data = computed({