feat: add discuss mode and quick actions
- Implement discuss mode toggle and UI in chat box - Add quick action buttons for file, message, implement and link actions - Extend markdown parser to handle quick action elements - Update message components to support discuss mode and quick actions - Add discuss prompt for technical consulting responses - Refactor chat components to support new functionality The changes introduce a new discuss mode that allows users to switch between code implementation and technical discussion modes. Quick action buttons provide immediate interaction options like opening files, sending messages, or switching modes.
This commit is contained in:
@@ -8,6 +8,7 @@ import { allowedHTMLElements } from '~/utils/markdown';
|
||||
import { LLMManager } from '~/lib/modules/llm/manager';
|
||||
import { createScopedLogger } from '~/utils/logger';
|
||||
import { createFilesContext, extractPropertiesFromMessage } from './utils';
|
||||
import { discussPrompt } from '~/lib/common/prompts/discuss-prompt';
|
||||
|
||||
export type Messages = Message[];
|
||||
|
||||
@@ -36,6 +37,7 @@ export async function streamText(props: {
|
||||
contextFiles?: FileMap;
|
||||
summary?: string;
|
||||
messageSliceId?: number;
|
||||
chatMode?: 'discuss' | 'build';
|
||||
}) {
|
||||
const {
|
||||
messages,
|
||||
@@ -48,6 +50,7 @@ export async function streamText(props: {
|
||||
contextOptimization,
|
||||
contextFiles,
|
||||
summary,
|
||||
chatMode,
|
||||
} = props;
|
||||
let currentModel = DEFAULT_MODEL;
|
||||
let currentProvider = DEFAULT_PROVIDER.name;
|
||||
@@ -124,26 +127,26 @@ export async function streamText(props: {
|
||||
},
|
||||
}) ?? getSystemPrompt();
|
||||
|
||||
if (contextFiles && contextOptimization) {
|
||||
if (chatMode === 'build' && contextFiles && contextOptimization) {
|
||||
const codeContext = createFilesContext(contextFiles, true);
|
||||
|
||||
systemPrompt = `${systemPrompt}
|
||||
|
||||
Below is the artifact containing the context loaded into context buffer for you to have knowledge of and might need changes to fullfill current user request.
|
||||
CONTEXT BUFFER:
|
||||
---
|
||||
${codeContext}
|
||||
---
|
||||
`;
|
||||
Below is the artifact containing the context loaded into context buffer for you to have knowledge of and might need changes to fullfill current user request.
|
||||
CONTEXT BUFFER:
|
||||
---
|
||||
${codeContext}
|
||||
---
|
||||
`;
|
||||
|
||||
if (summary) {
|
||||
systemPrompt = `${systemPrompt}
|
||||
below is the chat history till now
|
||||
CHAT SUMMARY:
|
||||
---
|
||||
${props.summary}
|
||||
---
|
||||
`;
|
||||
CHAT SUMMARY:
|
||||
---
|
||||
${props.summary}
|
||||
---
|
||||
`;
|
||||
|
||||
if (props.messageSliceId) {
|
||||
processedMessages = processedMessages.slice(props.messageSliceId);
|
||||
@@ -173,10 +176,10 @@ ${props.summary}
|
||||
.join('\n');
|
||||
systemPrompt = `${systemPrompt}
|
||||
|
||||
IMPORTANT: The following files are locked and MUST NOT be modified in any way. Do not suggest or make any changes to these files. You can proceed with the request but DO NOT make any changes to these files specifically:
|
||||
${lockedFilesListString}
|
||||
---
|
||||
`;
|
||||
IMPORTANT: The following files are locked and MUST NOT be modified in any way. Do not suggest or make any changes to these files. You can proceed with the request but DO NOT make any changes to these files specifically:
|
||||
${lockedFilesListString}
|
||||
---
|
||||
`;
|
||||
} else {
|
||||
console.log('No locked files found from any source for prompt.');
|
||||
}
|
||||
@@ -192,7 +195,7 @@ ${lockedFilesListString}
|
||||
apiKeys,
|
||||
providerSettings,
|
||||
}),
|
||||
system: systemPrompt,
|
||||
system: chatMode === 'build' ? systemPrompt : discussPrompt(),
|
||||
maxTokens: dynamicMaxTokens,
|
||||
messages: convertToCoreMessages(processedMessages as any),
|
||||
...options,
|
||||
|
||||
Reference in New Issue
Block a user