| | |
| | | v-model:title="data.title" |
| | | :type="NodeType.LLM" |
| | | :description="VueFlowHelper.getConfigValue(data, 'description', '调用大模型回答用户问题或者处理任务。')" |
| | | :isViewMode="isViewMode" |
| | | > |
| | | <Handle :id="targetHandleId" type="target" :position="Position.Left" /> |
| | | <FieldLayout :title="outputParam.name"> |
| | | <el-input class="w-full flex-0" v-model="outputParam.params[0].value" placeholder="输出参数名"> </el-input> |
| | | </FieldLayout> |
| | | <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-form :model="data" :rules="formRules" label-position="right" label-width="60px" status-icon> |
| | | <FieldLayout :title="VueFlowHelper.getConfigValue(modelSetting, 'name', '模型设置')"> |
| | | <div class="w-full flex-items-center gap-x-2"> |
| | | <div class="flex-column gap-y-1.5"> |
| | | <el-form-item |
| | | labelPosition="top" |
| | | :label="VueFlowHelper.getParams(modelSetting, 'llm_model').label" |
| | | prop="group_params.0.params.0.value" |
| | | > |
| | | <el-tree-select |
| | | v-model="VueFlowHelper.getParams(modelSetting, 'llm_model').value" |
| | | :data="llmInfoList" |
| | | :props="{ label: 'name', value: 'id' }" |
| | | :render-after-expand="false" |
| | | :check-strictly="false" |
| | | :show-checkbox="false" |
| | | :accordion="true" |
| | | :disabled="isViewMode" |
| | | filterable |
| | | clearable |
| | | :placeholder="VueFlowHelper.getParams(modelSetting, 'llm_model').placeholder" |
| | | /> |
| | | </el-form-item> |
| | | </div> |
| | | <div class="flex-column gap-y-1.5"> |
| | | <el-form-item |
| | | labelPosition="top" |
| | | :label="VueFlowHelper.getParams(modelSetting, 'temperature').label" |
| | | prop="group_params.0.params.1.value" |
| | | > |
| | | <el-input-number |
| | | class="w-full" |
| | | controls-position="right" |
| | | v-model="VueFlowHelper.getParams(modelSetting, 'temperature').value" |
| | | :readonly="isViewMode" |
| | | placeholder="" |
| | | ></el-input-number> |
| | | </el-form-item> |
| | | </div> |
| | | </div> |
| | | </FieldLayout> |
| | | <FieldLayout :title="prompt.name"> |
| | | <CodeEditor |
| | | :title="prompt.name" |
| | | class="nowheel" |
| | | v-model:editValue="VueFlowHelper.getParams(prompt, 'prompt').value" |
| | | :maxHeight="180" |
| | | :disabled="isViewMode" |
| | | /> |
| | | </FieldLayout> |
| | | <FieldLayout :title="outputParam.name" > |
| | | <el-form-item labelWidth="0" prop="group_params.2.params.0.value"> |
| | | <el-input |
| | | class="w-full flex-0" |
| | | v-model="outputParam.params[0].value" |
| | | placeholder="输出参数名" |
| | | :readonly="isViewMode" |
| | | ></el-input> |
| | | </el-form-item> |
| | | </FieldLayout> |
| | | </el-form> |
| | | |
| | | <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> |
| | | <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> |
| | | </FieldLayout> |
| | | <FieldLayout :title="prompt.name"> |
| | | <el-input |
| | | class="nowheel" |
| | | v-model="VueFlowHelper.getParams(prompt, 'prompt').value" |
| | | type="textarea" |
| | | :autosize="{ minRows: 3, maxRows: 6 }" |
| | | autocomplete="off" |
| | | > |
| | | </el-input> |
| | | </FieldLayout> |
| | | <Handle :id="sourceHandleId" type="source" :position="Position.Right" /> |
| | | </NodeBasicLayout> |
| | | </template> |
| | | |
| | | <script lang="ts" setup> |
| | | import { Handle, Position, useNode, useVueFlow } from '@vue-flow/core'; |
| | | import { ref } from 'vue'; |
| | | |
| | | <script setup lang="ts"> |
| | | import type { NodeProps } from '@vue-flow/core'; |
| | | import { VueFlowConstant } from '../../VueFlowConstant'; |
| | | import { Handle, Position, useNode } from '@vue-flow/core'; |
| | | import { ref } from 'vue'; |
| | | import { VueFlowHelper } from '../../VueFlowHelper'; |
| | | import type { LLMNodeData, LLMNodeEvents } from './index'; |
| | | import { deepClone } from '/@/utils/other'; |
| | | import { NodeType } from '../../vueFlowEnum'; |
| | | |
| | | import FieldLayout from './components/FieldLayout.vue'; |
| | | import NodeBasicLayout from './components/NodeBasicLayout.vue'; |
| | | import type { LLMNodeData, LLMNodeEvents } from './index'; |
| | | import CodeEditor from '/@/components/input/codeEditor/index.vue'; |
| | | |
| | | defineProps<NodeProps<LLMNodeData, LLMNodeEvents>>(); |
| | | defineProps< |
| | | NodeProps<LLMNodeData, LLMNodeEvents> & { |
| | | isViewMode?: boolean; |
| | | llmInfoList: any[]; |
| | | } |
| | | >(); |
| | | |
| | | 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); |
| | | console.log('🚀 ~ data.value:', data.value); |
| | | const modelSetting = ref(VueFlowHelper.getGroupParam(data.value, 0)); |
| | | const prompt = ref(VueFlowHelper.getGroupParam(data.value, 1)); |
| | | const outputParam = ref(VueFlowHelper.getGroupParam(data.value, 2)); |
| | | VueFlowHelper.getConfigValue(VueFlowHelper.getParams(prompt.value, 'prompt'), 'label', ''); |
| | | |
| | | const formRules = ref({ |
| | | 'group_params.0.params.0.value': [{ required: true, message: '请选择模型', trigger: 'change' }], |
| | | // 'group_params.0.params.1.value': [{ required: true, message: '请输入温度', trigger: 'blur' }], |
| | | // 'group_params.2.params.0.value': [{ required: true, message: '请输入输出参数名', trigger: 'blur' }], |
| | | }); |
| | | |
| | | const formRef = ref(); |
| | | const validateForm = async () => { |
| | | const valid = await formRef.value.validate(); |
| | | if (valid) { |
| | | console.log('submit!'); |
| | | } |
| | | }; |
| | | |
| | | defineExpose({ |
| | | validateForm, |
| | | }); |
| | | </script> |