From 4ec6a4e49359ba6840acc844c8b7d05598ba51df Mon Sep 17 00:00:00 2001 From: balibabu Date: Mon, 29 Dec 2025 17:46:05 +0800 Subject: [PATCH] Feat: Remove the code that outputs jsonschema from the webhook.#10427 (#12297) ### What problem does this PR solve? Feat: Remove the code that outputs jsonschema from the webhook.#10427 ### Type of change - [x] New Feature (non-breaking change which adds functionality) --- .../form/variable-assigner-form/index.tsx | 5 - .../hooks/use-build-structured-output.ts | 130 +++--------------- .../pages/agent/hooks/use-get-begin-query.tsx | 3 +- 3 files changed, 18 insertions(+), 120 deletions(-) diff --git a/web/src/pages/agent/form/variable-assigner-form/index.tsx b/web/src/pages/agent/form/variable-assigner-form/index.tsx index 6d717ebc7..931351e7e 100644 --- a/web/src/pages/agent/form/variable-assigner-form/index.tsx +++ b/web/src/pages/agent/form/variable-assigner-form/index.tsx @@ -24,8 +24,6 @@ export const FormSchema = z.object(VariableAssignerSchema); export type VariableAssignerFormSchemaType = z.infer; -// const outputList = buildOutputList(initialVariableAssignerValues.outputs); - function VariableAssignerForm({ node }: INextOperatorForm) { const defaultValues = useFormValues(initialDataOperationsValues, node); @@ -41,10 +39,7 @@ function VariableAssignerForm({ node }: INextOperatorForm) {
- {/* */} - {/* */} - {/* set up the dev tool */} ); } diff --git a/web/src/pages/agent/hooks/use-build-structured-output.ts b/web/src/pages/agent/hooks/use-build-structured-output.ts index efc309d30..c9d34bd43 100644 --- a/web/src/pages/agent/hooks/use-build-structured-output.ts +++ b/web/src/pages/agent/hooks/use-build-structured-output.ts @@ -2,9 +2,7 @@ import { getStructuredDatatype } from '@/utils/canvas-util'; import { get, isPlainObject } from 'lodash'; import { ReactNode, useCallback } from 'react'; import { - AgentDialogueMode, AgentStructuredOutputField, - BeginId, JsonSchemaDataType, Operator, } from '../constant'; @@ -18,94 +16,36 @@ function getNodeId(value: string) { } export function useShowSecondaryMenu() { - const { getOperatorTypeFromId, getNode } = useGraphStore((state) => state); + const { getOperatorTypeFromId } = useGraphStore((state) => state); const showSecondaryMenu = useCallback( (value: string, outputLabel: string) => { const nodeId = getNodeId(value); - const operatorType = getOperatorTypeFromId(nodeId); - - // For Agent nodes, show secondary menu for 'structured' field - if ( - operatorType === Operator.Agent && + return ( + getOperatorTypeFromId(nodeId) === Operator.Agent && outputLabel === AgentStructuredOutputField - ) { - return true; - } - - // For Begin nodes in webhook mode, show secondary menu for schema properties (body, headers, query, etc.) - if (operatorType === Operator.Begin) { - const node = getNode(nodeId); - const mode = get(node, 'data.form.mode'); - if (mode === AgentDialogueMode.Webhook) { - // Check if this output field is from the schema - const outputs = get(node, 'data.form.outputs', {}); - const outputField = outputs[outputLabel]; - // Show secondary menu if the field is an object or has properties - return ( - outputField && - (outputField.type === 'object' || - (outputField.properties && - Object.keys(outputField.properties).length > 0)) - ); - } - } - - return false; + ); }, - [getOperatorTypeFromId, getNode], + [getOperatorTypeFromId], ); return showSecondaryMenu; } -function useGetBeginOutputsOrSchema() { - const { getNode } = useGraphStore((state) => state); - - const getBeginOutputs = useCallback(() => { - const node = getNode(BeginId); - const outputs = get(node, 'data.form.outputs', {}); - return outputs; - }, [getNode]); - - const getBeginSchema = useCallback(() => { - const node = getNode(BeginId); - const outputs = get(node, 'data.form.schema', {}); - return outputs; - }, [getNode]); - - return { getBeginOutputs, getBeginSchema }; -} export function useGetStructuredOutputByValue() { - const { getNode, getOperatorTypeFromId } = useGraphStore((state) => state); - - const { getBeginOutputs } = useGetBeginOutputsOrSchema(); + const { getNode } = useGraphStore((state) => state); const getStructuredOutput = useCallback( (value: string) => { - const nodeId = getNodeId(value); - const node = getNode(nodeId); - const operatorType = getOperatorTypeFromId(nodeId); - const fields = splitValue(value); - const outputLabel = fields.at(1); - - let structuredOutput; - if (operatorType === Operator.Agent) { - structuredOutput = get( - node, - `data.form.outputs.${AgentStructuredOutputField}`, - ); - } else if (operatorType === Operator.Begin) { - // For Begin nodes in webhook mode, get the specific schema property - const outputs = getBeginOutputs(); - if (outputLabel) { - structuredOutput = outputs[outputLabel]; - } - } + const node = getNode(getNodeId(value)); + const structuredOutput = get( + node, + `data.form.outputs.${AgentStructuredOutputField}`, + ); return structuredOutput; }, - [getBeginOutputs, getNode, getOperatorTypeFromId], + [getNode], ); return getStructuredOutput; @@ -126,14 +66,13 @@ export function useFindAgentStructuredOutputLabel() { icon?: ReactNode; }>, ) => { + // agent structured output const fields = splitValue(value); - const operatorType = getOperatorTypeFromId(fields.at(0)); - - // Handle Agent structured fields if ( - operatorType === Operator.Agent && + getOperatorTypeFromId(fields.at(0)) === Operator.Agent && fields.at(1)?.startsWith(AgentStructuredOutputField) ) { + // is agent structured output const agentOption = options.find((x) => value.includes(x.value)); const jsonSchemaFields = fields .at(1) @@ -145,19 +84,6 @@ export function useFindAgentStructuredOutputLabel() { value: value, }; } - - // Handle Begin webhook fields - if (operatorType === Operator.Begin && fields.at(1)) { - const fieldOption = options - .filter((x) => x.parentLabel === BeginId) - .find((x) => value.startsWith(x.value)); - - return { - ...fieldOption, - label: fields.at(1), - value: value, - }; - } }, [getOperatorTypeFromId], ); @@ -168,7 +94,6 @@ export function useFindAgentStructuredOutputLabel() { export function useFindAgentStructuredOutputTypeByValue() { const { getOperatorTypeFromId } = useGraphStore((state) => state); const filterStructuredOutput = useGetStructuredOutputByValue(); - const { getBeginSchema } = useGetBeginOutputsOrSchema(); const findTypeByValue = useCallback( ( @@ -211,12 +136,10 @@ export function useFindAgentStructuredOutputTypeByValue() { } const fields = splitValue(value); const nodeId = fields.at(0); - const operatorType = getOperatorTypeFromId(nodeId); const jsonSchema = filterStructuredOutput(value); - // Handle Agent structured fields if ( - operatorType === Operator.Agent && + getOperatorTypeFromId(nodeId) === Operator.Agent && fields.at(1)?.startsWith(AgentStructuredOutputField) ) { const jsonSchemaFields = fields @@ -228,32 +151,13 @@ export function useFindAgentStructuredOutputTypeByValue() { return type; } } - - // Handle Begin webhook fields (body, headers, query, etc.) - if (operatorType === Operator.Begin) { - const outputLabel = fields.at(1); - const schema = getBeginSchema(); - if (outputLabel && schema) { - const jsonSchemaFields = fields.at(1); - if (jsonSchemaFields) { - const type = findTypeByValue(schema, jsonSchemaFields); - return type; - } - } - } }, - [ - filterStructuredOutput, - findTypeByValue, - getBeginSchema, - getOperatorTypeFromId, - ], + [filterStructuredOutput, findTypeByValue, getOperatorTypeFromId], ); return findAgentStructuredOutputTypeByValue; } -// TODO: Consider merging with useFindAgentStructuredOutputLabel export function useFindAgentStructuredOutputLabelByValue() { const { getNode } = useGraphStore((state) => state); diff --git a/web/src/pages/agent/hooks/use-get-begin-query.tsx b/web/src/pages/agent/hooks/use-get-begin-query.tsx index 46825e5a4..5de22e0e9 100644 --- a/web/src/pages/agent/hooks/use-get-begin-query.tsx +++ b/web/src/pages/agent/hooks/use-get-begin-query.tsx @@ -318,8 +318,7 @@ export function useFilterQueryVariableOptionsByTypes({ isAgentStructured( y.value, y.value.slice(-AgentStructuredOutputField.length), - ) || - y.value.startsWith(BeginId), // begin node outputs + ), ), }; })