Feat: Structured data will still be stored in outputs for compatibility with older versions. #10427 (#11368)

### What problem does this PR solve?

Feat: Structured data will still be stored in outputs for compatibility
with older versions. #10427

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2025-11-19 15:15:51 +08:00
committed by GitHub
parent add8c63458
commit ba78d0f0c2
4 changed files with 12 additions and 15 deletions

View File

@ -5,7 +5,6 @@ import {
import {
AgentGlobals,
AgentGlobalsSysQueryWithBrace,
AgentStructuredOutputField,
CodeTemplateStrMap,
ComparisonOperator,
JsonSchemaDataType,
@ -465,7 +464,6 @@ export const initialAgentValues = {
mcp: [],
cite: true,
showStructuredOutput: false,
[AgentStructuredOutputField]: {},
outputs: {
content: {
type: 'string',

View File

@ -28,7 +28,6 @@ import { useTranslation } from 'react-i18next';
import { z } from 'zod';
import {
AgentExceptionMethod,
AgentStructuredOutputField,
NodeHandleId,
VariableType,
} from '../../constant';
@ -74,7 +73,6 @@ const FormSchema = z.object({
...LargeModelFilterFormSchema,
cite: z.boolean().optional(),
showStructuredOutput: z.boolean().optional(),
[AgentStructuredOutputField]: z.record(z.any()),
});
export type AgentFormSchemaType = z.infer<typeof FormSchema>;
@ -127,7 +125,7 @@ function AgentForm({ node }: INextOperatorForm) {
structuredOutputDialogVisible,
hideStructuredOutputDialog,
handleStructuredOutputDialogOk,
} = useShowStructuredOutputDialog(form);
} = useShowStructuredOutputDialog(node?.id);
useEffect(() => {
if (exceptionMethod !== AgentExceptionMethod.Goto) {
@ -284,9 +282,7 @@ function AgentForm({ node }: INextOperatorForm) {
)}
</section>
</Collapse>
<RAGFlowFormItem name={AgentStructuredOutputField} className="hidden">
<Input></Input>
</RAGFlowFormItem>
<Output list={outputList}>
<RAGFlowFormItem name="showStructuredOutput">
{(field) => (

View File

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

View File

@ -22,7 +22,8 @@ export function useWatchFormChange(id?: string, form?: UseFormReturn<any>) {
...nextValues,
outputs: {
...values.outputs,
[AgentStructuredOutputField]: values[AgentStructuredOutputField],
[AgentStructuredOutputField]:
values[AgentStructuredOutputField] ?? {},
},
};
} else {