mirror of https://github.com/langgenius/dify.git
fix: tool show
This commit is contained in:
parent
8bd74d5abf
commit
cd9a58231b
|
|
@ -1,32 +1,23 @@
|
|||
import type { FC } from 'react'
|
||||
import React from 'react'
|
||||
import type { ToolNodeType } from './types'
|
||||
import { VarType } from './types'
|
||||
import { Variable02 } from '@/app/components/base/icons/src/vender/solid/development'
|
||||
import type { NodeProps } from '@/app/components/workflow/types'
|
||||
|
||||
const Node: FC<NodeProps<ToolNodeType>> = ({
|
||||
data,
|
||||
}) => {
|
||||
const { tool_parameters: tool_inputs } = data
|
||||
const { tool_configurations } = data
|
||||
|
||||
return (
|
||||
<div className='px-3'>
|
||||
<div className='space-y-0.5'>
|
||||
{tool_inputs.map((input, index) => (
|
||||
{Object.keys(tool_configurations || {}).map((key, index) => (
|
||||
<div key={index} className='flex items-center h-6 justify-between bg-gray-100 rounded-md px-1 space-x-1 text-xs font-normal text-gray-700'>
|
||||
<div className='text-xs font-medium text-gray-500 uppercase'>
|
||||
{input.variable}
|
||||
{key}
|
||||
</div>
|
||||
<div className='text-xs font-normal text-gray-700'>
|
||||
{input.variable_type === VarType.selector
|
||||
? (
|
||||
<div className='flex items-center text-primary-600 space-x-0.5'>
|
||||
<Variable02 className='h-3.5 w-3.5' />
|
||||
<div className='font-medium'>{input.value_selector?.slice(0, -1)[0]}</div>
|
||||
</div>
|
||||
)
|
||||
: input.value}
|
||||
{tool_configurations[key]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -47,8 +47,6 @@ const Panel: FC<NodePanelProps<ToolNodeType>> = ({
|
|||
runResult,
|
||||
} = useConfig(id, data)
|
||||
|
||||
console.log(inputs)
|
||||
|
||||
if (isLoading) {
|
||||
return <div className='flex h-[200px] items-center justify-center'>
|
||||
<Loading />
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { useTranslation } from 'react-i18next'
|
|||
import produce from 'immer'
|
||||
import { useBoolean } from 'ahooks'
|
||||
import { useStore } from '../../store'
|
||||
import { type ToolNodeType, type ToolVarInput } from './types'
|
||||
import { type ToolNodeType, type ToolVarInput, VarType } from './types'
|
||||
import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks'
|
||||
import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-crud'
|
||||
import { CollectionType } from '@/app/components/tools/types'
|
||||
|
|
@ -67,6 +67,7 @@ const useConfig = (id: string, payload: ToolNodeType) => {
|
|||
|
||||
const [currTool, setCurrTool] = useState<Tool | null>(null)
|
||||
const formSchemas = currTool ? toolParametersToFormSchemas(currTool.parameters) : []
|
||||
const toolInputVarSchema = formSchemas.filter((item: any) => item.form === 'llm')
|
||||
// use setting
|
||||
const toolSettingSchema = formSchemas.filter((item: any) => item.form !== 'llm')
|
||||
const toolSettingValue = (() => {
|
||||
|
|
@ -82,11 +83,20 @@ const useConfig = (id: string, payload: ToolNodeType) => {
|
|||
useEffect(() => {
|
||||
if (!currTool)
|
||||
return
|
||||
setToolSettingValue(addDefaultValue(tool_configurations, toolSettingSchema))
|
||||
const inputsWithDefaultValue = produce(inputs, (draft) => {
|
||||
draft.tool_configurations = addDefaultValue(tool_configurations, toolSettingSchema)
|
||||
draft.tool_parameters = toolInputVarSchema.map((item: any) => {
|
||||
return {
|
||||
variable: item.variable,
|
||||
variable_type: VarType.static,
|
||||
value: '',
|
||||
}
|
||||
})
|
||||
})
|
||||
setInputs(inputsWithDefaultValue)
|
||||
}, [currTool])
|
||||
|
||||
// setting when call
|
||||
const toolInputVarSchema = formSchemas.filter((item: any) => item.form === 'llm')
|
||||
const setInputVar = useCallback((value: ToolVarInput[]) => {
|
||||
setInputs({
|
||||
...inputs,
|
||||
|
|
|
|||
Loading…
Reference in New Issue