mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
fix(Structured Output Parser Node, Auto-fixing Output Parser Node, Tools Agent Node): Structured output improvements (#13908)
Co-authored-by: Oleg Ivaniv <me@olegivaniv.com>
This commit is contained in:
@@ -221,3 +221,22 @@ export const getConnectedTools = async (
|
||||
|
||||
return finalTools;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sometimes model output is wrapped in an additional object property.
|
||||
* This function unwraps the output if it is in the format { output: { output: { ... } } }
|
||||
*/
|
||||
export function unwrapNestedOutput(output: Record<string, unknown>): Record<string, unknown> {
|
||||
if (
|
||||
'output' in output &&
|
||||
Object.keys(output).length === 1 &&
|
||||
typeof output.output === 'object' &&
|
||||
output.output !== null &&
|
||||
'output' in output.output &&
|
||||
Object.keys(output.output).length === 1
|
||||
) {
|
||||
return output.output as Record<string, unknown>;
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user