fix(web): tool config

This commit is contained in:
zhaoying
2026-04-22 13:02:42 +08:00
parent 9159d5cbb0
commit a90757745d

View File

@@ -1,4 +1,4 @@
import { type FC, useEffect, useState, useMemo } from "react";
import { type FC, useEffect, useState } from "react";
import { useTranslation } from 'react-i18next'
import { Form, Select, Switch, Cascader, type CascaderProps, Tooltip } from 'antd'
import type { Suggestion } from '../../Editor/plugin/AutocompletePlugin'
@@ -155,18 +155,18 @@ const ToolConfig: FC<{ options: Suggestion[]; }> = ({
const targetOption = selectedOptions[selectedOptions.length - 1];
const curParameters = [...(targetOption.parameters ?? [])]
setParameters([...curParameters])
const inititalValue: any = { tool_id: selectedOptions[1].value, tool_parameters: {} }
const initialValue: any = { tool_id: selectedOptions[1].value, tool_parameters: { operation: undefined } }
if (value[0] === 'mcp' || (value[0] === 'builtin' && selectedOptions[1]?.children && selectedOptions[1].children.length > 1)) {
inititalValue.tool_parameters.operation = value?.[2]
initialValue.tool_parameters.operation = value?.[2]
} else if (value[0] === 'custom') {
inititalValue.tool_parameters.operation = selectedOptions?.[2].method_id
initialValue.tool_parameters.operation = selectedOptions?.[2].method_id
}
curParameters.forEach(vo => {
inititalValue.tool_parameters[vo.name] = vo.default
initialValue.tool_parameters[vo.name] = vo.default
})
form.setFieldsValue(inititalValue)
form.setFieldsValue(initialValue)
}
// string -> string
@@ -244,8 +244,8 @@ const ToolConfig: FC<{ options: Suggestion[]; }> = ({
{parameter.type === 'string' && parameter.enum && parameter.enum.length > 0
? <Select size="small" options={parameter.enum.map(vo => ({ value: vo, label: vo }))} placeholder={t('common.pleaseSelect')} />
: parameter.type === 'boolean'
? <Switch size="small" />
: <Editor
? <Switch size="small" />
: <Editor
variant="outlined"
type="input"
size="small"