remix-nlux
Version:
Remix IDE NLUX integration. Remix IDE is the leading IDE for building and deploying smart contracts on Ethereum. NLUX is a JavaScript and React library for building conversational AI experiences.
20 lines (15 loc) • 501 B
text/typescript
export const stringifyRandomResponse = <AiMsg>(randomResponse: AiMsg): string => {
if (typeof randomResponse === 'string') {
return randomResponse;
}
if (typeof randomResponse === 'object') {
return `${randomResponse}`;
}
if (randomResponse === null || randomResponse === undefined) {
return '';
}
if (typeof randomResponse.toString === 'function') {
return randomResponse.toString();
}
return JSON.stringify(randomResponse);
};