/* * @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'; import { useStore } from '@nanostores/react'; import { profileStore } from '~/lib/stores/profile'; import type { TextUIPart, ReasoningUIPart, ToolInvocationUIPart, SourceUIPart, FileUIPart, StepStartUIPart, } from '@ai-sdk/ui-utils'; interface UserMessageProps { content: string | Array<{ type: string; text?: string; image?: string }>; parts: | (TextUIPart | ReasoningUIPart | ToolInvocationUIPart | SourceUIPart | FileUIPart | StepStartUIPart)[] | undefined; } export function UserMessage({ content, parts }: UserMessageProps) { const profile = useStore(profileStore); // Extract images from parts - look for file parts with image mime types const images = parts?.filter( (part): part is FileUIPart => part.type === 'file' && 'mimeType' in part && part.mimeType.startsWith('image/'), ) || []; if (Array.isArray(content)) { const textItem = content.find((item) => item.type === 'text'); const textContent = stripMetadata(textItem?.text || ''); return (
{profile?.avatar || profile?.username ? (
{profile?.username {profile?.username ? profile.username : ''}
) : (
)}
{textContent && {textContent}} {images.map((item, index) => ( {`Image ))}
); } const textContent = stripMetadata(content); return (
{images.map((item, index) => (
{`Image
))}
{textContent}
); } function stripMetadata(content: string) { const artifactRegex = /]*>[\s\S]*?<\/boltArtifact>/gm; return content.replace(MODEL_REGEX, '').replace(PROVIDER_REGEX, '').replace(artifactRegex, ''); }