diff --git a/web/app/components/base/prompt-editor/plugins/hitl-input-block/pre-populate.tsx b/web/app/components/base/prompt-editor/plugins/hitl-input-block/pre-populate.tsx index e64e70512d..070a836548 100644 --- a/web/app/components/base/prompt-editor/plugins/hitl-input-block/pre-populate.tsx +++ b/web/app/components/base/prompt-editor/plugins/hitl-input-block/pre-populate.tsx @@ -1,10 +1,11 @@ 'use client' import type { FC } from 'react' -import type { ValueSelector } from '@/app/components/workflow/types' +import type { ValueSelector, Var } from '@/app/components/workflow/types' import * as React from 'react' import { useCallback, useState } from 'react' import { Trans, useTranslation } from 'react-i18next' import VarReferencePicker from '@/app/components/workflow/nodes/_base/components/variable/var-reference-picker' +import { VarType } from '@/app/components/workflow/types' import { cn } from '@/utils/classnames' import Textarea from '../../../textarea' import TagLabel from './tag-label' @@ -76,6 +77,9 @@ const PrePopulate: FC = ({ onChange: onValueSelectorChange!, readonly: false, zIndex: 1000000, // bigger than shortcut plugin popup + filterVar: (varPayload: Var) => { + return [VarType.string, VarType.number, VarType.secret].includes(varPayload.type) + }, } const isShowPlaceholder = !onPlaceholderClicked && (isVariable ? (!valueSelector || valueSelector.length === 0) : !value) diff --git a/web/app/components/workflow/nodes/human-input/components/form-content.tsx b/web/app/components/workflow/nodes/human-input/components/form-content.tsx index b4ae6f82db..df16260715 100644 --- a/web/app/components/workflow/nodes/human-input/components/form-content.tsx +++ b/web/app/components/workflow/nodes/human-input/components/form-content.tsx @@ -2,6 +2,7 @@ import type { LexicalCommand } from 'lexical' import type { FC } from 'react' import type { FormInputItem } from '../types' +import type { Node, NodeOutPutVar } from '@/app/components/workflow/types' import { useBoolean } from 'ahooks' import * as React from 'react' import { useEffect, useState } from 'react' @@ -12,7 +13,6 @@ import { cn } from '@/utils/classnames' import { useWorkflowVariableType } from '../../../hooks' import { BlockEnum } from '../../../types' import { isMac } from '../../../utils' -import useAvailableVarList from '../../_base/hooks/use-available-var-list' import AddInputField from './add-input-field' type FormContentProps = { @@ -25,6 +25,8 @@ type FormContentProps = { onFormInputItemRemove: (varName: string) => void editorKey: number isExpand: boolean + availableVars: NodeOutPutVar[] + availableNodes: Node[] } const Key: FC<{ children: React.ReactNode, className?: string }> = ({ children, className }) => { @@ -45,16 +47,10 @@ const FormContent: FC = ({ onFormInputItemRemove, editorKey, isExpand, + availableVars, + availableNodes, }) => { const { t } = useTranslation() - const filterVar = () => true - const { - availableVars, - availableNodesWithParent: availableNodes, - } = useAvailableVarList(nodeId, { - onlyLeafNodeVar: false, - filterVar, - }) const getVarType = useWorkflowVariableType() diff --git a/web/app/components/workflow/nodes/human-input/panel.tsx b/web/app/components/workflow/nodes/human-input/panel.tsx index 382c27493d..1164f0de41 100644 --- a/web/app/components/workflow/nodes/human-input/panel.tsx +++ b/web/app/components/workflow/nodes/human-input/panel.tsx @@ -17,6 +17,8 @@ import Button from '@/app/components/base/button' import Divider from '@/app/components/base/divider' import Toast from '@/app/components/base/toast' import Tooltip from '@/app/components/base/tooltip' +import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/components/output-vars' +import Split from '@/app/components/workflow/nodes/_base/components/split' import useAvailableVarList from '@/app/components/workflow/nodes/_base/hooks/use-available-var-list' import { useStore } from '@/app/components/workflow/store' import { VarType } from '@/app/components/workflow/types' @@ -49,6 +51,8 @@ const Panel: FC> = ({ handleFormInputItemRename, handleFormInputItemRemove, editorKey, + structuredOutputCollapsed, + setStructuredOutputCollapsed, } = useConfig(id, data) const { availableVars, availableNodesWithParent } = useAvailableVarList(id, { @@ -122,6 +126,8 @@ const Panel: FC> = ({ onFormInputItemRename={handleFormInputItemRename} onFormInputItemRemove={handleFormInputItemRemove} isExpand={isExpandFormContent} + availableVars={availableVars} + availableNodes={availableNodesWithParent} /> {/* user actions */} @@ -154,7 +160,7 @@ const Panel: FC> = ({
{inputs.user_actions.map((action, index) => ( handleUserActionChange(index, data)} onDelete={handleUserActionDelete} @@ -175,6 +181,23 @@ const Panel: FC> = ({ onChange={handleTimeoutChange} />
+ {/* output vars */} + + + { + inputs.inputs.map(input => ( + + )) + } + {isPreview && ( { const { nodesReadOnly: readOnly } = useNodesReadOnly() const { inputs, setInputs } = useNodeCrud(id, payload) const formContentHook = useFormContent(id, payload) + const [structuredOutputCollapsed, setStructuredOutputCollapsed] = useState(true) const handleDeliveryMethodChange = (methods: DeliveryMethod[]) => { setInputs({ @@ -60,6 +62,8 @@ const useConfig = (id: string, payload: HumanInputNodeType) => { handleUserActionChange, handleUserActionDelete, handleTimeoutChange, + structuredOutputCollapsed, + setStructuredOutputCollapsed, ...formContentHook, } } diff --git a/web/app/components/workflow/nodes/llm/panel.tsx b/web/app/components/workflow/nodes/llm/panel.tsx index fd20b1a2bb..2032dfc705 100644 --- a/web/app/components/workflow/nodes/llm/panel.tsx +++ b/web/app/components/workflow/nodes/llm/panel.tsx @@ -94,7 +94,8 @@ const Panel: FC> = ({ handleModelChanged(model) } })() - }, [inputs.model.completion_params]) + }, [handleCompletionParamsChange, handleModelChanged, inputs.model.completion_params, t]) + return (