legends810/testingnew
0
1/*2 * @ts-nocheck3 * Preventing TS checks with files presented in the video for a better presentation.4 */5import { MODEL_REGEX, PROVIDER_REGEX } from '~/utils/constants';6import { Markdown } from './Markdown';7 8interface UserMessageProps {9 content: string | Array<{ type: string; text?: string; image?: string }>;10}11 12export function UserMessage({ content }: UserMessageProps) {13 if (Array.isArray(content)) {14 const textItem = content.find((item) => item.type === 'text');15 const textContent = stripMetadata(textItem?.text || '');16 const images = content.filter((item) => item.type === 'image' && item.image);17 18 return (19 <div className="overflow-hidden pt-[4px]">20 <div className="flex flex-col gap-4">21 {textContent && <Markdown html>{textContent}</Markdown>}22 {images.map((item, index) => (23 <img24 key={index}25 src={item.image}26 alt={`Image ${index + 1}`}27 className="max-w-full h-auto rounded-lg"28 style={{ maxHeight: '512px', objectFit: 'contain' }}29 />30 ))}31 </div>32 </div>33 );34 }35 36 const textContent = stripMetadata(content);37 38 return (39 <div className="overflow-hidden pt-[4px]">40 <Markdown html>{textContent}</Markdown>41 </div>42 );43}44 45function stripMetadata(content: string) {46 const artifactRegex = /<boltArtifact\s+[^>]*>[\s\S]*?<\/boltArtifact>/gm;47 return content.replace(MODEL_REGEX, '').replace(PROVIDER_REGEX, '').replace(artifactRegex, '');48}49 