mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### 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)
33 lines
1.0 KiB
TypeScript
33 lines
1.0 KiB
TypeScript
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';
|
|
|
|
export function useShowStructuredOutputDialog(form: UseFormReturn<any>) {
|
|
const {
|
|
visible: structuredOutputDialogVisible,
|
|
showModal: showStructuredOutputDialog,
|
|
hideModal: hideStructuredOutputDialog,
|
|
} = useSetModalState();
|
|
|
|
const initialStructuredOutput = form.getValues(AgentStructuredOutputField);
|
|
|
|
const handleStructuredOutputDialogOk = useCallback(
|
|
(values: JSONSchema) => {
|
|
// Sync data to canvas
|
|
form.setValue(AgentStructuredOutputField, values);
|
|
hideStructuredOutputDialog();
|
|
},
|
|
[form, hideStructuredOutputDialog],
|
|
);
|
|
|
|
return {
|
|
initialStructuredOutput,
|
|
structuredOutputDialogVisible,
|
|
showStructuredOutputDialog,
|
|
hideStructuredOutputDialog,
|
|
handleStructuredOutputDialogOk,
|
|
};
|
|
}
|