mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
refactor(Basic LLM Chain Node): Refactor Basic LLM Chain & add tests (#13850)
This commit is contained in:
@@ -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,
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user