/** * Copyright (c) 2023 MERCENARIES.AI PTE. LTD. * All rights reserved. */ import DOMPurify from 'dompurify'; import { ChatRenderer } from 'omni-client-services'; import { OAIComponent31 } from 'omni-sockets'; // An extension to render an omnitool component object class OmniComponentRenderer extends ChatRenderer { constructor(id?: string, opts?: any) { super({ id: id ?? 'omni/component' }, opts); } render(content: { type: string; value: any }): string { const componentJson = JSON.parse(content.value); let component; if (componentJson.type === 'OAIComponent31') { component = OAIComponent31.fromJSON(componentJson); } if (!component) { //WorkflowComponentRegistry.getSingleton().add([component]) return `Can not render missing component ${content.value}`; } return `