From 47ad74d1375e8c2603733187fceed151a4b7a8a8 Mon Sep 17 00:00:00 2001 From: Eugene Date: Thu, 5 Jun 2025 09:51:03 +0200 Subject: [PATCH] feat(Structured Output Parser Node): Add notice about $refs support in JSON schema (#15973) --- .../InformationExtractor.node.ts | 12 ---------- .../OutputParserStructured.node.ts | 23 +++++++++---------- .../nodes-langchain/utils/descriptions.ts | 3 ++- 3 files changed, 13 insertions(+), 25 deletions(-) diff --git a/packages/@n8n/nodes-langchain/nodes/chains/InformationExtractor/InformationExtractor.node.ts b/packages/@n8n/nodes-langchain/nodes/chains/InformationExtractor/InformationExtractor.node.ts index c4b618a284..eee9f9bffc 100644 --- a/packages/@n8n/nodes-langchain/nodes/chains/InformationExtractor/InformationExtractor.node.ts +++ b/packages/@n8n/nodes-langchain/nodes/chains/InformationExtractor/InformationExtractor.node.ts @@ -105,18 +105,6 @@ export class InformationExtractor implements INodeType { } }`, }, - { - displayName: - 'The schema has to be defined in the JSON Schema format. Look at this page for examples.', - name: 'notice', - type: 'notice', - default: '', - displayOptions: { - show: { - schemaType: ['manual'], - }, - }, - }, { displayName: 'Attributes', name: 'attributes', diff --git a/packages/@n8n/nodes-langchain/nodes/output_parser/OutputParserStructured/OutputParserStructured.node.ts b/packages/@n8n/nodes-langchain/nodes/output_parser/OutputParserStructured/OutputParserStructured.node.ts index af089f1c7b..5c81a2b20c 100644 --- a/packages/@n8n/nodes-langchain/nodes/output_parser/OutputParserStructured/OutputParserStructured.node.ts +++ b/packages/@n8n/nodes-langchain/nodes/output_parser/OutputParserStructured/OutputParserStructured.node.ts @@ -120,18 +120,6 @@ export class OutputParserStructured implements INodeType { }, }, }, - { - displayName: - 'The schema has to be defined in the JSON Schema format. Look at this page for examples.', - name: 'notice', - type: 'notice', - default: '', - displayOptions: { - hide: { - schemaType: ['fromJson'], - }, - }, - }, { displayName: 'Auto-Fix Format', description: @@ -172,6 +160,17 @@ export class OutputParserStructured implements INodeType { 'Prompt template used for fixing the output. Uses placeholders: "{instructions}" for parsing rules, "{completion}" for the failed attempt, and "{error}" for the validation error message.', }, ], + hints: [ + { + message: + 'Fields that use $refs might have the wrong type, since this syntax is not currently supported', + type: 'warning', + location: 'outputPane', + whenToDisplay: 'afterExecution', + displayCondition: + '={{ $parameter["schemaType"] === "manual" && $parameter["inputSchema"]?.includes("$ref") }}', + }, + ], }; async supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise { diff --git a/packages/@n8n/nodes-langchain/utils/descriptions.ts b/packages/@n8n/nodes-langchain/utils/descriptions.ts index e3ac7277d3..072473fc53 100644 --- a/packages/@n8n/nodes-langchain/utils/descriptions.ts +++ b/packages/@n8n/nodes-langchain/utils/descriptions.ts @@ -12,7 +12,7 @@ export const schemaTypeField: INodeProperties = { description: 'Generate a schema from an example JSON object', }, { - name: 'Define Below', + name: 'Define using JSON Schema', value: 'manual', description: 'Define the JSON schema manually', }, @@ -71,6 +71,7 @@ export const buildInputSchemaField = (props?: { }, }, description: 'Schema to use for the function', + hint: 'Use JSON Schema format (examples). $refs syntax is currently not supported.', }); export const inputSchemaField = buildInputSchemaField();