fix(Basic LLM Chain Node): Prevent incorrect wrapping of output (#14183)

This commit is contained in:
oleg
2025-03-26 14:26:09 +01:00
committed by GitHub
parent ee64fdc5cb
commit b9030d45de
5 changed files with 174 additions and 25 deletions

View File

@@ -3,12 +3,10 @@ import type { IDataObject } from 'n8n-workflow';
/**
* Formats the response from the LLM chain into a consistent structure
*/
export function formatResponse(response: unknown): IDataObject {
export function formatResponse(response: unknown, version: number): IDataObject {
if (typeof response === 'string') {
return {
response: {
text: response.trim(),
},
text: response.trim(),
};
}
@@ -19,7 +17,13 @@ export function formatResponse(response: unknown): IDataObject {
}
if (response instanceof Object) {
return response as IDataObject;
if (version >= 1.6) {
return response as IDataObject;
}
return {
text: JSON.stringify(response),
};
}
return {