refactor(Basic LLM Chain Node): Refactor Basic LLM Chain & add tests (#13850)

This commit is contained in:
oleg
2025-03-14 11:38:22 +01:00
committed by GitHub
parent 311553926a
commit 1bfd128717
24 changed files with 1754 additions and 609 deletions

View File

@@ -0,0 +1,30 @@
import type { IDataObject } from 'n8n-workflow';
/**
* Formats the response from the LLM chain into a consistent structure
*/
export function formatResponse(response: unknown): IDataObject {
if (typeof response === 'string') {
return {
response: {
text: response.trim(),
},
};
}
if (Array.isArray(response)) {
return {
data: response,
};
}
if (response instanceof Object) {
return response as IDataObject;
}
return {
response: {
text: response,
},
};
}