diff --git a/core/index.d.ts b/core/index.d.ts index f02e38e6f..f38cd4d3e 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -492,7 +492,8 @@ type TemplateType = | "neural-chat" | "codellama-70b" | "llava" - | "gemma"; + | "gemma" + | "llama3"; type ModelProvider = | "openai" diff --git a/core/llm/autodetect.ts b/core/llm/autodetect.ts index 882f7efa5..76185b657 100644 --- a/core/llm/autodetect.ts +++ b/core/llm/autodetect.ts @@ -6,6 +6,7 @@ import { deepseekTemplateMessages, gemmaTemplateMessage, llama2TemplateMessages, + llama3TemplateMessages, llavaTemplateMessages, neuralChatTemplateMessages, openchatTemplateMessages, @@ -22,6 +23,7 @@ import { deepseekEditPrompt, gemmaEditPrompt, gptEditPrompt, + llama3EditPrompt, mistralEditPrompt, neuralChatEditPrompt, openchatEditPrompt, @@ -124,6 +126,10 @@ function autodetectTemplateType(model: string): TemplateType | undefined { return undefined; } + if (lower.includes("llama3")) { + return "llama3"; + } + if (lower.includes("llava")) { return "llava"; } @@ -218,6 +224,7 @@ function autodetectTemplateFunction( llava: llavaTemplateMessages, "codellama-70b": codeLlama70bTemplateMessages, gemma: gemmaTemplateMessage, + llama3: llama3TemplateMessages, none: null, }; @@ -241,6 +248,7 @@ const USES_OS_MODELS_EDIT_PROMPT: TemplateType[] = [ "phind", "xwin-coder", "zephyr", + "llama3", ]; function autodetectPromptTemplates( @@ -284,6 +292,8 @@ function autodetectPromptTemplates( editTemplate = claudeEditPrompt; } else if (templateType === "gemma") { editTemplate = gemmaEditPrompt; + } else if (templateType === "llama3") { + editTemplate = llama3EditPrompt; } else if (templateType === "none") { editTemplate = null; } else if (templateType) { diff --git a/core/llm/templates/chat.ts b/core/llm/templates/chat.ts index cb39f8827..a4f12771c 100644 --- a/core/llm/templates/chat.ts +++ b/core/llm/templates/chat.ts @@ -254,6 +254,14 @@ function codeLlama70bTemplateMessages(msgs: ChatMessage[]): string { return prompt; } +const llama3TemplateMessages = templateFactory( + (msg: ChatMessage) => + `<|begin_of_text|><|start_header_id|>${msg.role}<|end_header_id|>\n${msg.content}<|eot_id|>\n`, + "<|start_header_id|>user<|end_header_id|>\n", + "<|start_header_id|>assistant<|end_header_id|>\n", + "<|eot_id|>", +); + /** user What is Cramer's Rule? @@ -273,6 +281,7 @@ export { deepseekTemplateMessages, gemmaTemplateMessage, llama2TemplateMessages, + llama3TemplateMessages, llavaTemplateMessages, neuralChatTemplateMessages, openchatTemplateMessages, diff --git a/core/llm/templates/edit.ts b/core/llm/templates/edit.ts index 188ff0966..26ee44a74 100644 --- a/core/llm/templates/edit.ts +++ b/core/llm/templates/edit.ts @@ -259,6 +259,15 @@ Output only a code block with the rewritten code: }, ]; +const llama3EditPrompt: PromptTemplate = `<|begin_of_text|><|start_header_id|>user<|end_header_id|> +\`\`\`{{{language}}} +{{{codeToEdit}}} +\`\`\` + +Rewrite the above code to satisfy this request: "{{{userInput}}}"<|eot_id|><|start_header_id|>assistant<|end_header_id|> +Sure! Here's the code you requested: +\`\`\`{{{language}}}`; + const gemmaEditPrompt = `user You are an expert programmer and write code on the first attempt without any errors or fillers. Rewrite the code to satisfy this request: "{{{userInput}}}" @@ -279,6 +288,7 @@ export { deepseekEditPrompt, gemmaEditPrompt, gptEditPrompt, + llama3EditPrompt, mistralEditPrompt, neuralChatEditPrompt, openchatEditPrompt, diff --git a/docs/static/schemas/config.json b/docs/static/schemas/config.json index 09321f64c..1e6522519 100644 --- a/docs/static/schemas/config.json +++ b/docs/static/schemas/config.json @@ -209,7 +209,8 @@ "neural-chat", "codellama-70b", "llava", - "gemma" + "gemma", + "llama3" ], "type": "string" }, diff --git a/extensions/intellij/src/main/resources/config_schema.json b/extensions/intellij/src/main/resources/config_schema.json index 09321f64c..1e6522519 100644 --- a/extensions/intellij/src/main/resources/config_schema.json +++ b/extensions/intellij/src/main/resources/config_schema.json @@ -209,7 +209,8 @@ "neural-chat", "codellama-70b", "llava", - "gemma" + "gemma", + "llama3" ], "type": "string" }, diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index 09321f64c..1e6522519 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -209,7 +209,8 @@ "neural-chat", "codellama-70b", "llava", - "gemma" + "gemma", + "llama3" ], "type": "string" }, diff --git a/extensions/vscode/continue_rc_schema.json b/extensions/vscode/continue_rc_schema.json index c0d4f10fe..6b3d420d3 100644 --- a/extensions/vscode/continue_rc_schema.json +++ b/extensions/vscode/continue_rc_schema.json @@ -209,7 +209,8 @@ "neural-chat", "codellama-70b", "llava", - "gemma" + "gemma", + "llama3" ], "type": "string" },