// SPDX-License-Identifier: MIT // Copyright contributors to the openassistant project import React from 'react'; import { Spinner, Link } from '@heroui/react'; import { MessagePayload, StreamMessage, ToolCallComponents, } from '@openassistant/core'; import { PartComponent } from './message-toolcall'; const FailedMessage = ({ githubIssueLink }: { githubIssueLink?: string }) => (

Sorry, something went wrong. If the issue persists please contact us through   Github

); const ScreenshotImage = ({ customMessage }: { customMessage: string }) => ( screenshot ); type MessageContentProps = { customMessage?: MessagePayload; hasFailed: boolean; githubIssueLink?: string; message?: StreamMessage; status?: 'success' | 'failed' | 'pending'; useMarkdown?: boolean; components?: ToolCallComponents; showTools?: boolean; }; export function MessageContent({ customMessage, hasFailed, githubIssueLink, message, status, useMarkdown, components, showTools, }: MessageContentProps) { return (
{/* show screenshot image */} {customMessage && typeof customMessage === 'string' && customMessage.startsWith('data:image') && ( )} {/* show parts of the message */} {message?.parts?.map((part, i) => ( ))} {/* show React payload e.g. LLM Model Configure Panel when it is a valid React element */} {customMessage && React.isValidElement(customMessage) && (
{customMessage}
)} {/* show error message if any */} {hasFailed && }
{/* show loading spinner */} {status === 'pending' && ( )}
); }