build ask mode (#444)
This commit is contained in:
@@ -347,6 +347,7 @@ ${componentSnippet}
|
||||
|
||||
let systemPrompt = constructSystemPrompt({
|
||||
aiRules: await readAiRules(getDyadAppPath(updatedChat.app.path)),
|
||||
chatMode: settings.selectedChatMode,
|
||||
});
|
||||
if (
|
||||
updatedChat.app?.supabaseProjectId &&
|
||||
@@ -410,7 +411,10 @@ This conversation includes one or more image attachments. When the user uploads
|
||||
// Why remove thinking tags?
|
||||
// Thinking tags are generally not critical for the context
|
||||
// and eats up extra tokens.
|
||||
content: removeThinkingTags(msg.content),
|
||||
content:
|
||||
settings.selectedChatMode === "ask"
|
||||
? removeDyadTags(removeThinkingTags(msg.content))
|
||||
: removeThinkingTags(msg.content),
|
||||
})),
|
||||
];
|
||||
|
||||
@@ -608,8 +612,11 @@ This conversation includes one or more image attachments. When the user uploads
|
||||
.update(messages)
|
||||
.set({ content: fullResponse })
|
||||
.where(eq(messages.id, placeholderAssistantMessage.id));
|
||||
|
||||
if (readSettings().autoApproveChanges) {
|
||||
const settings = readSettings();
|
||||
if (
|
||||
settings.autoApproveChanges &&
|
||||
settings.selectedChatMode !== "ask"
|
||||
) {
|
||||
const status = await processFullResponseActions(
|
||||
fullResponse,
|
||||
req.chatId,
|
||||
@@ -820,3 +827,8 @@ function removeThinkingTags(text: string): string {
|
||||
const thinkRegex = /<think>([\s\S]*?)<\/think>/g;
|
||||
return text.replace(thinkRegex, "").trim();
|
||||
}
|
||||
|
||||
export function removeDyadTags(text: string): string {
|
||||
const dyadRegex = /<dyad-[^>]*>[\s\S]*?<\/dyad-[^>]*>/g;
|
||||
return text.replace(dyadRegex, "").trim();
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import { withLock } from "../utils/lock_utils";
|
||||
import { createLoggedHandler } from "./safe_handle";
|
||||
import { ApproveProposalResult } from "../ipc_types";
|
||||
import { validateChatContext } from "../utils/context_paths_utils";
|
||||
import { readSettings } from "@/main/settings";
|
||||
|
||||
const logger = log.scope("proposal_handlers");
|
||||
const handle = createLoggedHandler(logger);
|
||||
@@ -333,6 +334,12 @@ const approveProposalHandler = async (
|
||||
_event: IpcMainInvokeEvent,
|
||||
{ chatId, messageId }: { chatId: number; messageId: number },
|
||||
): Promise<ApproveProposalResult> => {
|
||||
const settings = readSettings();
|
||||
if (settings.selectedChatMode === "ask") {
|
||||
throw new Error(
|
||||
"Ask mode is not supported for proposal approval. Please switch to build mode.",
|
||||
);
|
||||
}
|
||||
// 1. Fetch the specific assistant message
|
||||
const messageToApprove = await db.query.messages.findFirst({
|
||||
where: and(
|
||||
|
||||
@@ -19,6 +19,7 @@ import { TokenCountResult } from "../ipc_types";
|
||||
import { estimateTokens, getContextWindow } from "../utils/token_utils";
|
||||
import { createLoggedHandler } from "./safe_handle";
|
||||
import { validateChatContext } from "../utils/context_paths_utils";
|
||||
import { readSettings } from "@/main/settings";
|
||||
|
||||
const logger = log.scope("token_count_handlers");
|
||||
|
||||
@@ -51,9 +52,11 @@ export function registerTokenCountHandlers() {
|
||||
// Count input tokens
|
||||
const inputTokens = estimateTokens(req.input);
|
||||
|
||||
const settings = readSettings();
|
||||
// Count system prompt tokens
|
||||
let systemPrompt = constructSystemPrompt({
|
||||
aiRules: await readAiRules(getDyadAppPath(chat.app.path)),
|
||||
chatMode: settings.selectedChatMode,
|
||||
});
|
||||
let supabaseContext = "";
|
||||
|
||||
|
||||
@@ -116,7 +116,10 @@ export async function getModelClient(
|
||||
baseURL: dyadEngineUrl ?? "https://engine.dyad.sh/v1",
|
||||
originalProviderId: model.provider,
|
||||
dyadOptions: {
|
||||
enableLazyEdits: settings.enableProLazyEditsMode,
|
||||
enableLazyEdits:
|
||||
settings.selectedChatMode === "ask"
|
||||
? false
|
||||
: settings.enableProLazyEditsMode,
|
||||
enableSmartFilesContext: settings.enableProSmartFilesContextMode,
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user