feat: 编排

This commit is contained in:
wangdan-fit2cloud 2024-06-05 15:53:58 +08:00
parent 7b88a09a22
commit af30ffc5e5
9 changed files with 83 additions and 43 deletions

View File

@ -3,7 +3,7 @@
<el-button-group>
<el-button size="small" @click="$_zoomIn">放大</el-button>
<el-button size="small" @click="$_zoomOut">缩小</el-button>
<el-button size="small" @click="$_reset">还原(大小&定位)</el-button>
<el-button size="small" @click="$_reset">适应</el-button>
</el-button-group>
</div>
</template>
@ -23,6 +23,7 @@ function $_zoomOut() {
function $_reset() {
props.lf?.resetZoom()
props.lf?.resetTranslate()
props.lf?.fitView()
}
</script>
<style scoped></style>

View File

@ -0,0 +1,6 @@
<template>
<AppAvatar shape="square" style="background: #D136D1;">
<img src="@/assets/icon_start.svg" style="width: 75%" alt="" />
</AppAvatar>
</template>
<script setup lang="ts"></script>

View File

@ -25,7 +25,7 @@ type ShapeItem = {
className?: string
disabled?: boolean
properties?: Record<string, any>
callback?: (lf: LogicFlow, container: HTMLElement) => void
callback?: (lf: LogicFlow, container?: HTMLElement) => void
}
const graphData = {
@ -52,24 +52,24 @@ const graphData = {
id: '34902d3d-a3ff-497f-b8e1-0c34a44d7dd4',
type: 'start-node',
x: 180,
y: 623,
y: 723,
properties: {
height: 200,
stepName: '开始',
// input: [{ key: '' }],
input: [{ key: '输入' }],
output: [{ key: '输出' }]
// node_data: { model: 'shanghai', name: '222222' }
}
},
{
id: '34902d3d-a3ff-497f-b8e1-0c34a44d7dd4',
id: '34902d3d-a3ff-497f-b8e1-0c34a44d7dd5',
type: 'search-dataset-node',
x: 500,
x: 600,
y: 250,
properties: {
height: 200,
stepName: '开始',
// input: [{ key: '' }],
stepName: '知识库检索',
input: [{ key: '输入' }],
output: [{ key: '输出' }]
// node_data: { model: 'shanghai', name: '222222' }
}
@ -207,8 +207,8 @@ defineExpose({
position: relative;
.control {
position: absolute;
bottom: 50px;
right: 50px;
bottom: 24px;
left: 24px;
z-index: 2;
}
}

View File

@ -31,11 +31,11 @@ const shapeList = [
{
type: 'search-dataset-node',
text: '关联知识库,查找与问题相关的分段',
label: '知识检索',
label: '知识检索',
icon: 'search-dataset-node-icon',
properties: {
height: '',
stepName: '知识检索',
stepName: '知识检索',
input: [
{
key: '输入'

View File

@ -41,6 +41,7 @@
</NodeContainer>
</template>
<script setup lang="ts">
import { set } from 'lodash'
import NodeContainer from '@/components/workflow/common/node-container/index.vue'
import type { FormInstance } from 'element-plus'
import { ref, computed, onMounted } from 'vue'

View File

@ -0,0 +1,12 @@
import ChatNodeVue from './index.vue'
import { AppNode, AppNodeModel } from '@/components/workflow/common/app-node/index'
class ChatNode extends AppNode {
constructor(props: any) {
super(props, ChatNodeVue)
}
}
export default {
type: 'start-node',
model: AppNodeModel,
view: ChatNode
}

View File

@ -0,0 +1,46 @@
<template>
<NodeContainer :nodeModel="nodeModel" class="start-node">
<h5 class="title-decoration-1 mb-8">全局变量</h5>
<div class="border-r-4 p-8-12 mb-8 layout-bg lighter">当前时 {time}</div>
<h5 class="title-decoration-1 mb-8">参数输出</h5>
<div class="border-r-4 p-8-12 mb-8 layout-bg lighter">用户问题 {question}</div>
</NodeContainer>
</template>
<script setup lang="ts">
import NodeContainer from '@/components/workflow/common/node-container/index.vue'
import type { FormInstance } from 'element-plus'
import { ref, computed, onMounted } from 'vue'
const condition_data = computed({
get: () => {
if (props.nodeModel.properties.node_data) {
return props.nodeModel.properties.node_data
} else {
props.nodeModel.properties.node_data = {
name: '',
desc: '',
prologue:
'您好,我是 MaxKB 小助手,您可以向我提出 MaxKB 使用问题。\n- MaxKB 主要功能有什么?\n- MaxKB 支持哪些大语言模型?\n- MaxKB 支持哪些文档类型?'
}
}
return props.nodeModel.properties.node_data
},
set: (value) => {
props.nodeModel.properties.node_data = value
}
})
const props = defineProps<{ nodeModel: any }>()
const handleFocus = () => {
props.nodeModel.isSelected = false
}
const aiChatNodeFormRef = ref<FormInstance>()
const validate = () => {
aiChatNodeFormRef.value?.validate()
}
onMounted(() => {
props.nodeModel.validate = validate
})
</script>
<style lang="scss" scoped></style>

View File

@ -108,6 +108,8 @@ const {
const props = defineProps<{ nodeModel: any }>()
console.log(props.nodeModel)
const form = {
dataset_id_list: [],
dataset_setting: {
@ -156,7 +158,9 @@ function addDataset(val: Array<string>) {
}
function openDatasetDialog() {
AddDatasetDialogRef.value.open(form_data.value.dataset_id_list)
if (AddDatasetDialogRef.value) {
AddDatasetDialogRef.value.open(form_data.value.dataset_id_list)
}
}
function getDataset() {

View File

@ -11,36 +11,6 @@ import NodeContainer from '@/components/workflow/common/node-container/index.vue
import type { FormInstance } from 'element-plus'
import { ref, computed, onMounted } from 'vue'
// const chat_data = computed({
// get: () => {
// if (props.nodeModel.properties.node_data) {
// return props.nodeModel.properties.node_data
// } else {
// props.nodeModel.properties.node_data = {
// name: '',
// desc: '',
// prologue:
// ' MaxKB MaxKB 使\n- MaxKB \n- MaxKB \n- MaxKB '
// }
// }
// return props.nodeModel.properties.node_data
// },
// set: (value) => {
// props.nodeModel.properties.node_data = value
// }
// })
const props = defineProps<{ nodeModel: any }>()
const handleFocus = () => {
props.nodeModel.isSelected = false
}
const aiChatNodeFormRef = ref<FormInstance>()
const validate = () => {
aiChatNodeFormRef.value?.validate()
}
onMounted(() => {
props.nodeModel.validate = validate
})
</script>
<style lang="scss" scoped></style>