Skip to content

refactor: enhance input handling for custom sources in form fields #2871

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 14, 2025
Merged
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
64 changes: 58 additions & 6 deletions ui/src/workflow/nodes/mcp-node/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,24 @@
</div>
</template>
<el-input
v-if="item.source === 'custom'"
v-if="item.source === 'custom' && item.input_type === 'TextInput'"
v-model="form_data.tool_params[form_data.params_nested][item.label.label]"
/>
<el-input-number
v-else-if="item.source === 'custom' && item.input_type === 'NumberInput'"
v-model="form_data.tool_params[form_data.params_nested][item.label.label]"
/>
<el-switch
v-else-if="item.source === 'custom' && item.input_type === 'SwitchInput'"
v-model="form_data.tool_params[form_data.params_nested][item.label.label]"
/>
<el-input
v-else-if="item.source === 'custom' && item.input_type === 'JsonInput'"
v-model="form_data.tool_params[form_data.params_nested][item.label.label]"
type="textarea"
/>
<NodeCascader
v-else
v-if="item.source === 'referencing'"
ref="nodeCascaderRef2"
:nodeModel="nodeModel"
class="w-full"
Expand Down Expand Up @@ -148,11 +161,24 @@
</div>
</template>
<el-input
v-if="item.source === 'custom'"
v-if="item.source === 'custom' && item.input_type === 'TextInput'"
v-model="form_data.tool_params[item.label.label]"
/>
<el-input-number
v-else-if="item.source === 'custom' && item.input_type === 'NumberInput'"
v-model="form_data.tool_params[item.label.label]"
/>
<el-switch
v-else-if="item.source === 'custom' && item.input_type === 'SwitchInput'"
v-model="form_data.tool_params[item.label.label]"
/>
<el-input
v-else-if="item.source === 'custom' && item.input_type === 'JsonInput'"
v-model="form_data.tool_params[item.label.label]"
type="textarea"
/>
<NodeCascader
v-else
v-if="item.source === 'referencing'"
ref="nodeCascaderRef2"
:nodeModel="nodeModel"
class="w-full"
Expand Down Expand Up @@ -244,6 +270,19 @@ function changeTool() {
if (params) {
form_data.value.params_nested = item
for (const item2 in params) {
let input_type = 'TextInput'
if (params[item2].type === 'string') {
input_type = 'TextInput'
} else if (params[item2].type === 'number') {
input_type = 'NumberInput'
} else if (params[item2].type === 'boolean') {
input_type = 'SwitchInput'
} else if (params[item2].type === 'array') {
input_type = 'JsonInput'
} else if (params[item2].type === 'object') {
input_type = 'JsonInput'
}
console.log(params[item2])
form_data.value.tool_form_field.push({
field: item2,
label: {
Expand All @@ -252,7 +291,7 @@ function changeTool() {
attrs: { tooltip: params[item2].description },
props_info: {}
},
input_type: 'TextInput',
input_type: input_type,
source: 'referencing',
required: args_schema.properties[item].required?.indexOf(item2) !== -1,
props_info: {
Expand All @@ -268,6 +307,19 @@ function changeTool() {
}
} else {
form_data.value.params_nested = ''
let input_type = 'TextInput'
if (args_schema.properties[item].type === 'string') {
input_type = 'TextInput'
} else if (args_schema.properties[item].type === 'number') {
input_type = 'NumberInput'
} else if (args_schema.properties[item].type === 'boolean') {
input_type = 'SwitchInput'
} else if (args_schema.properties[item].type === 'array') {
input_type = 'JsonInput'
} else if (args_schema.properties[item].type === 'object') {
input_type = 'JsonInput'
}
console.log(args_schema.properties[item]);
form_data.value.tool_form_field.push({
field: item,
label: {
Expand All @@ -276,7 +328,7 @@ function changeTool() {
attrs: { tooltip: args_schema.properties[item].description },
props_info: {}
},
input_type: 'TextInput',
input_type: input_type,
source: 'referencing',
required: args_schema.required?.indexOf(item) !== -1,
props_info: {
Expand Down