mirror of
https://github.com/stackblitz-labs/bolt.diy
synced 2025-06-26 18:26:38 +00:00
fix: add model and provider info to quick action messages
Pass model and provider information through chat components to include in quick action messages. This fixes the issue of defaulting to anthropic model.
This commit is contained in:
parent
12f9f4dcdc
commit
0017d29154
@ -6,6 +6,7 @@ import { workbenchStore } from '~/lib/stores/workbench';
|
|||||||
import { WORK_DIR } from '~/utils/constants';
|
import { WORK_DIR } from '~/utils/constants';
|
||||||
import WithTooltip from '~/components/ui/Tooltip';
|
import WithTooltip from '~/components/ui/Tooltip';
|
||||||
import type { Message } from 'ai';
|
import type { Message } from 'ai';
|
||||||
|
import type { ProviderInfo } from '~/types/model';
|
||||||
|
|
||||||
interface AssistantMessageProps {
|
interface AssistantMessageProps {
|
||||||
content: string;
|
content: string;
|
||||||
@ -16,6 +17,8 @@ interface AssistantMessageProps {
|
|||||||
append?: (message: Message) => void;
|
append?: (message: Message) => void;
|
||||||
chatMode?: 'discuss' | 'build';
|
chatMode?: 'discuss' | 'build';
|
||||||
setChatMode?: (mode: 'discuss' | 'build') => void;
|
setChatMode?: (mode: 'discuss' | 'build') => void;
|
||||||
|
model?: string;
|
||||||
|
provider?: ProviderInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
function openArtifactInWorkbench(filePath: string) {
|
function openArtifactInWorkbench(filePath: string) {
|
||||||
@ -43,7 +46,18 @@ function normalizedFilePath(path: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const AssistantMessage = memo(
|
export const AssistantMessage = memo(
|
||||||
({ content, annotations, messageId, onRewind, onFork, append, chatMode, setChatMode }: AssistantMessageProps) => {
|
({
|
||||||
|
content,
|
||||||
|
annotations,
|
||||||
|
messageId,
|
||||||
|
onRewind,
|
||||||
|
onFork,
|
||||||
|
append,
|
||||||
|
chatMode,
|
||||||
|
setChatMode,
|
||||||
|
model,
|
||||||
|
provider,
|
||||||
|
}: AssistantMessageProps) => {
|
||||||
const filteredAnnotations = (annotations?.filter(
|
const filteredAnnotations = (annotations?.filter(
|
||||||
(annotation: JSONValue) =>
|
(annotation: JSONValue) =>
|
||||||
annotation && typeof annotation === 'object' && Object.keys(annotation).includes('type'),
|
annotation && typeof annotation === 'object' && Object.keys(annotation).includes('type'),
|
||||||
@ -141,7 +155,7 @@ export const AssistantMessage = memo(
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
<Markdown append={append} chatMode={chatMode} setChatMode={setChatMode} html>
|
<Markdown append={append} chatMode={chatMode} setChatMode={setChatMode} model={model} provider={provider} html>
|
||||||
{content}
|
{content}
|
||||||
</Markdown>
|
</Markdown>
|
||||||
</div>
|
</div>
|
||||||
|
@ -359,6 +359,8 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
|
|||||||
append={append}
|
append={append}
|
||||||
chatMode={chatMode}
|
chatMode={chatMode}
|
||||||
setChatMode={setChatMode}
|
setChatMode={setChatMode}
|
||||||
|
provider={provider}
|
||||||
|
model={model}
|
||||||
/>
|
/>
|
||||||
) : null;
|
) : null;
|
||||||
}}
|
}}
|
||||||
|
@ -8,6 +8,7 @@ import { CodeBlock } from './CodeBlock';
|
|||||||
import type { Message } from 'ai';
|
import type { Message } from 'ai';
|
||||||
import styles from './Markdown.module.scss';
|
import styles from './Markdown.module.scss';
|
||||||
import ThoughtBox from './ThoughtBox';
|
import ThoughtBox from './ThoughtBox';
|
||||||
|
import type { ProviderInfo } from '~/types/model';
|
||||||
|
|
||||||
const logger = createScopedLogger('MarkdownComponent');
|
const logger = createScopedLogger('MarkdownComponent');
|
||||||
|
|
||||||
@ -18,10 +19,12 @@ interface MarkdownProps {
|
|||||||
append?: (message: Message) => void;
|
append?: (message: Message) => void;
|
||||||
chatMode?: 'discuss' | 'build';
|
chatMode?: 'discuss' | 'build';
|
||||||
setChatMode?: (mode: 'discuss' | 'build') => void;
|
setChatMode?: (mode: 'discuss' | 'build') => void;
|
||||||
|
model?: string;
|
||||||
|
provider?: ProviderInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Markdown = memo(
|
export const Markdown = memo(
|
||||||
({ children, html = false, limitedMarkdown = false, append, setChatMode }: MarkdownProps) => {
|
({ children, html = false, limitedMarkdown = false, append, setChatMode, model, provider }: MarkdownProps) => {
|
||||||
logger.trace('Render');
|
logger.trace('Render');
|
||||||
|
|
||||||
const components = useMemo(() => {
|
const components = useMemo(() => {
|
||||||
@ -106,17 +109,17 @@ export const Markdown = memo(
|
|||||||
openArtifactInWorkbench(path);
|
openArtifactInWorkbench(path);
|
||||||
} else if (type === 'message' && append) {
|
} else if (type === 'message' && append) {
|
||||||
append({
|
append({
|
||||||
id: 'random-message', // Replace with your ID generation logic
|
id: `quick-action-message-${Date.now()}`,
|
||||||
content: message as string, // The message content from the action
|
content: `[Model: ${model}]\n\n[Provider: ${provider?.name}]\n\n${message}`,
|
||||||
role: 'user', // Or another role as appropriate
|
role: 'user',
|
||||||
});
|
});
|
||||||
console.log('Message appended:', message); // Log the appended message
|
console.log('Message appended:', message);
|
||||||
} else if (type === 'implement' && append && setChatMode) {
|
} else if (type === 'implement' && append && setChatMode) {
|
||||||
setChatMode('build');
|
setChatMode('build');
|
||||||
append({
|
append({
|
||||||
id: 'implement-message', // Replace with your ID generation logic
|
id: `quick-action-implement-${Date.now()}`,
|
||||||
content: message as string, // The message content from the action
|
content: `[Model: ${model}]\n\n[Provider: ${provider?.name}]\n\n${message}`,
|
||||||
role: 'user', // Or another role as appropriate
|
role: 'user',
|
||||||
});
|
});
|
||||||
} else if (type === 'link' && typeof href === 'string') {
|
} else if (type === 'link' && typeof href === 'string') {
|
||||||
try {
|
try {
|
||||||
|
@ -11,6 +11,7 @@ import { useStore } from '@nanostores/react';
|
|||||||
import { profileStore } from '~/lib/stores/profile';
|
import { profileStore } from '~/lib/stores/profile';
|
||||||
import { forwardRef } from 'react';
|
import { forwardRef } from 'react';
|
||||||
import type { ForwardedRef } from 'react';
|
import type { ForwardedRef } from 'react';
|
||||||
|
import type { ProviderInfo } from '~/types/model';
|
||||||
|
|
||||||
interface MessagesProps {
|
interface MessagesProps {
|
||||||
id?: string;
|
id?: string;
|
||||||
@ -20,6 +21,8 @@ interface MessagesProps {
|
|||||||
append?: (message: Message) => void;
|
append?: (message: Message) => void;
|
||||||
chatMode?: 'discuss' | 'build';
|
chatMode?: 'discuss' | 'build';
|
||||||
setChatMode?: (mode: 'discuss' | 'build') => void;
|
setChatMode?: (mode: 'discuss' | 'build') => void;
|
||||||
|
model?: string;
|
||||||
|
provider?: ProviderInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Messages = forwardRef<HTMLDivElement, MessagesProps>(
|
export const Messages = forwardRef<HTMLDivElement, MessagesProps>(
|
||||||
@ -100,6 +103,8 @@ export const Messages = forwardRef<HTMLDivElement, MessagesProps>(
|
|||||||
append={props.append}
|
append={props.append}
|
||||||
chatMode={props.chatMode}
|
chatMode={props.chatMode}
|
||||||
setChatMode={props.setChatMode}
|
setChatMode={props.setChatMode}
|
||||||
|
model={props.model}
|
||||||
|
provider={props.provider}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user