diff --git a/web/app/components/workflow/hooks/use-workflow-variables.ts b/web/app/components/workflow/hooks/use-workflow-variables.ts index 292edfd9ef..fb6c466e03 100644 --- a/web/app/components/workflow/hooks/use-workflow-variables.ts +++ b/web/app/components/workflow/hooks/use-workflow-variables.ts @@ -94,7 +94,7 @@ export const useWorkflowVariableType = () => { }) => { // debugger const node = getNodes().find(n => n.id === nodeId) - console.log(nodeId, valueSelector) + // console.log(nodeId, valueSelector) const isInIteration = !!node?.data.isInIteration const iterationNode = isInIteration ? getNodes().find(n => n.id === node.parentId) : null const availableNodes = getBeforeNodesInSameBranch(nodeId) diff --git a/web/app/components/workflow/nodes/_base/components/collapse/field-collapse.tsx b/web/app/components/workflow/nodes/_base/components/collapse/field-collapse.tsx index 71ca0d28ea..cf1526d5c9 100644 --- a/web/app/components/workflow/nodes/_base/components/collapse/field-collapse.tsx +++ b/web/app/components/workflow/nodes/_base/components/collapse/field-collapse.tsx @@ -4,10 +4,12 @@ import Collapse from '.' type FieldCollapseProps = { title: string children: ReactNode + operations?: ReactNode } const FieldCollapse = ({ title, children, + operations, }: FieldCollapseProps) => { return (
@@ -15,6 +17,7 @@ const FieldCollapse = ({ trigger={
{title}
} + operations={operations} >
{children} diff --git a/web/app/components/workflow/nodes/_base/components/collapse/index.tsx b/web/app/components/workflow/nodes/_base/components/collapse/index.tsx index a798ff0a9e..943fd80024 100644 --- a/web/app/components/workflow/nodes/_base/components/collapse/index.tsx +++ b/web/app/components/workflow/nodes/_base/components/collapse/index.tsx @@ -1,3 +1,4 @@ +import type { ReactNode } from 'react' import { useState } from 'react' import { RiArrowDropRightLine } from '@remixicon/react' import cn from '@/utils/classnames' @@ -10,6 +11,8 @@ type CollapseProps = { children: JSX.Element collapsed?: boolean onCollapse?: (collapsed: boolean) => void + operations?: ReactNode + } const Collapse = ({ disabled, @@ -17,34 +20,38 @@ const Collapse = ({ children, collapsed, onCollapse, + operations, }: CollapseProps) => { const [collapsedLocal, setCollapsedLocal] = useState(true) const collapsedMerged = collapsed !== undefined ? collapsed : collapsedLocal return ( <> -
{ - if (!disabled) { - setCollapsedLocal(!collapsedMerged) - onCollapse?.(!collapsedMerged) - } - }} - > -
- { - !disabled && ( - - ) - } +
+
{ + if (!disabled) { + setCollapsedLocal(!collapsedMerged) + onCollapse?.(!collapsedMerged) + } + }} + > +
+ { + !disabled && ( + + ) + } +
+ {trigger}
- {trigger} + {operations}
{ !collapsedMerged && children diff --git a/web/app/components/workflow/nodes/_base/components/output-vars.tsx b/web/app/components/workflow/nodes/_base/components/output-vars.tsx index 4a265a5a5b..953e9deb81 100644 --- a/web/app/components/workflow/nodes/_base/components/output-vars.tsx +++ b/web/app/components/workflow/nodes/_base/components/output-vars.tsx @@ -8,15 +8,20 @@ type Props = { className?: string title?: string children: ReactNode + operations?: ReactNode } const OutputVars: FC = ({ title, children, + operations, }) => { const { t } = useTranslation() return ( - + {children} ) @@ -40,9 +45,11 @@ export const VarItem: FC = ({ }) => { return (
-
-
{name}
-
{type}
+
+
+
{name}
+
{type}
+
{description} diff --git a/web/app/components/workflow/nodes/llm/components/structure-output.tsx b/web/app/components/workflow/nodes/llm/components/structure-output.tsx index b466d79ad9..a0bba53c27 100644 --- a/web/app/components/workflow/nodes/llm/components/structure-output.tsx +++ b/web/app/components/workflow/nodes/llm/components/structure-output.tsx @@ -7,13 +7,16 @@ import type { SchemaRoot, StructuredOutput } from '../types' import ShowPanel from '@/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/show' import { useBoolean } from 'ahooks' import JsonSchemaConfigModal from './json-schema-config-modal' +import cn from '@/utils/classnames' type Props = { + className?: string value?: StructuredOutput onChange: (value: StructuredOutput) => void, } const StructureOutput: FC = ({ + className, value, onChange, }) => { @@ -28,13 +31,18 @@ const StructureOutput: FC = ({ }) }, [onChange]) return ( -
+
structured_output
object
- @@ -43,7 +51,7 @@ const StructureOutput: FC = ({ ) : ( -
no data
+
no data
)} {showConfig && ( diff --git a/web/app/components/workflow/nodes/llm/panel.tsx b/web/app/components/workflow/nodes/llm/panel.tsx index cab8245aba..f4b0b6a0de 100644 --- a/web/app/components/workflow/nodes/llm/panel.tsx +++ b/web/app/components/workflow/nodes/llm/panel.tsx @@ -21,6 +21,7 @@ import ResultPanel from '@/app/components/workflow/run/result-panel' import Tooltip from '@/app/components/base/tooltip' import Editor from '@/app/components/workflow/nodes/_base/components/prompt/editor' import StructureOutput from './components/structure-output' +import Switch from '@/app/components/base/switch' const i18nPrefix = 'workflow.nodes.llm' @@ -65,6 +66,7 @@ const Panel: FC> = ({ contexts, setContexts, runningStatus, + handleStructureOutputEnableChange, handleStructureOutputChange, handleRun, handleStop, @@ -274,17 +276,34 @@ const Panel: FC> = ({ />
- + + +
+ } + > <> - + {inputs.structured_output_enabled && ( + <> + + + + )} {isShowSingleRun && ( diff --git a/web/app/components/workflow/nodes/llm/use-config.ts b/web/app/components/workflow/nodes/llm/use-config.ts index 0e6fe00cbc..4e6dac024d 100644 --- a/web/app/components/workflow/nodes/llm/use-config.ts +++ b/web/app/components/workflow/nodes/llm/use-config.ts @@ -277,6 +277,13 @@ const useConfig = (id: string, payload: LLMNodeType) => { setInputs(newInputs) }, [inputs, setInputs]) + const handleStructureOutputEnableChange = useCallback((enabled: boolean) => { + const newInputs = produce(inputs, (draft) => { + draft.structured_output_enabled = enabled + }) + setInputs(newInputs) + }, [inputs, setInputs]) + const handleStructureOutputChange = useCallback((newOutput: StructuredOutput) => { const newInputs = produce(inputs, (draft) => { draft.structured_output = newOutput @@ -416,6 +423,7 @@ const useConfig = (id: string, payload: LLMNodeType) => { varInputs, runningStatus, handleStructureOutputChange, + handleStructureOutputEnableChange, handleRun, handleStop, runResult,