mirror of
https://github.com/stackblitz-labs/bolt.diy
synced 2025-06-26 18:26:38 +00:00
image-upload
This commit is contained in:
@@ -9,13 +9,34 @@ interface UserMessageProps {
|
||||
}
|
||||
|
||||
export function UserMessage({ content }: UserMessageProps) {
|
||||
const sanitizedContent = sanitizeUserMessage(content);
|
||||
const textContent = Array.isArray(sanitizedContent)
|
||||
? sanitizedContent.find(item => item.type === 'text')?.text || ''
|
||||
: sanitizedContent;
|
||||
|
||||
return (
|
||||
<div className="overflow-hidden pt-[4px]">
|
||||
<Markdown limitedMarkdown>{sanitizeUserMessage(content)}</Markdown>
|
||||
<Markdown limitedMarkdown>{textContent}</Markdown>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function sanitizeUserMessage(content: string) {
|
||||
return content.replace(modificationsRegex, '').replace(MODEL_REGEX, 'Using: $1').replace(PROVIDER_REGEX, ' ($1)\n\n').trim();
|
||||
// function sanitizeUserMessage(content: string) {
|
||||
// return content.replace(modificationsRegex, '').replace(MODEL_REGEX, 'Using: $1').replace(PROVIDER_REGEX, ' ($1)\n\n').trim();
|
||||
// }
|
||||
function sanitizeUserMessage(content: string | Array<{type: string, text?: string, image_url?: {url: string}}>) {
|
||||
if (Array.isArray(content)) {
|
||||
return content.map(item => {
|
||||
if (item.type === 'text') {
|
||||
return {
|
||||
type: 'text',
|
||||
text: item.text?.replace(/\[Model:.*?\]\n\n/, '').replace(/\[Provider:.*?\]\n\n/, '')
|
||||
};
|
||||
}
|
||||
return item; // Keep image_url items unchanged
|
||||
});
|
||||
}
|
||||
|
||||
// Handle legacy string content
|
||||
return content.replace(/\[Model:.*?\]\n\n/, '').replace(/\[Provider:.*?\]\n\n/, '');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user