diff --git a/web/app/components/header/account-setting/model-provider-page/model-modal/Form.tsx b/web/app/components/header/account-setting/model-provider-page/model-modal/Form.tsx index d3b61a8d0f..baf6b194ce 100644 --- a/web/app/components/header/account-setting/model-provider-page/model-modal/Form.tsx +++ b/web/app/components/header/account-setting/model-provider-page/model-modal/Form.tsx @@ -22,6 +22,10 @@ import ToolSelector from '@/app/components/plugins/plugin-detail-panel/tool-sele import MultipleToolSelector from '@/app/components/plugins/plugin-detail-panel/multiple-tool-selector' import AppSelector from '@/app/components/plugins/plugin-detail-panel/app-selector' import RadioE from '@/app/components/base/radio/ui' +import type { + NodeOutPutVar, +} from '@/app/components/workflow/types' +import type { Node } from 'reactflow' type FormProps< CustomFormSchema extends Omit & { type: string } = never, @@ -47,6 +51,9 @@ type FormProps< ) => ReactNode // If return falsy value, this field will fallback to default render override?: [Array, (formSchema: CredentialFormSchema, props: Omit, 'override' | 'customRenderField'>) => ReactNode] + nodeId?: string + nodeOutputVars?: NodeOutPutVar[], + availableNodes?: Node[], } function Form< @@ -69,6 +76,9 @@ function Form< fieldMoreInfo, customRenderField, override, + nodeId, + nodeOutputVars, + availableNodes, }: FormProps) { const language = useLanguage() const [changeKey, setChangeKey] = useState('') @@ -326,8 +336,9 @@ function Form< = ({ onChange, schemas, nodeOutputVars, - availableNodes, + // availableNodes, nodeId, }) => { const { t } = useTranslation() @@ -51,52 +51,52 @@ const ReasoningConfigForm: React.FC = ({ }) } - const [inputsIsFocus, setInputsIsFocus] = useState>({}) - const handleInputFocus = useCallback((variable: string) => { - return (value: boolean) => { - setInputsIsFocus((prev) => { - return { - ...prev, - [variable]: value, - } - }) - } - }, []) - const handleNotMixedTypeChange = useCallback((variable: string) => { + // const [inputsIsFocus, setInputsIsFocus] = useState>({}) + // const handleInputFocus = useCallback((variable: string) => { + // return (value: boolean) => { + // setInputsIsFocus((prev) => { + // return { + // ...prev, + // [variable]: value, + // } + // }) + // } + // }, []) + const handleNotMixedTypeChange = useCallback((variable: string, toString = false) => { return (varValue: ValueSelector | string, varKindType: VarKindType) => { const newValue = produce(value, (draft: ToolVarInputs) => { const target = draft[variable].value if (target) { target.type = varKindType - target.value = varValue + target.value = toString ? `${varValue}` : varValue } else { draft[variable].value = { type: varKindType, - value: varValue, - } - } - }) - onChange(newValue) - } - }, [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, + value: toString ? `${varValue}` : varValue, } } }) onChange(newValue) } }, [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) + // } + // }, [value, onChange]) const handleFileChange = useCallback((variable: string) => { return (varValue: ValueSelector | string) => { const newValue = produce(value, (draft: ToolVarInputs) => { @@ -192,8 +192,21 @@ const ReasoningConfigForm: React.FC = ({ placeholderClassName='!leading-[21px]' /> )} */} + {isString && ( + varPayload.type === VarType.number || varPayload.type === VarType.secret || varPayload.type === VarType.string} + /> + )} {(isNumber || isSelect) && ( = ({ )} {isFile && ( { > onChange(item)} @@ -175,9 +175,9 @@ export const AgentStrategy = memo((props: AgentStrategyProps) => { return ( { fieldLabelClassName='uppercase' customRenderField={renderField} override={override} + nodeId={nodeId} + nodeOutputVars={nodeOutputVars || []} + availableNodes={availableNodes || []} /> : = ({ @@ -90,6 +91,7 @@ const VarReferencePicker: FC = ({ placeholder, minWidth, popupFor, + zIndex, }) => { const { t } = useTranslation() const store = useStoreApi() @@ -386,7 +388,7 @@ const VarReferencePicker: FC = ({ {!isConstant && (