/* * @ts-nocheck * Preventing TS checks with files presented in the video for a better presentation. */ import { MODEL_REGEX, PROVIDER_REGEX } from '~/utils/constants'; import { Markdown } from './Markdown'; interface UserMessageProps { content: string | Array<{ type: string; text?: string; image?: string }>; } export function UserMessage({ content }: UserMessageProps) { if (Array.isArray(content)) { const textItem = content.find((item) => item.type === 'text'); const textContent = stripMetadata(textItem?.text || ''); const images = content.filter((item) => item.type === 'image' && item.image); return (
{textContent && {textContent}} {images.map((item, index) => ( {`Image ))}
); } const textContent = stripMetadata(content); return (
{textContent}
); } function stripMetadata(content: string) { return content.replace(MODEL_REGEX, '').replace(PROVIDER_REGEX, ''); }