mirror of
https://github.com/langgenius/dify.git
synced 2026-04-28 20:17:29 +08:00
chore: change tool input types
This commit is contained in:
parent
c051c89176
commit
68fa81ec82
@ -106,6 +106,7 @@ const Item = ({
|
|||||||
provider_type: data.type,
|
provider_type: data.type,
|
||||||
provider_name: data.name,
|
provider_name: data.name,
|
||||||
tool_name: tool.name,
|
tool_name: tool.name,
|
||||||
|
tool_label: tool.label[language],
|
||||||
title: tool.label[language],
|
title: tool.label[language],
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
|
|||||||
@ -30,5 +30,6 @@ export type ToolDefaultValue = {
|
|||||||
provider_type: string
|
provider_type: string
|
||||||
provider_name: string
|
provider_name: string
|
||||||
tool_name: string
|
tool_name: string
|
||||||
|
tool_label: string
|
||||||
title: string
|
title: string
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import useOneStepRun from '@/app/components/workflow/nodes/_base/hooks/use-one-s
|
|||||||
const useConfig = (id: string, payload: HttpNodeType) => {
|
const useConfig = (id: string, payload: HttpNodeType) => {
|
||||||
const { inputs, setInputs } = useNodeCrud<HttpNodeType>(id, payload)
|
const { inputs, setInputs } = useNodeCrud<HttpNodeType>(id, payload)
|
||||||
|
|
||||||
|
// console.log(inputs)
|
||||||
const { handleVarListChange, handleAddVariable } = useVarList<HttpNodeType>({
|
const { handleVarListChange, handleAddVariable } = useVarList<HttpNodeType>({
|
||||||
inputs,
|
inputs,
|
||||||
setInputs,
|
setInputs,
|
||||||
|
|||||||
@ -3,8 +3,8 @@ import type { ToolNodeType } from './types'
|
|||||||
|
|
||||||
const nodeDefault: NodeDefault<ToolNodeType> = {
|
const nodeDefault: NodeDefault<ToolNodeType> = {
|
||||||
defaultValue: {
|
defaultValue: {
|
||||||
tool_inputs: [],
|
tool_parameters: [],
|
||||||
tool_parameters: {},
|
tool_configurations: {},
|
||||||
},
|
},
|
||||||
getAvailablePrevNodes() {
|
getAvailablePrevNodes() {
|
||||||
return []
|
return []
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import type { NodeProps } from '@/app/components/workflow/types'
|
|||||||
const Node: FC<NodeProps<ToolNodeType>> = ({
|
const Node: FC<NodeProps<ToolNodeType>> = ({
|
||||||
data,
|
data,
|
||||||
}) => {
|
}) => {
|
||||||
const { tool_inputs } = data
|
const { tool_parameters: tool_inputs } = data
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='px-3'>
|
<div className='px-3'>
|
||||||
|
|||||||
@ -47,7 +47,7 @@ const Panel: FC<NodePanelProps<ToolNodeType>> = ({
|
|||||||
runResult,
|
runResult,
|
||||||
} = useConfig(id, data)
|
} = useConfig(id, data)
|
||||||
|
|
||||||
// console.log(inputs)
|
console.log(inputs)
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return <div className='flex h-[200px] items-center justify-center'>
|
return <div className='flex h-[200px] items-center justify-center'>
|
||||||
@ -80,7 +80,7 @@ const Panel: FC<NodePanelProps<ToolNodeType>> = ({
|
|||||||
readOnly={readOnly}
|
readOnly={readOnly}
|
||||||
nodeId={id}
|
nodeId={id}
|
||||||
schema={toolInputVarSchema as any}
|
schema={toolInputVarSchema as any}
|
||||||
value={inputs.tool_inputs}
|
value={inputs.tool_parameters}
|
||||||
onChange={setInputVar}
|
onChange={setInputVar}
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|||||||
@ -18,6 +18,6 @@ export type ToolNodeType = CommonNodeType & {
|
|||||||
provider_name: string
|
provider_name: string
|
||||||
tool_name: string
|
tool_name: string
|
||||||
tool_label: string
|
tool_label: string
|
||||||
tool_inputs: ToolVarInput[]
|
tool_parameters: ToolVarInput[]
|
||||||
tool_parameters: Record<string, any>
|
tool_configurations: Record<string, any>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,8 +23,8 @@ const useConfig = (id: string, payload: ToolNodeType) => {
|
|||||||
const setToolsMap = useStore(s => s.setToolsMap)
|
const setToolsMap = useStore(s => s.setToolsMap)
|
||||||
|
|
||||||
const { inputs, setInputs } = useNodeCrud<ToolNodeType>(id, payload)
|
const { inputs, setInputs } = useNodeCrud<ToolNodeType>(id, payload)
|
||||||
const toolInputs = inputs.tool_inputs
|
const toolInputs = inputs.tool_parameters
|
||||||
const { provider_id, provider_name, provider_type, tool_name, tool_parameters } = inputs
|
const { provider_id, provider_name, provider_type, tool_name, tool_configurations: tool_parameters } = inputs
|
||||||
const isBuiltIn = provider_type === CollectionType.builtIn
|
const isBuiltIn = provider_type === CollectionType.builtIn
|
||||||
const [currCollection, setCurrCollection] = useState<Collection | null | undefined>(null)
|
const [currCollection, setCurrCollection] = useState<Collection | null | undefined>(null)
|
||||||
const fetchCurrCollection = useCallback(async () => {
|
const fetchCurrCollection = useCallback(async () => {
|
||||||
@ -72,7 +72,7 @@ const useConfig = (id: string, payload: ToolNodeType) => {
|
|||||||
const setToolSettingValue = useCallback((value: Record<string, any>) => {
|
const setToolSettingValue = useCallback((value: Record<string, any>) => {
|
||||||
setInputs({
|
setInputs({
|
||||||
...inputs,
|
...inputs,
|
||||||
tool_parameters: value,
|
tool_configurations: value,
|
||||||
})
|
})
|
||||||
}, [inputs, setInputs])
|
}, [inputs, setInputs])
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ const useConfig = (id: string, payload: ToolNodeType) => {
|
|||||||
const setInputVar = useCallback((value: ToolVarInput[]) => {
|
const setInputVar = useCallback((value: ToolVarInput[]) => {
|
||||||
setInputs({
|
setInputs({
|
||||||
...inputs,
|
...inputs,
|
||||||
tool_inputs: value,
|
tool_parameters: value,
|
||||||
})
|
})
|
||||||
}, [inputs, setInputs])
|
}, [inputs, setInputs])
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user