bolt.diy/app/components/chat/UserMessage.tsx

28 lines
724 B
TypeScript
Raw Normal View History

2024-11-21 21:05:35 +00:00
/*
* @ts-nocheck
* Preventing TS checks with files presented in the video for a better presentation.
*/
import { modificationsRegex } from '~/utils/diff';
import { MODEL_REGEX, PROVIDER_REGEX } from '~/utils/constants';
2024-07-10 16:44:39 +00:00
import { Markdown } from './Markdown';
interface UserMessageProps {
content: string;
}
export function UserMessage({ content }: UserMessageProps) {
return (
<div className="overflow-hidden pt-[4px]">
2024-08-22 13:06:51 +00:00
<Markdown limitedMarkdown>{sanitizeUserMessage(content)}</Markdown>
2024-07-10 16:44:39 +00:00
</div>
);
}
function sanitizeUserMessage(content: string) {
2024-11-21 21:05:35 +00:00
return content
.replace(modificationsRegex, '')
.replace(MODEL_REGEX, 'Using: $1')
.replace(PROVIDER_REGEX, ' ($1)\n\n')
.trim();
}