| | |
| | | <template> |
| | | <div |
| | | class="w-max-[520px] border-2 rounded-lg border-solid border-gray-100 bg-white p-3 shadow-md relative hover:border-blue-500 group" |
| | | <NodeBasicLayout |
| | | v-model:title="data.title" |
| | | :type="NodeType.LLM" |
| | | :description="VueFlowHelper.getConfigValue(data, 'description', '调用大模型回答用户问题或者处理任务。')" |
| | | > |
| | | <Handle :id="targetHandleId" type="target" :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> |
| | | <FieldLayout :title="VueFlowHelper.getConfigValue(modelSetting, 'name', '模型设置')"> |
| | | <div class="w-[340px] flex-items-center gap-x-2"> |
| | | <div class="flex-column gap-y-1.5"> |
| | | <span class="text-gray-500">{{ VueFlowHelper.getParams(modelSetting, 'llm_model').label }}</span> |
| | | |
| | | <el-select |
| | | v-model="VueFlowHelper.getParams(modelSetting, 'llm_model').value" |
| | | class="w-[150px]" |
| | | :placeholder="VueFlowHelper.getParams(modelSetting, 'llm_model').placeholder" |
| | | > |
| | | <el-option v-for="item in VueFlowConstant.LLM_MODEL_LIST" :key="item.value" :label="item.label" :value="item.value" /> |
| | | </el-select> |
| | | </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"> |
| | | <YWIcon |
| | | :name="VueFlowConfig.nodeStyleMap.get(NodeType.LLM).icon" |
| | | :fontSize="VueFlowConfig.nodeStyleMap.get(NodeType.LLM).fontSize" |
| | | :color="VueFlowConfig.nodeStyleMap.get(NodeType.LLM).color" |
| | | class="rounded-lg p-1.5" |
| | | :class="VueFlowConfig.nodeStyleMap.get(NodeType.LLM).class" |
| | | /> |
| | | <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-elInputFocus="false" v-model="data.title" @blur="() => (titleIsEdit = false)"></el-input> |
| | | </div> |
| | | <div class="flex-column gap-y-1.5"> |
| | | <span class="text-gray-500">{{ VueFlowHelper.getParams(modelSetting, 'temperature').label }}</span> |
| | | <el-input-number |
| | | v-model="VueFlowHelper.getParams(modelSetting, 'temperature').value" |
| | | class="w-[180px]" |
| | | placeholder="" |
| | | ></el-input-number> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="flex-auto gap-y-2 flex-col flex nodrag"> |
| | | <div class="text-lg font-bold">模型设置</div> |
| | | |
| | | <div class="min-w-[340px] flex-items-center gap-x-2"> |
| | | <div class="flex-column gap-y-1.5"> |
| | | <span class="text-gray-500">模型</span> |
| | | |
| | | <el-select v-model="VueFlowHelper.getParams(modelSetting, 'llm_model').value" class="w-[150px]" placeholder="请选择模型"> |
| | | <el-option v-for="item in VueFlowConstant.LLM_MODEL_LIST" :key="item.value" :label="item.label" :value="item.value" /> |
| | | </el-select> |
| | | </div> |
| | | <div class="flex-column gap-y-1.5"> |
| | | <span class="text-gray-500">温度</span> |
| | | <el-input-number |
| | | v-model="VueFlowHelper.getParams(modelSetting, 'temperature').value" |
| | | class="w-[180px]" |
| | | placeholder="温度" |
| | | ></el-input-number> |
| | | </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="text-gray-500">模型</span> --> |
| | | <el-input v-model="VueFlowHelper.getParams(prompt, 'prompt').value" type="textarea" :rows="3" autocomplete="off"> </el-input> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </FieldLayout> |
| | | <FieldLayout :title="prompt.name"> |
| | | <el-input v-model="VueFlowHelper.getParams(prompt, 'prompt').value" type="textarea" :rows="3" autocomplete="off"> </el-input> |
| | | </FieldLayout> |
| | | <Handle :id="sourceHandleId" type="source" :position="Position.Right" /> |
| | | </div> |
| | | |
| | | <!-- <div> |
| | | <span>起始</span> |
| | | |
| | | <Handle type="source" :position="Position.Right" /> |
| | | </div> --> |
| | | </NodeBasicLayout> |
| | | </template> |
| | | |
| | | <script lang="ts" setup> |
| | |
| | | import { LLMNodeData, LLMNodeEvents } from './index'; |
| | | import { deepClone } from '/@/utils/other'; |
| | | import { NodeType } from '../../vueFlowEnum'; |
| | | import { VueFlowConfig } from '../VueFlowConfig'; |
| | | |
| | | import FieldLayout from './components/FieldLayout.vue'; |
| | | import NodeBasicLayout from './components/NodeBasicLayout.vue'; |
| | | |
| | | defineProps<NodeProps<LLMNodeData, LLMNodeEvents>>(); |
| | | |
| | |
| | | |
| | | const data = ref(node.node.data); |
| | | |
| | | const varList = ref(VueFlowHelper.getFieldValue(data.value, 'var_list')); |
| | | const titleIsEdit = ref(false); |
| | | |
| | | const modelSetting = ref(VueFlowHelper.getGroupParam(data.value, 0)); |
| | | const prompt = ref(VueFlowHelper.getGroupParam(data.value, 1)); |
| | | |
| | | 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); |
| | | }; |
| | | |
| | | VueFlowHelper.getConfigValue(VueFlowHelper.getParams(prompt.value, 'prompt'), 'label', ''); |
| | | </script> |