mirror of
https://github.com/stackblitz/bolt.new
synced 2025-02-06 04:48:04 +00:00
fixes for PR #332
This commit is contained in:
parent
fe3ea8005e
commit
76713c2e6e
@ -9,10 +9,7 @@ interface UserMessageProps {
|
||||
}
|
||||
|
||||
export function UserMessage({ content }: UserMessageProps) {
|
||||
const sanitizedContent = sanitizeUserMessage(content);
|
||||
const textContent = Array.isArray(sanitizedContent)
|
||||
? sanitizedContent.find(item => item.type === 'text')?.text || ''
|
||||
: sanitizedContent;
|
||||
const textContent = sanitizeUserMessage(content);
|
||||
|
||||
return (
|
||||
<div className="overflow-hidden pt-[4px]">
|
||||
@ -23,17 +20,9 @@ export function UserMessage({ content }: UserMessageProps) {
|
||||
|
||||
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
|
||||
});
|
||||
const textItem = content.find(item => item.type === 'text');
|
||||
return textItem?.text?.replace(MODEL_REGEX, '').replace(PROVIDER_REGEX, '') || '';
|
||||
}
|
||||
|
||||
// Handle legacy string content
|
||||
return content.replace(/\[Model:.*?\]\n\n/, '').replace(/\[Provider:.*?\]\n\n/, '');
|
||||
return content.replace(MODEL_REGEX, '').replace(PROVIDER_REGEX, '');
|
||||
}
|
@ -23,6 +23,7 @@ import { isMobile } from '~/utils/mobile';
|
||||
import { FileBreadcrumb } from './FileBreadcrumb';
|
||||
import { FileTree } from './FileTree';
|
||||
import { Terminal, type TerminalRef } from './terminal/Terminal';
|
||||
import React from 'react';
|
||||
|
||||
interface EditorPanelProps {
|
||||
files?: FileMap;
|
||||
@ -203,7 +204,7 @@ export const EditorPanel = memo(
|
||||
const isActive = activeTerminal === index;
|
||||
|
||||
return (
|
||||
<>
|
||||
<React.Fragment key={index}>
|
||||
{index == 0 ? (
|
||||
<button
|
||||
key={index}
|
||||
@ -222,7 +223,7 @@ export const EditorPanel = memo(
|
||||
Bolt Terminal
|
||||
</button>
|
||||
) : (
|
||||
<>
|
||||
<React.Fragment>
|
||||
<button
|
||||
key={index}
|
||||
className={classNames(
|
||||
@ -238,9 +239,9 @@ export const EditorPanel = memo(
|
||||
<div className="i-ph:terminal-window-duotone text-lg" />
|
||||
Terminal {terminalCount > 1 && index}
|
||||
</button>
|
||||
</>
|
||||
</React.Fragment>
|
||||
)}
|
||||
</>
|
||||
</React.Fragment>
|
||||
);
|
||||
})}
|
||||
{terminalCount < MAX_TERMINALS && <IconButton icon="i-ph:plus" size="md" onClick={addTerminal} />}
|
||||
|
@ -80,6 +80,11 @@ export function streamText(
|
||||
return message; // No changes for non-user messages
|
||||
});
|
||||
|
||||
console.log('Stream Text:', JSON.stringify({
|
||||
model: getModel(currentProvider, currentModel, env, apiKeys),
|
||||
messages: convertToCoreMessages(processedMessages),
|
||||
}));
|
||||
|
||||
return _streamText({
|
||||
model: getModel(currentProvider, currentModel, env, apiKeys),
|
||||
system: getSystemPrompt(),
|
||||
|
Loading…
Reference in New Issue
Block a user