mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
31 lines
497 B
TypeScript
31 lines
497 B
TypeScript
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,
|
|
},
|
|
};
|
|
}
|