/* * @ts-nocheck * Preventing TS checks with files presented in the video for a better presentation. */ import { MODEL_REGEX, PROVIDER_REGEX } from '~/shared/utils/constants'; import { Markdown } from '~/chat/components/markdown/Markdown'; import { useStore } from '@nanostores/react'; import { profileStore } from '~/shared/stores/profile'; 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); const profile = useStore(profileStore); return (
{profile?.avatar || profile?.username ? (
{profile?.username {profile?.username ? profile.username : ''}
) : (
)}
{textContent && {textContent}} {images.map((item, index) => ( {`Image ))}
); } const textContent = stripMetadata(content); return (
{textContent}
); } function stripMetadata(content: string) { const artifactRegex = /]*>[\s\S]*?<\/boltArtifact>/gm; return content.replace(MODEL_REGEX, '').replace(PROVIDER_REGEX, '').replace(artifactRegex, ''); }