feat: 支持节点参数设置直接输出

This commit is contained in:
wangdan-fit2cloud 2024-08-02 13:43:49 +08:00 committed by shaohuzhang1
parent 89b9f06f45
commit 03ecebe506
4 changed files with 82 additions and 3 deletions

View File

@ -170,3 +170,13 @@ export const nodeDict: any = {
export function isWorkFlow(type: string | undefined) {
return type === 'WORK_FLOW'
}
export function isLastNode(nodeModel: any) {
const incoming = nodeModel.graphModel.getNodeIncomingNode(nodeModel.id)
const outcomming = nodeModel.graphModel.getNodeOutgoingNode(nodeModel.id)
if (incoming.length > 0 && outcomming.length === 0) {
return true
} else {
return false
}
}

View File

@ -132,6 +132,23 @@
class="w-full"
/>
</el-form-item>
<el-form-item label="返回内容" @click.prevent>
<template #label>
<div class="flex align-center">
<div class="mr-4">
<span>返回内容<span class="danger">*</span></span>
</div>
<el-tooltip effect="dark" placement="right" popper-class="max-w-200">
<template #content>
关闭后该节点的内容则不输出给用户
如果你想让用户看到该节点的输出内容请打开开关
</template>
<AppIcon iconName="app-warning" class="app-warning-icon"></AppIcon>
</el-tooltip>
</div>
</template>
<el-switch size="small" v-model="chat_data.is_return" />
</el-form-item>
</el-form>
</el-card>
@ -156,6 +173,7 @@ import applicationApi from '@/api/application'
import useStore from '@/stores'
import { relatedObject } from '@/utils/utils'
import type { Provider } from '@/api/type/model'
import { isLastNode } from '@/workflow/common/data'
const { model } = useStore()
const isKeyDown = ref(false)
@ -180,7 +198,8 @@ const form = {
model_id: '',
system: '',
prompt: defaultPrompt,
dialogue_number: 1
dialogue_number: 1,
is_return: false
}
const chat_data = computed({
@ -240,6 +259,10 @@ const openCreateModel = (provider?: Provider) => {
onMounted(() => {
getProvider()
getModel()
if (isLastNode(props.nodeModel)) {
set(props.nodeModel.properties.node_data, 'is_return', true)
}
set(props.nodeModel, 'validate', validate)
})
</script>

View File

@ -133,6 +133,23 @@
class="w-full"
/>
</el-form-item>
<el-form-item label="返回内容" @click.prevent>
<template #label>
<div class="flex align-center">
<div class="mr-4">
<span>返回内容<span class="danger">*</span></span>
</div>
<el-tooltip effect="dark" placement="right" popper-class="max-w-200">
<template #content>
关闭后该节点的内容则不输出给用户
如果你想让用户看到该节点的输出内容请打开开关
</template>
<AppIcon iconName="app-warning" class="app-warning-icon"></AppIcon>
</el-tooltip>
</div>
</template>
<el-switch size="small" v-model="form_data.is_return" />
</el-form-item>
</el-form>
</el-card>
<!-- 添加模版 -->
@ -156,6 +173,8 @@ import applicationApi from '@/api/application'
import useStore from '@/stores'
import { relatedObject } from '@/utils/utils'
import type { Provider } from '@/api/type/model'
import { isLastNode } from '@/workflow/common/data'
const { model } = useStore()
const isKeyDown = ref(false)
const wheel = (e: any) => {
@ -177,7 +196,8 @@ const form = {
model_id: '',
system: '你是一个问题优化大师',
prompt: defaultPrompt,
dialogue_number: 1
dialogue_number: 1,
is_return: false
}
const form_data = computed({
@ -237,6 +257,9 @@ const openCreateModel = (provider?: Provider) => {
onMounted(() => {
getProvider()
getModel()
if (isLastNode(props.nodeModel)) {
set(props.nodeModel.properties.node_data, 'is_return', true)
}
set(props.nodeModel, 'validate', validate)
})
</script>

View File

@ -46,6 +46,23 @@
v-model="form_data.fields"
/>
</el-form-item>
<el-form-item label="返回内容" @click.prevent>
<template #label>
<div class="flex align-center">
<div class="mr-4">
<span>返回内容<span class="danger">*</span></span>
</div>
<el-tooltip effect="dark" placement="right" popper-class="max-w-200">
<template #content>
关闭后该节点的内容则不输出给用户
如果你想让用户看到该节点的输出内容请打开开关
</template>
<AppIcon iconName="app-warning" class="app-warning-icon"></AppIcon>
</el-tooltip>
</div>
</template>
<el-switch size="small" v-model="form_data.is_return" />
</el-form-item>
</el-form>
</el-card>
<!-- 回复内容弹出层 -->
@ -64,12 +81,14 @@ import { set } from 'lodash'
import NodeContainer from '@/workflow/common/NodeContainer.vue'
import NodeCascader from '@/workflow/common/NodeCascader.vue'
import { ref, computed, onMounted } from 'vue'
import { isLastNode } from '@/workflow/common/data'
const props = defineProps<{ nodeModel: any }>()
const form = {
reply_type: 'content',
content: '',
fields: []
fields: [],
is_return: false
}
const footers: any = [null, '=', 0]
@ -111,6 +130,10 @@ const validate = () => {
}
onMounted(() => {
if (isLastNode(props.nodeModel)) {
set(props.nodeModel.properties.node_data, 'is_return', true)
}
set(props.nodeModel, 'validate', validate)
})
</script>