UNPKG

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.

32 lines (28 loc) 950 B
import {ChatSegment} from '../../types/chatSegment/chatSegment'; import {ChatItem} from '../../types/conversation'; export const chatSegmentsToChatItems = <AiMsg>( chatSegments: ChatSegment<AiMsg>[], ): ChatItem<AiMsg>[] => { const chatItems: ChatItem<AiMsg>[] = []; chatSegments.forEach((segment) => { segment.items.forEach((item) => { if (item.status !== 'complete') { return; } if (item.participantRole === 'assistant') { chatItems.push({ role: 'assistant', message: item.content as AiMsg, }); } else { if (item.participantRole === 'user') { return chatItems.push({ role: 'user', message: item.content, }); } } }); }); return chatItems; };