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) {
|
export function UserMessage({ content }: UserMessageProps) {
|
||||||
const sanitizedContent = sanitizeUserMessage(content);
|
const textContent = sanitizeUserMessage(content);
|
||||||
const textContent = Array.isArray(sanitizedContent)
|
|
||||||
? sanitizedContent.find(item => item.type === 'text')?.text || ''
|
|
||||||
: sanitizedContent;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="overflow-hidden pt-[4px]">
|
<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}}>) {
|
function sanitizeUserMessage(content: string | Array<{type: string, text?: string, image_url?: {url: string}}>) {
|
||||||
if (Array.isArray(content)) {
|
if (Array.isArray(content)) {
|
||||||
return content.map(item => {
|
const textItem = content.find(item => item.type === 'text');
|
||||||
if (item.type === 'text') {
|
return textItem?.text?.replace(MODEL_REGEX, '').replace(PROVIDER_REGEX, '') || '';
|
||||||
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_REGEX, '').replace(PROVIDER_REGEX, '');
|
||||||
return content.replace(/\[Model:.*?\]\n\n/, '').replace(/\[Provider:.*?\]\n\n/, '');
|
}
|
||||||
}
|
|
@ -23,6 +23,7 @@ import { isMobile } from '~/utils/mobile';
|
|||||||
import { FileBreadcrumb } from './FileBreadcrumb';
|
import { FileBreadcrumb } from './FileBreadcrumb';
|
||||||
import { FileTree } from './FileTree';
|
import { FileTree } from './FileTree';
|
||||||
import { Terminal, type TerminalRef } from './terminal/Terminal';
|
import { Terminal, type TerminalRef } from './terminal/Terminal';
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
interface EditorPanelProps {
|
interface EditorPanelProps {
|
||||||
files?: FileMap;
|
files?: FileMap;
|
||||||
@ -203,7 +204,7 @@ export const EditorPanel = memo(
|
|||||||
const isActive = activeTerminal === index;
|
const isActive = activeTerminal === index;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<React.Fragment key={index}>
|
||||||
{index == 0 ? (
|
{index == 0 ? (
|
||||||
<button
|
<button
|
||||||
key={index}
|
key={index}
|
||||||
@ -222,7 +223,7 @@ export const EditorPanel = memo(
|
|||||||
Bolt Terminal
|
Bolt Terminal
|
||||||
</button>
|
</button>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<React.Fragment>
|
||||||
<button
|
<button
|
||||||
key={index}
|
key={index}
|
||||||
className={classNames(
|
className={classNames(
|
||||||
@ -238,9 +239,9 @@ export const EditorPanel = memo(
|
|||||||
<div className="i-ph:terminal-window-duotone text-lg" />
|
<div className="i-ph:terminal-window-duotone text-lg" />
|
||||||
Terminal {terminalCount > 1 && index}
|
Terminal {terminalCount > 1 && index}
|
||||||
</button>
|
</button>
|
||||||
</>
|
</React.Fragment>
|
||||||
)}
|
)}
|
||||||
</>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
{terminalCount < MAX_TERMINALS && <IconButton icon="i-ph:plus" size="md" onClick={addTerminal} />}
|
{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
|
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({
|
return _streamText({
|
||||||
model: getModel(currentProvider, currentModel, env, apiKeys),
|
model: getModel(currentProvider, currentModel, env, apiKeys),
|
||||||
system: getSystemPrompt(),
|
system: getSystemPrompt(),
|
||||||
|
Loading…
Reference in New Issue
Block a user