From 3a69bf4b2ad9114389322890705f0e31e03d8fa0 Mon Sep 17 00:00:00 2001 From: Will Chen Date: Wed, 23 Apr 2025 14:55:30 -0700 Subject: [PATCH] Make messages clearer with codebase context (#8) --- src/ipc/handlers/chat_stream_handlers.ts | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/ipc/handlers/chat_stream_handlers.ts b/src/ipc/handlers/chat_stream_handlers.ts index 04458ee..a40de37 100644 --- a/src/ipc/handlers/chat_stream_handlers.ts +++ b/src/ipc/handlers/chat_stream_handlers.ts @@ -148,24 +148,11 @@ export function registerChatStreamHandlers() { codebaseInfo.length / 4 ); - // Append codebase information to the user's prompt if available - const userPrompt = codebaseInfo - ? `${req.prompt}\n\nHere's the codebase:\n${codebaseInfo}` - : req.prompt; - // Prepare message history for the AI const messageHistory = updatedChat.messages.map((message) => ({ role: message.role as "user" | "assistant" | "system", content: message.content, })); - - // Remove the last user message (we'll replace it with our enhanced version) - if ( - messageHistory.length > 0 && - messageHistory[messageHistory.length - 1].role === "user" - ) { - messageHistory.pop(); - } let systemPrompt = SYSTEM_PROMPT; if (readSettings().experiments?.enableSupabaseIntegration) { if (updatedChat.app?.supabaseProjectId) { @@ -186,12 +173,15 @@ export function registerChatStreamHandlers() { model: modelClient, system: systemPrompt, messages: [ - ...messageHistory, - // Add the enhanced user prompt { role: "user", - content: userPrompt, + content: "This is my codebase. " + codebaseInfo, }, + { + role: "assistant", + content: "OK, got it. I'm ready to help", + }, + ...messageHistory, ], onError: (error) => { logger.error("Error streaming text:", error);