wujingjing
2024-12-11 2144fb07b53812f565b2801f99e69cee9b28cab3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<template>
    <div
        class="min-w-[320px] w-max-[520px] border-2 rounded-lg border-solid border-gray-100 bg-white p-3 shadow-md relative hover:border-blue-500 group"
    >
        <Handle :id="targetHandleId" type="source" :position="Position.Left" />
        <div
            class="group-hover:visible invisible flex absolute divide-y-[1.5px] divide-solid divide-gray-100 rounded-lg right-0 -top-0.5 translate-y-[-100%]"
            style="box-shadow: 0 0 15px #dbdee6"
        >
            <el-tooltip effect="dark" content="复制" placement="top">
                <div
                    class="flex content-center items-center border-x-0 p-1 hover:bg-gray-200 active:bg-gray-300 cursor-pointer"
                    @click="handleClickDuplicateBtn"
                >
                    <span class="ywifont !text-[20px] mb-1 p-1.5 ywicon-copy"></span>
                </div>
            </el-tooltip>
            <el-tooltip effect="dark" content="删除" placement="top">
                <div
                    @click="clickDeleteBtn"
                    class="flex content-center items-center border-x-0 p-1 hover:bg-gray-200 active:bg-gray-300 hover:text-red-400 cursor-pointer"
                >
                    <span class="ywifont !text-[20px] mb-1 p-1.5 ywicon-shanchu"></span>
                </div>
            </el-tooltip>
        </div>
        <div class="flex flex-col gap-y-2">
            <div class="flex justify-between flex-0">
                <div class="flex items-center gap-x-2">
                    <img src="/@/components/vue-flow/ui/assets/images/icon_Start.png" class="h-4 w-4" alt="Start icon" />
                    <div class="flex flex-col gap-y-1">
                        <p v-if="!titleIsEdit" class="text-xl font-bold text-gray-500" @click="titleIsEdit = true">{{ data.title }}</p>
                        <el-input v-else v-model="data.title" @blur="() => (titleIsEdit = false)"></el-input>
                    </div>
                </div>
            </div>
 
            <div class="flex-auto gap-y-2 flex-col flex nodrag w-full">
                <!-- <div class="text-lg font-bold">提示词</div> -->
 
                <div class="flex-column gap-y-1.5 w-full">
                    <span class="self-start text-gray-500">{{ VueFlowHelper.getParams(outputParams, 'output_msg').label }}</span>
                    <el-input
                        v-model="VueFlowHelper.getParams(outputParams, 'output_msg').value.msg"
                        type="textarea"
                        :rows="4"
                        :placeholder="VueFlowHelper.getParams(outputParams, 'output_msg').placeholder"
                        autocomplete="off"
                    >
                    </el-input>
                </div>
                <div class="flex-column gap-y-1.5 w-full">
                    <span class="self-start text-gray-500">{{ VueFlowHelper.getParams(outputParams, 'output_result').label }}</span>
 
                    <el-radio-group v-model="VueFlowHelper.getParams(outputParams, 'output_result').value.type">
                        <el-radio v-for="item in Object.keys(interactionTypeMap)" :key="item" :value="item">{{
                            interactionTypeMap[item]
                        }}</el-radio>
                    </el-radio-group>
 
                    
                </div>
            </div>
        </div>
        <Handle :id="sourceHandleId" type="source" :position="Position.Right" />
    </div>
 
    <!-- <div>
        <span>起始</span>
 
        <Handle type="source" :position="Position.Right" />
    </div> -->
</template>
 
<script lang="ts" setup>
import { Handle, Position, useNode, useVueFlow } from '@vue-flow/core';
import { ref } from 'vue';
 
import type { NodeProps } from '@vue-flow/core';
import { VueFlowHelper } from '../../VueFlowHelper';
import { LLMNodeData, LLMNodeEvents } from './index';
import { deepClone } from '/@/utils/other';
import { interactionTypeMap } from '../../vueFlowEnum';
defineProps<NodeProps<LLMNodeData, LLMNodeEvents>>();
 
const node = useNode();
const sourceHandleId = ref(VueFlowHelper.getHandleId(node.node, 'source'));
const targetHandleId = ref(VueFlowHelper.getHandleId(node.node, 'target'));
 
const data = ref(node.node.data);
 
 
const titleIsEdit = ref(false);
 
const outputParams = ref(VueFlowHelper.getGroupParam(data.value, 0));
 
const { removeNodes, nodes, addNodes } = useVueFlow();
 
function handleClickDuplicateBtn() {
    const { type, position, data } = node.node;
    const newNode = {
        id: VueFlowHelper.genGeometryId(),
        type,
        position: {
            x: position.x + 100,
            y: position.y + 100,
        },
        data: deepClone(data),
    };
    addNodes(newNode);
}
const clickDeleteBtn = () => {
    removeNodes(node.id);
};
</script>