From 085f15738866a3616fdb78360a5cb22776f38ce5 Mon Sep 17 00:00:00 2001 From: Nate Date: Wed, 12 Mar 2025 11:01:35 -0700 Subject: [PATCH] improved system message to avoid model defaulting to "file.ts" or "file.py" when writing code blocks --- core/llm/constructMessages.ts | 11 +++++++---- extensions/vscode/package-lock.json | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/core/llm/constructMessages.ts b/core/llm/constructMessages.ts index 0e4533ceb..a80a4a72b 100644 --- a/core/llm/constructMessages.ts +++ b/core/llm/constructMessages.ts @@ -8,15 +8,18 @@ import { normalizeToMessageParts } from "../util/messageContent"; import { modelSupportsTools } from "./autodetect"; -const TOOL_USE_RULES = `When using tools, follow the following guidelines: -- Avoid calling tools unless they are absolutely necessary. For example, if you are asked a simple programming question you do not need web search. As another example, if the user asks you to explain something about code, do not create a new file.`; +const TOOL_USE_RULES = ` + When using tools, follow the following guidelines: + - Avoid calling tools unless they are absolutely necessary. For example, if you are asked a simple programming question you do not need web search. As another example, if the user asks you to explain something about code, do not create a new file. +`; function constructSystemPrompt( modelDescription: ModelDescription, useTools: boolean, ): string | null { - let systemMessage = - "Always include the language and file name in the info string when you write code blocks, for example '```python file.py'."; + let systemMessage = ` + Always include the language and file name in the info string when you write code blocks. If you are editing "src/main.py" for example, your code block should start with '\`\`\`python src/main.py'. +`; if (useTools && modelSupportsTools(modelDescription)) { systemMessage += "\n\n" + TOOL_USE_RULES; } diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 5f7702aee..dc6465ddd 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "1.1.7", + "version": "1.1.8", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "1.1.7", + "version": "1.1.8", "license": "Apache-2.0", "dependencies": { "@continuedev/fetch": "^1.0.3",