Merge pull request #3177 from continuedev/pe/sys-msg-updates

feat: use lazy edit sys msg for `gpt-4o` and `mistral-large` families
This commit is contained in:
Nate Sesti 2024-12-03 21:12:32 -08:00 • committed by GitHub
commit c2caf8529b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,7 +1,10 @@
import { ChatHistoryItem, ChatMessage, MessagePart } from "../index.js";
import { normalizeToMessageParts } from "../util/messageContent.js";
import { modelSupportsTools } from "./autodetect.js";
const CUSTOM_SYS_MSG_MODEL_FAMILIES = ["sonnet", "gpt-4o", "mistral-large"];
const SYSTEM_MESSAGE = `When generating new code:
1. Always produce a single code block.
@ -64,7 +67,7 @@ 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(model: string): string | null {
if (model.includes("sonnet")) {
if (CUSTOM_SYS_MSG_MODEL_FAMILIES.some((family) => model.includes(family))) {
return SYSTEM_MESSAGE + "\n\n" + TOOL_USE_RULES;
}
if (modelSupportsTools(model)) {