mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 12:32:30 +08:00
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:
@ -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',
|
||||
|
||||
@ -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) => (
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -22,7 +22,8 @@ export function useWatchFormChange(id?: string, form?: UseFormReturn<any>) {
|
||||
...nextValues,
|
||||
outputs: {
|
||||
...values.outputs,
|
||||
[AgentStructuredOutputField]: values[AgentStructuredOutputField],
|
||||
[AgentStructuredOutputField]:
|
||||
values[AgentStructuredOutputField] ?? {},
|
||||
},
|
||||
};
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user