fix(Basic LLM Chain Node): Prevent stringifying of structured output on previous versions (#14200)

This commit is contained in:
oleg
2025-03-27 11:48:17 +01:00
committed by GitHub
parent a4a34a2745
commit bbd6e8ee41
6 changed files with 375 additions and 19 deletions

View File

@@ -116,10 +116,13 @@ export class ChainLlm implements INodeType {
messages,
});
// If the node version is 1.6(and LLM is using `response_format: json_object`) or higher or an output parser is configured,
// we unwrap the response and return the object directly as JSON
const shouldUnwrapObjects = this.getNode().typeVersion >= 1.6 || !!outputParser;
// Process each response and add to return data
responses.forEach((response) => {
returnData.push({
json: formatResponse(response, this.getNode().typeVersion),
json: formatResponse(response, shouldUnwrapObjects),
});
});
} catch (error) {