improved system message to avoid model defaulting to "file.ts" or "file.py" when writing code blocks

This commit is contained in:
Nate 2025-03-12 11:01:35 -07:00
parent 9d7510578b
commit 085f157388
2 changed files with 9 additions and 6 deletions

View file

@ -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 = `<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.
</tool_use_rules>`;
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 = `<important_rules>
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'.
</important_rules>`;
if (useTools && modelSupportsTools(modelDescription)) {
systemMessage += "\n\n" + TOOL_USE_RULES;
}

View file

@ -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",