chore: change tool input types

This commit is contained in:
Joel 2024-03-14 11:25:18 +08:00
parent c051c89176
commit 68fa81ec82
8 changed files with 14 additions and 11 deletions

View File

@ -106,6 +106,7 @@ const Item = ({
provider_type: data.type,
provider_name: data.name,
tool_name: tool.name,
tool_label: tool.label[language],
title: tool.label[language],
})}
>

View File

@ -30,5 +30,6 @@ export type ToolDefaultValue = {
provider_type: string
provider_name: string
tool_name: string
tool_label: string
title: string
}

View File

@ -10,6 +10,7 @@ import useOneStepRun from '@/app/components/workflow/nodes/_base/hooks/use-one-s
const useConfig = (id: string, payload: HttpNodeType) => {
const { inputs, setInputs } = useNodeCrud<HttpNodeType>(id, payload)
// console.log(inputs)
const { handleVarListChange, handleAddVariable } = useVarList<HttpNodeType>({
inputs,
setInputs,

View File

@ -3,8 +3,8 @@ import type { ToolNodeType } from './types'
const nodeDefault: NodeDefault<ToolNodeType> = {
defaultValue: {
tool_inputs: [],
tool_parameters: {},
tool_parameters: [],
tool_configurations: {},
},
getAvailablePrevNodes() {
return []

View File

@ -8,7 +8,7 @@ import type { NodeProps } from '@/app/components/workflow/types'
const Node: FC<NodeProps<ToolNodeType>> = ({
data,
}) => {
const { tool_inputs } = data
const { tool_parameters: tool_inputs } = data
return (
<div className='px-3'>

View File

@ -47,7 +47,7 @@ const Panel: FC<NodePanelProps<ToolNodeType>> = ({
runResult,
} = useConfig(id, data)
// console.log(inputs)
console.log(inputs)
if (isLoading) {
return <div className='flex h-[200px] items-center justify-center'>
@ -80,7 +80,7 @@ const Panel: FC<NodePanelProps<ToolNodeType>> = ({
readOnly={readOnly}
nodeId={id}
schema={toolInputVarSchema as any}
value={inputs.tool_inputs}
value={inputs.tool_parameters}
onChange={setInputVar}
/>
</Field>

View File

@ -18,6 +18,6 @@ export type ToolNodeType = CommonNodeType & {
provider_name: string
tool_name: string
tool_label: string
tool_inputs: ToolVarInput[]
tool_parameters: Record<string, any>
tool_parameters: ToolVarInput[]
tool_configurations: Record<string, any>
}

View File

@ -23,8 +23,8 @@ const useConfig = (id: string, payload: ToolNodeType) => {
const setToolsMap = useStore(s => s.setToolsMap)
const { inputs, setInputs } = useNodeCrud<ToolNodeType>(id, payload)
const toolInputs = inputs.tool_inputs
const { provider_id, provider_name, provider_type, tool_name, tool_parameters } = inputs
const toolInputs = inputs.tool_parameters
const { provider_id, provider_name, provider_type, tool_name, tool_configurations: tool_parameters } = inputs
const isBuiltIn = provider_type === CollectionType.builtIn
const [currCollection, setCurrCollection] = useState<Collection | null | undefined>(null)
const fetchCurrCollection = useCallback(async () => {
@ -72,7 +72,7 @@ const useConfig = (id: string, payload: ToolNodeType) => {
const setToolSettingValue = useCallback((value: Record<string, any>) => {
setInputs({
...inputs,
tool_parameters: value,
tool_configurations: value,
})
}, [inputs, setInputs])
@ -81,7 +81,7 @@ const useConfig = (id: string, payload: ToolNodeType) => {
const setInputVar = useCallback((value: ToolVarInput[]) => {
setInputs({
...inputs,
tool_inputs: value,
tool_parameters: value,
})
}, [inputs, setInputs])