|
|
|
@ -7,17 +7,22 @@ import {
|
|
|
|
} from '@remixicon/react'
|
|
|
|
} from '@remixicon/react'
|
|
|
|
import Tooltip from '@/app/components/base/tooltip'
|
|
|
|
import Tooltip from '@/app/components/base/tooltip'
|
|
|
|
import Switch from '@/app/components/base/switch'
|
|
|
|
import Switch from '@/app/components/base/switch'
|
|
|
|
import Input from '@/app/components/workflow/nodes/_base/components/input-support-select-var'
|
|
|
|
import MixedInput from '@/app/components/workflow/nodes/_base/components/input-support-select-var'
|
|
|
|
|
|
|
|
import Input from '@/app/components/base/input'
|
|
|
|
|
|
|
|
import FormInputTypeSwitch from '@/app/components/workflow/nodes/_base/components/form-input-type-switch'
|
|
|
|
|
|
|
|
import FormInputBoolean from '@/app/components/workflow/nodes/_base/components/form-input-boolean'
|
|
|
|
|
|
|
|
import { SimpleSelect } from '@/app/components/base/select'
|
|
|
|
|
|
|
|
import CodeEditor from '@/app/components/workflow/nodes/_base/components/editor/code-editor'
|
|
|
|
import VarReferencePicker from '@/app/components/workflow/nodes/_base/components/variable/var-reference-picker'
|
|
|
|
import VarReferencePicker from '@/app/components/workflow/nodes/_base/components/variable/var-reference-picker'
|
|
|
|
import AppSelector from '@/app/components/plugins/plugin-detail-panel/app-selector'
|
|
|
|
import AppSelector from '@/app/components/plugins/plugin-detail-panel/app-selector'
|
|
|
|
import ModelParameterModal from '@/app/components/plugins/plugin-detail-panel/model-selector'
|
|
|
|
import ModelParameterModal from '@/app/components/plugins/plugin-detail-panel/model-selector'
|
|
|
|
|
|
|
|
import { CodeLanguage } from '@/app/components/workflow/nodes/code/types'
|
|
|
|
import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks'
|
|
|
|
import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks'
|
|
|
|
import { FormTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
|
|
|
|
import { FormTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
|
|
|
|
import type { Node } from 'reactflow'
|
|
|
|
import type { Node } from 'reactflow'
|
|
|
|
import type {
|
|
|
|
import type {
|
|
|
|
NodeOutPutVar,
|
|
|
|
NodeOutPutVar,
|
|
|
|
ValueSelector,
|
|
|
|
ValueSelector,
|
|
|
|
Var,
|
|
|
|
|
|
|
|
} from '@/app/components/workflow/types'
|
|
|
|
} from '@/app/components/workflow/types'
|
|
|
|
import type { ToolVarInputs } from '@/app/components/workflow/nodes/tool/types'
|
|
|
|
import type { ToolVarInputs } from '@/app/components/workflow/nodes/tool/types'
|
|
|
|
import { VarType as VarKindType } from '@/app/components/workflow/nodes/tool/types'
|
|
|
|
import { VarType as VarKindType } from '@/app/components/workflow/nodes/tool/types'
|
|
|
|
@ -46,14 +51,13 @@ const ReasoningConfigForm: React.FC<Props> = ({
|
|
|
|
}) => {
|
|
|
|
}) => {
|
|
|
|
const { t } = useTranslation()
|
|
|
|
const { t } = useTranslation()
|
|
|
|
const language = useLanguage()
|
|
|
|
const language = useLanguage()
|
|
|
|
const handleAutomatic = (key: string, val: any) => {
|
|
|
|
const getVarKindType = (type: FormTypeEnum) => {
|
|
|
|
onChange({
|
|
|
|
if (type === FormTypeEnum.file || type === FormTypeEnum.files)
|
|
|
|
...value,
|
|
|
|
return VarKindType.variable
|
|
|
|
[key]: {
|
|
|
|
if (type === FormTypeEnum.select || type === FormTypeEnum.boolean || type === FormTypeEnum.textNumber)
|
|
|
|
value: val ? null : value[key]?.value,
|
|
|
|
return VarKindType.constant
|
|
|
|
auto: val ? 1 : 0,
|
|
|
|
if (type === FormTypeEnum.textInput || type === FormTypeEnum.secretInput)
|
|
|
|
},
|
|
|
|
return VarKindType.mixed
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const [inputsIsFocus, setInputsIsFocus] = useState<Record<string, boolean>>({})
|
|
|
|
const [inputsIsFocus, setInputsIsFocus] = useState<Record<string, boolean>>({})
|
|
|
|
@ -67,52 +71,38 @@ const ReasoningConfigForm: React.FC<Props> = ({
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, [])
|
|
|
|
}, [])
|
|
|
|
const handleNotMixedTypeChange = useCallback((variable: string) => {
|
|
|
|
|
|
|
|
return (varValue: ValueSelector | string, varKindType: VarKindType) => {
|
|
|
|
const handleAutomatic = (key: string, val: any, type: FormTypeEnum) => {
|
|
|
|
const newValue = produce(value, (draft: ToolVarInputs) => {
|
|
|
|
onChange({
|
|
|
|
const target = draft[variable].value
|
|
|
|
...value,
|
|
|
|
if (target) {
|
|
|
|
[key]: {
|
|
|
|
target.type = varKindType
|
|
|
|
value: val ? null : { type: getVarKindType(type), value: null },
|
|
|
|
target.value = varValue
|
|
|
|
auto: val ? 1 : 0,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
else {
|
|
|
|
})
|
|
|
|
draft[variable].value = {
|
|
|
|
}
|
|
|
|
type: varKindType,
|
|
|
|
const handleTypeChange = useCallback((variable: string, defaultValue: any) => {
|
|
|
|
value: varValue,
|
|
|
|
return (newType: VarKindType) => {
|
|
|
|
}
|
|
|
|
const res = produce(value, (draft: ToolVarInputs) => {
|
|
|
|
}
|
|
|
|
draft[variable].value = {
|
|
|
|
})
|
|
|
|
type: newType,
|
|
|
|
onChange(newValue)
|
|
|
|
value: newType === VarKindType.variable ? '' : defaultValue,
|
|
|
|
}
|
|
|
|
|
|
|
|
}, [value, onChange])
|
|
|
|
|
|
|
|
const handleMixedTypeChange = useCallback((variable: string) => {
|
|
|
|
|
|
|
|
return (itemValue: string) => {
|
|
|
|
|
|
|
|
const newValue = produce(value, (draft: ToolVarInputs) => {
|
|
|
|
|
|
|
|
const target = draft[variable].value
|
|
|
|
|
|
|
|
if (target) {
|
|
|
|
|
|
|
|
target.value = itemValue
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
draft[variable].value = {
|
|
|
|
|
|
|
|
type: VarKindType.mixed,
|
|
|
|
|
|
|
|
value: itemValue,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
onChange(newValue)
|
|
|
|
onChange(res)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, [value, onChange])
|
|
|
|
}, [onChange, value])
|
|
|
|
const handleFileChange = useCallback((variable: string) => {
|
|
|
|
const handleValueChange = useCallback((variable: string, varType: FormTypeEnum) => {
|
|
|
|
return (varValue: ValueSelector | string) => {
|
|
|
|
return (newValue: any) => {
|
|
|
|
const newValue = produce(value, (draft: ToolVarInputs) => {
|
|
|
|
const res = produce(value, (draft: ToolVarInputs) => {
|
|
|
|
draft[variable].value = {
|
|
|
|
draft[variable].value = {
|
|
|
|
type: VarKindType.variable,
|
|
|
|
type: getVarKindType(varType),
|
|
|
|
value: varValue,
|
|
|
|
value: newValue,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
onChange(newValue)
|
|
|
|
onChange(res)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, [value, onChange])
|
|
|
|
}, [onChange, value])
|
|
|
|
const handleAppChange = useCallback((variable: string) => {
|
|
|
|
const handleAppChange = useCallback((variable: string) => {
|
|
|
|
return (app: {
|
|
|
|
return (app: {
|
|
|
|
app_id: string
|
|
|
|
app_id: string
|
|
|
|
@ -136,6 +126,17 @@ const ReasoningConfigForm: React.FC<Props> = ({
|
|
|
|
onChange(newValue)
|
|
|
|
onChange(newValue)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, [onChange, value])
|
|
|
|
}, [onChange, value])
|
|
|
|
|
|
|
|
const handleVariableSelectorChange = useCallback((variable: string) => {
|
|
|
|
|
|
|
|
return (newValue: ValueSelector | string) => {
|
|
|
|
|
|
|
|
const res = produce(value, (draft: ToolVarInputs) => {
|
|
|
|
|
|
|
|
draft[variable].value = {
|
|
|
|
|
|
|
|
type: VarKindType.variable,
|
|
|
|
|
|
|
|
value: newValue,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
onChange(res)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}, [onChange, value])
|
|
|
|
|
|
|
|
|
|
|
|
const [isShowSchema, {
|
|
|
|
const [isShowSchema, {
|
|
|
|
setTrue: showSchema,
|
|
|
|
setTrue: showSchema,
|
|
|
|
@ -147,6 +148,7 @@ const ReasoningConfigForm: React.FC<Props> = ({
|
|
|
|
|
|
|
|
|
|
|
|
const renderField = (schema: any, showSchema: (schema: SchemaRoot, rootName: string) => void) => {
|
|
|
|
const renderField = (schema: any, showSchema: (schema: SchemaRoot, rootName: string) => void) => {
|
|
|
|
const {
|
|
|
|
const {
|
|
|
|
|
|
|
|
default: defaultValue,
|
|
|
|
variable,
|
|
|
|
variable,
|
|
|
|
label,
|
|
|
|
label,
|
|
|
|
required,
|
|
|
|
required,
|
|
|
|
@ -155,6 +157,8 @@ const ReasoningConfigForm: React.FC<Props> = ({
|
|
|
|
scope,
|
|
|
|
scope,
|
|
|
|
url,
|
|
|
|
url,
|
|
|
|
input_schema,
|
|
|
|
input_schema,
|
|
|
|
|
|
|
|
placeholder,
|
|
|
|
|
|
|
|
options,
|
|
|
|
} = schema
|
|
|
|
} = schema
|
|
|
|
const auto = value[variable]?.auto
|
|
|
|
const auto = value[variable]?.auto
|
|
|
|
const tooltipContent = (tooltip && (
|
|
|
|
const tooltipContent = (tooltip && (
|
|
|
|
@ -166,28 +170,55 @@ const ReasoningConfigForm: React.FC<Props> = ({
|
|
|
|
asChild={false} />
|
|
|
|
asChild={false} />
|
|
|
|
))
|
|
|
|
))
|
|
|
|
const varInput = value[variable].value
|
|
|
|
const varInput = value[variable].value
|
|
|
|
|
|
|
|
const isString = type === FormTypeEnum.textInput || type === FormTypeEnum.secretInput
|
|
|
|
const isNumber = type === FormTypeEnum.textNumber
|
|
|
|
const isNumber = type === FormTypeEnum.textNumber
|
|
|
|
const isSelect = type === FormTypeEnum.select
|
|
|
|
|
|
|
|
const isFile = type === FormTypeEnum.file || type === FormTypeEnum.files
|
|
|
|
|
|
|
|
const isObject = type === FormTypeEnum.object
|
|
|
|
const isObject = type === FormTypeEnum.object
|
|
|
|
const isArray = type === FormTypeEnum.array
|
|
|
|
const isArray = type === FormTypeEnum.array
|
|
|
|
const isShowSchemaTooltip = isObject || isArray
|
|
|
|
const isShowJSONEditor = isObject || isArray
|
|
|
|
|
|
|
|
const isFile = type === FormTypeEnum.file || type === FormTypeEnum.files
|
|
|
|
|
|
|
|
const isBoolean = type === FormTypeEnum.boolean
|
|
|
|
|
|
|
|
const isSelect = type === FormTypeEnum.select
|
|
|
|
const isAppSelector = type === FormTypeEnum.appSelector
|
|
|
|
const isAppSelector = type === FormTypeEnum.appSelector
|
|
|
|
const isModelSelector = type === FormTypeEnum.modelSelector
|
|
|
|
const isModelSelector = type === FormTypeEnum.modelSelector
|
|
|
|
// const isToolSelector = type === FormTypeEnum.toolSelector
|
|
|
|
const showTypeSwitch = isNumber || isObject || isArray
|
|
|
|
const isString = !isNumber && !isSelect && !isFile && !isAppSelector && !isModelSelector && !isObject && !isArray
|
|
|
|
const isConstant = varInput?.type === VarKindType.constant || !varInput?.type
|
|
|
|
const valueType = (() => {
|
|
|
|
const showVariableSelector = isFile || varInput?.type === VarKindType.variable
|
|
|
|
if (isNumber) return VarType.number
|
|
|
|
const targetVarType = () => {
|
|
|
|
if (isSelect) return VarType.string
|
|
|
|
if (isString)
|
|
|
|
if (isFile) return VarType.file
|
|
|
|
return VarType.string
|
|
|
|
if (isObject) return VarType.object
|
|
|
|
else if (isNumber)
|
|
|
|
if (isArray) return VarType.array
|
|
|
|
return VarType.number
|
|
|
|
|
|
|
|
else if (type === FormTypeEnum.files)
|
|
|
|
return VarType.string
|
|
|
|
return VarType.arrayFile
|
|
|
|
})()
|
|
|
|
else if (type === FormTypeEnum.file)
|
|
|
|
|
|
|
|
return VarType.file
|
|
|
|
|
|
|
|
else if (isBoolean)
|
|
|
|
|
|
|
|
return VarType.boolean
|
|
|
|
|
|
|
|
else if (isObject)
|
|
|
|
|
|
|
|
return VarType.object
|
|
|
|
|
|
|
|
else if (isArray)
|
|
|
|
|
|
|
|
return VarType.arrayObject
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
return VarType.string
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
const getFilterVar = () => {
|
|
|
|
|
|
|
|
if (isNumber)
|
|
|
|
|
|
|
|
return (varPayload: any) => varPayload.type === VarType.number
|
|
|
|
|
|
|
|
else if (isString)
|
|
|
|
|
|
|
|
return (varPayload: any) => [VarType.string, VarType.number, VarType.secret].includes(varPayload.type)
|
|
|
|
|
|
|
|
else if (isFile)
|
|
|
|
|
|
|
|
return (varPayload: any) => [VarType.file, VarType.arrayFile].includes(varPayload.type)
|
|
|
|
|
|
|
|
else if (isBoolean)
|
|
|
|
|
|
|
|
return (varPayload: any) => varPayload.type === VarType.boolean
|
|
|
|
|
|
|
|
else if (isObject)
|
|
|
|
|
|
|
|
return (varPayload: any) => varPayload.type === VarType.object
|
|
|
|
|
|
|
|
else if (isArray)
|
|
|
|
|
|
|
|
return (varPayload: any) => [VarType.array, VarType.arrayString, VarType.arrayNumber, VarType.arrayObject].includes(varPayload.type)
|
|
|
|
|
|
|
|
return undefined
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div key={variable} className='space-y-1'>
|
|
|
|
<div key={variable} className='space-y-0.5'>
|
|
|
|
<div className='system-sm-semibold flex items-center justify-between py-2 text-text-secondary'>
|
|
|
|
<div className='system-sm-semibold flex items-center justify-between py-2 text-text-secondary'>
|
|
|
|
<div className='flex items-center'>
|
|
|
|
<div className='flex items-center'>
|
|
|
|
<span className={cn('code-sm-semibold max-w-[140px] truncate text-text-secondary')} title={label[language] || label.en_US}>{label[language] || label.en_US}</span>
|
|
|
|
<span className={cn('code-sm-semibold max-w-[140px] truncate text-text-secondary')} title={label[language] || label.en_US}>{label[language] || label.en_US}</span>
|
|
|
|
@ -196,8 +227,8 @@ const ReasoningConfigForm: React.FC<Props> = ({
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
{tooltipContent}
|
|
|
|
{tooltipContent}
|
|
|
|
<span className='system-xs-regular mx-1 text-text-quaternary'>·</span>
|
|
|
|
<span className='system-xs-regular mx-1 text-text-quaternary'>·</span>
|
|
|
|
<span className='system-xs-regular text-text-tertiary'>{valueType}</span>
|
|
|
|
<span className='system-xs-regular text-text-tertiary'>{targetVarType()}</span>
|
|
|
|
{isShowSchemaTooltip && (
|
|
|
|
{isShowJSONEditor && (
|
|
|
|
<Tooltip
|
|
|
|
<Tooltip
|
|
|
|
popupContent={<div className='system-xs-medium text-text-secondary'>
|
|
|
|
popupContent={<div className='system-xs-medium text-text-secondary'>
|
|
|
|
{t('workflow.nodes.agent.clickToViewParameterSchema')}
|
|
|
|
{t('workflow.nodes.agent.clickToViewParameterSchema')}
|
|
|
|
@ -213,22 +244,25 @@ const ReasoningConfigForm: React.FC<Props> = ({
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className='flex cursor-pointer items-center gap-1 rounded-[6px] border border-divider-subtle bg-background-default-lighter px-2 py-1 hover:bg-state-base-hover' onClick={() => handleAutomatic(variable, !auto)}>
|
|
|
|
<div className='flex cursor-pointer items-center gap-1 rounded-[6px] border border-divider-subtle bg-background-default-lighter px-2 py-1 hover:bg-state-base-hover' onClick={() => handleAutomatic(variable, !auto, type)}>
|
|
|
|
<span className='system-xs-medium text-text-secondary'>{t('plugin.detailPanel.toolSelector.auto')}</span>
|
|
|
|
<span className='system-xs-medium text-text-secondary'>{t('plugin.detailPanel.toolSelector.auto')}</span>
|
|
|
|
<Switch
|
|
|
|
<Switch
|
|
|
|
size='xs'
|
|
|
|
size='xs'
|
|
|
|
defaultValue={!!auto}
|
|
|
|
defaultValue={!!auto}
|
|
|
|
onChange={val => handleAutomatic(variable, val)}
|
|
|
|
onChange={val => handleAutomatic(variable, val, type)}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{auto === 0 && (
|
|
|
|
{auto === 0 && (
|
|
|
|
<>
|
|
|
|
<div className={cn('gap-1', !(isShowJSONEditor && isConstant) && 'flex')}>
|
|
|
|
|
|
|
|
{showTypeSwitch && (
|
|
|
|
|
|
|
|
<FormInputTypeSwitch value={varInput?.type || VarKindType.constant} onChange={handleTypeChange(variable, defaultValue)}/>
|
|
|
|
|
|
|
|
)}
|
|
|
|
{isString && (
|
|
|
|
{isString && (
|
|
|
|
<Input
|
|
|
|
<MixedInput
|
|
|
|
className={cn(inputsIsFocus[variable] ? 'border-gray-300 bg-gray-50 shadow-xs' : 'border-gray-100 bg-gray-100', 'rounded-lg border px-3 py-[6px]')}
|
|
|
|
className={cn(inputsIsFocus[variable] ? 'border-gray-300 bg-gray-50 shadow-xs' : 'border-gray-100 bg-gray-100', 'grow rounded-lg border px-3 py-[6px]')}
|
|
|
|
value={varInput?.value as string || ''}
|
|
|
|
value={varInput?.value as string || ''}
|
|
|
|
onChange={handleMixedTypeChange(variable)}
|
|
|
|
onChange={handleValueChange(variable, type)}
|
|
|
|
nodesOutputVars={nodeOutputVars}
|
|
|
|
nodesOutputVars={nodeOutputVars}
|
|
|
|
availableNodes={availableNodes}
|
|
|
|
availableNodes={availableNodes}
|
|
|
|
onFocusChange={handleInputFocus(variable)}
|
|
|
|
onFocusChange={handleInputFocus(variable)}
|
|
|
|
@ -236,53 +270,50 @@ const ReasoningConfigForm: React.FC<Props> = ({
|
|
|
|
placeholderClassName='!leading-[21px]'
|
|
|
|
placeholderClassName='!leading-[21px]'
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
{/* {isString && (
|
|
|
|
{isNumber && isConstant && (
|
|
|
|
<VarReferencePicker
|
|
|
|
<Input
|
|
|
|
zIndex={1001}
|
|
|
|
className='h-8 grow'
|
|
|
|
readonly={false}
|
|
|
|
type='number'
|
|
|
|
isShowNodeName
|
|
|
|
|
|
|
|
nodeId={nodeId}
|
|
|
|
|
|
|
|
value={varInput?.value || ''}
|
|
|
|
value={varInput?.value || ''}
|
|
|
|
onChange={handleNotMixedTypeChange(variable)}
|
|
|
|
onChange={handleValueChange(variable, type)}
|
|
|
|
defaultVarKindType={VarKindType.variable}
|
|
|
|
placeholder={placeholder?.[language] || placeholder?.en_US}
|
|
|
|
filterVar={(varPayload: Var) => varPayload.type === VarType.number || varPayload.type === VarType.secret || varPayload.type === VarType.string}
|
|
|
|
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
)} */}
|
|
|
|
)}
|
|
|
|
{(isNumber || isSelect) && (
|
|
|
|
{isBoolean && (
|
|
|
|
<VarReferencePicker
|
|
|
|
<FormInputBoolean
|
|
|
|
zIndex={1001}
|
|
|
|
value={varInput?.value as boolean}
|
|
|
|
readonly={false}
|
|
|
|
onChange={handleValueChange(variable, type)}
|
|
|
|
isShowNodeName
|
|
|
|
|
|
|
|
nodeId={nodeId}
|
|
|
|
|
|
|
|
value={varInput?.type === VarKindType.constant ? (varInput?.value ?? '') : (varInput?.value ?? [])}
|
|
|
|
|
|
|
|
onChange={handleNotMixedTypeChange(variable)}
|
|
|
|
|
|
|
|
defaultVarKindType={varInput?.type || (isNumber ? VarKindType.constant : VarKindType.variable)}
|
|
|
|
|
|
|
|
isSupportConstantValue
|
|
|
|
|
|
|
|
filterVar={isNumber ? (varPayload: Var) => varPayload.type === schema._type : undefined}
|
|
|
|
|
|
|
|
availableVars={isSelect ? nodeOutputVars : undefined}
|
|
|
|
|
|
|
|
schema={schema}
|
|
|
|
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
{(isFile || isObject || isArray) && (
|
|
|
|
{isSelect && (
|
|
|
|
<VarReferencePicker
|
|
|
|
<SimpleSelect
|
|
|
|
zIndex={1001}
|
|
|
|
wrapperClassName='h-8 grow'
|
|
|
|
readonly={false}
|
|
|
|
defaultValue={varInput?.value}
|
|
|
|
isShowNodeName
|
|
|
|
items={options.filter((option: { show_on: any[] }) => {
|
|
|
|
nodeId={nodeId}
|
|
|
|
if (option.show_on.length)
|
|
|
|
value={varInput?.value || []}
|
|
|
|
return option.show_on.every(showOnItem => value[showOnItem.variable] === showOnItem.value)
|
|
|
|
onChange={handleFileChange(variable)}
|
|
|
|
|
|
|
|
defaultVarKindType={VarKindType.variable}
|
|
|
|
|
|
|
|
filterVar={(varPayload: Var) => {
|
|
|
|
|
|
|
|
if(isFile)
|
|
|
|
|
|
|
|
return varPayload.type === VarType.file || varPayload.type === VarType.arrayFile
|
|
|
|
|
|
|
|
if(isObject)
|
|
|
|
|
|
|
|
return varPayload.type === VarType.object
|
|
|
|
|
|
|
|
if(isArray)
|
|
|
|
|
|
|
|
return [VarType.array, VarType.arrayNumber, VarType.arrayString, VarType.arrayObject, VarType.arrayFile].includes(varPayload.type)
|
|
|
|
|
|
|
|
return true
|
|
|
|
return true
|
|
|
|
}}
|
|
|
|
}).map((option: { value: any; label: { [x: string]: any; en_US: any } }) => ({ value: option.value, name: option.label[language] || option.label.en_US }))}
|
|
|
|
|
|
|
|
onSelect={item => handleValueChange(variable, type)(item.value as string)}
|
|
|
|
|
|
|
|
placeholder={placeholder?.[language] || placeholder?.en_US}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
|
|
|
|
{isShowJSONEditor && isConstant && (
|
|
|
|
|
|
|
|
<div className='mt-1 w-full'>
|
|
|
|
|
|
|
|
<CodeEditor
|
|
|
|
|
|
|
|
title='JSON'
|
|
|
|
|
|
|
|
value={varInput?.value as any}
|
|
|
|
|
|
|
|
isExpand
|
|
|
|
|
|
|
|
isInNode
|
|
|
|
|
|
|
|
height={100}
|
|
|
|
|
|
|
|
language={CodeLanguage.json}
|
|
|
|
|
|
|
|
onChange={handleValueChange(variable, type)}
|
|
|
|
|
|
|
|
className='w-full'
|
|
|
|
|
|
|
|
placeholder={<div className='whitespace-pre'>{placeholder?.[language] || placeholder?.en_US}</div>}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
)}
|
|
|
|
{isAppSelector && (
|
|
|
|
{isAppSelector && (
|
|
|
|
<AppSelector
|
|
|
|
<AppSelector
|
|
|
|
disabled={false}
|
|
|
|
disabled={false}
|
|
|
|
@ -301,7 +332,20 @@ const ReasoningConfigForm: React.FC<Props> = ({
|
|
|
|
scope={scope}
|
|
|
|
scope={scope}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
{showVariableSelector && (
|
|
|
|
|
|
|
|
<VarReferencePicker
|
|
|
|
|
|
|
|
className='h-8 grow'
|
|
|
|
|
|
|
|
readonly={false}
|
|
|
|
|
|
|
|
isShowNodeName
|
|
|
|
|
|
|
|
nodeId={nodeId}
|
|
|
|
|
|
|
|
value={varInput?.value || []}
|
|
|
|
|
|
|
|
onChange={handleVariableSelectorChange(variable)}
|
|
|
|
|
|
|
|
filterVar={getFilterVar()}
|
|
|
|
|
|
|
|
schema={schema}
|
|
|
|
|
|
|
|
valueTypePlaceHolder={targetVarType()}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
{url && (
|
|
|
|
{url && (
|
|
|
|
<a
|
|
|
|
<a
|
|
|
|
|