UNPKG

@botonic/plugin-flow-builder

Version:

Use Flow Builder to show your contents

36 lines 1.76 kB
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime"; import { Button, Carousel, Text } from '@botonic/react'; import { SOURCE_INFO_SEPARATOR } from '../constants'; import { ContentFieldsBase } from './content-fields-base'; import { FlowElement } from './flow-element'; export class FlowAiAgent extends ContentFieldsBase { constructor() { super(...arguments); this.code = ''; this.name = ''; this.instructions = ''; this.responses = []; } static fromHubtypeCMS(component) { const newAiAgent = new FlowAiAgent(component.id); newAiAgent.name = component.content.name; newAiAgent.instructions = component.content.instructions; newAiAgent.activeTools = component.content.active_tools; return newAiAgent; } toBotonic(id) { return (_jsx(_Fragment, { children: this.responses.map(response => { if (response.type === 'text') { return _jsx(Text, { children: response.content.text }, id); } if (response.type === 'textWithButtons') { return (_jsxs(Text, { children: [response.content.text, response.content.buttons.map((button, buttonIndex) => (_jsx(Button, Object.assign({ payload: `do-nothing${SOURCE_INFO_SEPARATOR}${buttonIndex}` }, { children: button }), buttonIndex)))] }, id)); } if (response.type === 'carousel') { return (_jsx(Carousel, { children: response.content.elements.map(element => FlowElement.fromAIAgent(id, element).toBotonic(id)) }, id)); } return _jsx(_Fragment, {}); }) })); } } //# sourceMappingURL=flow-ai-agent.js.map