Feat: Add a switch to control the display of structured output to the agent form. #10427 (#11344)

### What problem does this PR solve?

Feat: Add a switch to control the display of structured output to the
agent form. #10427

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2025-11-18 18:58:36 +08:00
committed by GitHub
parent d1716d865a
commit 4942a23290
13 changed files with 133 additions and 75 deletions

View File

@ -1,27 +1,25 @@
import { JSONSchema } from '@/components/jsonjoy-builder';
import { AgentStructuredOutputField } from '@/constants/agent';
import { useSetModalState } from '@/hooks/common-hooks';
import { useCallback } from 'react';
import useGraphStore from '../../store';
import { UseFormReturn } from 'react-hook-form';
export function useShowStructuredOutputDialog(nodeId?: string) {
export function useShowStructuredOutputDialog(form: UseFormReturn<any>) {
const {
visible: structuredOutputDialogVisible,
showModal: showStructuredOutputDialog,
hideModal: hideStructuredOutputDialog,
} = useSetModalState();
const { updateNodeForm, getNode } = useGraphStore((state) => state);
const initialStructuredOutput = getNode(nodeId)?.data.form.outputs.structured;
const initialStructuredOutput = form.getValues(AgentStructuredOutputField);
const handleStructuredOutputDialogOk = useCallback(
(values: JSONSchema) => {
// Sync data to canvas
if (nodeId) {
updateNodeForm(nodeId, values, ['outputs', 'structured']);
}
form.setValue(AgentStructuredOutputField, values);
hideStructuredOutputDialog();
},
[hideStructuredOutputDialog, nodeId, updateNodeForm],
[form, hideStructuredOutputDialog],
);
return {