Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ onMounted(() => {
</el-button>
</div>

<div class="w-full rounded-md bg-N100 p-3">
<div class="w-full mk-gray-card">
<MkFormList v-model="formValue.option_list" :default-item="{ label: '', value: '' }" :show-add-button="false" @remove="handleOptionRemove">
<template #default="{ index, item: option }">
<el-form-item :label="index === 0 ? '标签' : ''" class="flex-1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ onMounted(() => {
</el-button>
</div>

<div class="w-full rounded-md bg-N100 p-3">
<div class="w-full mk-gray-card">
<MkFormList v-model="formValue.option_list" :default-item="{ label: '', value: '' }" :show-add-button="false" @remove="handleOptionRemove">
<template #default="{ index, item: option }">
<el-form-item :label="index === 0 ? '标签' : ''" class="flex-1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ onMounted(() => {
</el-button>
</div>

<div class="w-full rounded-md bg-N100 p-3">
<div class="w-full mk-gray-card">
<MkFormList v-model="formValue.option_list" :default-item="{ label: '', value: '' }" :show-add-button="false" @remove="handleOptionRemove">
<template #default="{ index, item: option }">
<el-form-item :label="index === 0 ? '标签' : ''" class="flex-1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ onMounted(() => {
</el-button>
</div>

<div class="w-full rounded-md bg-N100 p-3">
<div class="w-full mk-gray-card">
<MkFormList v-model="formValue.option_list" :default-item="{ label: '', value: '' }" :show-add-button="false" @remove="handleOptionRemove">
<template #default="{ index, item: option }">
<el-form-item :label="index === 0 ? '标签' : ''" class="flex-1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ onMounted(() => {
</el-button>
</div>

<div class="w-full rounded-md bg-N100 p-3">
<div class="w-full mk-gray-card">
<MkFormList v-model="formValue.option_list" :default-item="{ label: '', value: '' }" :show-add-button="false" @remove="handleOptionRemove">
<template #default="{ index, item: option }">
<el-form-item :label="index === 0 ? '标签' : ''" class="flex-1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ onMounted(() => {
</el-form-item>

<el-form-item label="账号登录验证码设置" required>
<div class="w-full rounded-md bg-N100 p-4">
<div class="w-full mk-gray-card p-4!">
<div class="flex items-center gap-2">
<span>登录失败</span>
<el-input-number v-model="form.max_attempts" :max="10" :min="-1" :step="1" :value-on-clear="-1" @change="form.max_attempts = normalizeNonZeroNumber($event)" />
Expand All @@ -177,7 +177,7 @@ onMounted(() => {
</div>
</el-form-item>
<p class="mb-2">第三方用户默认角色分配</p>
<div class="w-full rounded-md bg-N100 p-4">
<div class="w-full mk-gray-card p-4!">
<el-form-item label="角色" prop="role_id">
<el-select v-model="form.role_id" :loading="roleSettingOptionsLoading" filterable clearable placeholder="请选择角色" @change="handleRoleChange">
<el-option v-for="role in roleOptions" :key="role.id" :label="role.name" :value="role.id" />
Expand Down
8 changes: 4 additions & 4 deletions ui/src/workflow-canvas/config/node-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ export const startNode = {
{ label: '当前时间', value: 'time' },
{ label: '历史聊天记录', value: 'history_context' },
{ label: '对话 ID', value: 'aiChat_id' },
{ label: '对话用户 ID', value: 'chat_user_id' },
{ label: '对话用户类型', value: 'chat_user_type' },
{ label: '对话用户组', value: 'chat_user_group' },
{ label: '对话用户', value: 'chat_user' },
],
},
fields: [{ label: '用户问题', value: 'question' }],
globalFields: [{ label: '当前时间', value: 'time' }],
showNode: true,
},
}
Expand All @@ -41,8 +43,6 @@ export const baseNode = {
config: {},
showNode: true,
user_input_config: { title: '用户输入' },
api_input_field_list: [],
chat_input_field_list: [],
user_input_field_list: [],
},
}
Expand Down
19 changes: 10 additions & 9 deletions ui/src/workflow-canvas/core/node-container/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ const handleNodeMousedown = (event?: MouseEvent) => {
set(model, 'isHovered', !model.isSelected)
model.graphModel.toFront(model.id)
}
const showicon = ref<number | string | null>(null)
const resizeStepContainer = (nodeHeight: number) => {
if (nodeHeight > 0 && !model.virtual) {
model.setHeight(nodeHeight)
Expand Down Expand Up @@ -295,6 +294,8 @@ onBeforeUnmount(() => {
<el-collapse-transition>
<div v-show="showNode" class="mt-4" @pointermove.stop @pointerenter.stop @mousedown.stop @keydown.stop @click.stop>
<slot />

<!-- 输出参数 -->
<template v-if="nodeFields.length > 0">
<div class="flex-between">
<h6 class="mk-title-decoration my-2">{{ output_title }}</h6>
Expand All @@ -303,25 +304,25 @@ onBeforeUnmount(() => {
<el-switch v-model="enable_exception" size="small" />
</div>
</div>
<div class="mk-gray-card">
<div class="mk-gray-card space-y-4">
<template v-for="(item, index) in nodeFields" :key="index">
<div class="flex-between my-2" @mouseenter="showicon = index" @mouseleave="showicon = null">
<div class="group flex-between">
<span class="break-all">{{ item.label }} {{ '{' + item.value + '}' }}</span>
<el-tooltip effect="dark" content="复制参数" placement="top" v-if="showicon === index">
<el-button class="p-0!" link @click="copyText(item.globeLabel)">
<el-tooltip effect="dark" content="复制参数" placement="top">
<el-button class="group-hover-visible" link @click="copyText(item.globeLabel)">
<MkIcon name="icon_copy_outlined" />
</el-button>
</el-tooltip>
</div>
</template>
</div>

<div v-if="enable_exception" class="mk-gray-card">
<div v-if="enable_exception" class="mk-gray-card space-y-4">
<template v-for="(item, index) in abnormalNodeFields" :key="index">
<div class="flex-between my-2" @mouseenter="showicon = 'abnormal' + index" @mouseleave="showicon = null">
<div class="group flex-between">
<span class="break-all">{{ item.label }} {{ '{' + item.value + '}' }}</span>
<el-tooltip effect="dark" content="复制参数" placement="top" v-if="showicon === 'abnormal' + index">
<el-button class="p-0!" link @click="copyText(item.globeLabel)">
<el-tooltip effect="dark" content="复制参数" placement="top">
<el-button class="group-hover-visible" link @click="copyText(item.globeLabel)">
<MkIcon name="icon_copy_outlined" />
</el-button>
</el-tooltip>
Expand Down
17 changes: 12 additions & 5 deletions ui/src/workflow-canvas/nodes/ai-chat-node/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,16 @@ const formData = computed<AiChatNodeForm>({
})

function validate() {
return Promise.all([formData.value.model_id_type === 'reference' ? nodeCascaderRef.value?.validate() : Promise.resolve(), formRef.value?.validate()]).catch((error) =>
Promise.reject({ node: model, errMessage: error }),
)
return Promise.all([
formData.value.model_id_type === 'reference' ? nodeCascaderRef.value?.validate() : Promise.resolve(),
formRef.value?.validate(),
]).catch((error) => Promise.reject({ node: model, errMessage: error }))
}
const store = useWorkflowStore(apiType)
const modelList = ref<Array<ModelItem>>([])
const providerOptions = ref<Array<any>>([])
onMounted(() => {
set(model, 'validate', validate)
model.validate = validate
store.getModelList({ model_type: 'LLM' }).then((data) => {
modelList.value = data
})
Expand Down Expand Up @@ -86,7 +87,13 @@ onMounted(() => {
class="w-full"
placeholder="请选择变量"
/>
<ModelSelect v-else placeholder="请输入 AI 模型 ID" :options="modelList" :provider-options="providerOptions" v-model="formData.model_id"></ModelSelect>
<ModelSelect
v-else
placeholder="请输入 AI 模型 ID"
:options="modelList"
:provider-options="providerOptions"
v-model="formData.model_id"
></ModelSelect>
</el-form-item>

<el-form-item label="系统提示词">
Expand Down
1 change: 1 addition & 0 deletions ui/src/workflow-canvas/nodes/base-node/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ onMounted(() => {
</el-form-item>

<el-form-item label="开场白">
<!-- // TODO Markdown 编辑器 -->
<PrologueEditor v-model="formData.prologue" />
</el-form-item>

Expand Down
44 changes: 23 additions & 21 deletions ui/src/workflow-canvas/nodes/start-node/index.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<script setup lang="ts">
import { computed, inject, onBeforeUnmount, onMounted } from 'vue'

import { CopyDocument } from '@element-plus/icons-vue'
import { cloneDeep, set } from 'lodash'
import { cloneDeep } from 'lodash'
import NodeContainer from '@/workflow-canvas/core/node-container/index.vue'
import { WorkflowNodeType, type WorkflowNodeField } from '@/workflow-canvas/types'
import { copyText } from '@/utils/clipboard'
Expand Down Expand Up @@ -47,8 +45,8 @@ function refreshFields() {
value: field.field,
}))

set(nodeConfig, 'fields', [{ label: '用户问题', value: 'question' }])
set(nodeConfig, 'globalFields', [
nodeConfig.fields = [{ label: '用户问题', value: 'question' }]
nodeConfig.globalFields = [
{ label: '当前时间', value: 'time' },
{ label: '历史聊天记录', value: 'history_context' },
{ label: '对话 ID', value: 'chat_id' },
Expand All @@ -58,8 +56,8 @@ function refreshFields() {
{ label: '对话用户', value: 'chat_user' },
...userFields,
...apiFields,
])
set(nodeConfig, 'chatFields', chatInputFields)
]
nodeConfig.chatFields = chatInputFields
}

onMounted(() => {
Expand All @@ -77,24 +75,28 @@ onBeforeUnmount(() => {
<template>
<NodeContainer :node-model="model">
<h6 class="mk-title-decoration mb-2">全局变量</h6>
<div class="rounded-md bg-N100 px-3 py-1 text-N600">
<div v-for="field in globalFields" :key="field.value" class="flex items-center justify-between gap-2 py-2">
<span>{{ field.label }} {{ formatFieldReference(field.value) }}</span>
<el-button link @click="copyField('global', field.value)">
<MkIcon :icon="CopyDocument" />
</el-button>
</div>
<div class="mk-gray-card space-y-4">
<template v-for="field in globalFields" :key="field.value">
<div class="group flex-between">
<span class="break-all">{{ field.label }} {{ formatFieldReference(field.value) }}</span>
<el-button class="group-hover-visible" link @click="copyField('global', field.value)">
<MkIcon name="icon_copy_outlined" />
</el-button>
</div>
</template>
</div>

<template v-if="chatFields.length">
<h6 class="mk-title-decoration my-2">会话变量</h6>
<div class="rounded-md bg-N100 px-3 py-1 text-N600">
<div v-for="field in chatFields" :key="field.value" class="flex items-center justify-between gap-2 py-2">
<span>{{ field.label }} {{ formatFieldReference(field.value) }}</span>
<el-button link @click="copyField('chat', field.value)">
<MkIcon :icon="CopyDocument" />
</el-button>
</div>
<div class="mk-gray-card space-y-4">
<template v-for="field in chatFields" :key="field.value">
<div class="group flex-between">
<span class="break-all">{{ field.label }} {{ formatFieldReference(field.value) }}</span>
<el-button class="group-hover-visible" link @click="copyField('chat', field.value)">
<MkIcon name="icon_copy_outlined" />
</el-button>
</div>
</template>
</div>
</template>
</NodeContainer>
Expand Down
Loading