From e26da7a8be8ecca2a2b6a95f9312be13f68aa9b9 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Thu, 23 May 2024 17:37:22 -0700 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Use=20gptEditPrompt=20for?= =?UTF-8?q?=20Mistral?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/config/default.ts | 10 + core/config/onboarding.ts | 5 + core/index.d.ts | 10 +- core/llm/autodetect.ts | 1 + core/llm/index.ts | 10 +- core/llm/llms/FreeTrial.ts | 1 + core/llm/llms/Mistral.ts | 27 +- core/llm/llms/Together.ts | 9 +- docs/docs/walkthroughs/tab-autocomplete.md | 11 +- docs/static/schemas/config.json | 2 +- .../src/main/resources/config_schema.json | 2 +- extensions/vscode/config_schema.json | 2 +- extensions/vscode/continue_rc_schema.json | 2 +- gui/src/util/modelData.ts | 245 ++++++++++-------- 14 files changed, 201 insertions(+), 136 deletions(-) diff --git a/core/config/default.ts b/core/config/default.ts index 3fffb9499..25b265228 100644 --- a/core/config/default.ts +++ b/core/config/default.ts @@ -5,6 +5,11 @@ import { export const defaultConfig: SerializedContinueConfig = { models: [ + // { + // title: "Codestral (Free Trial)", + // provider: "free-trial", + // model: "codestral", + // }, { title: "GPT-4o (Free Trial)", provider: "free-trial", @@ -42,6 +47,11 @@ export const defaultConfig: SerializedContinueConfig = { export const defaultConfigJetBrains: SerializedContinueConfig = { models: [ + // { + // title: "Codestral (Free Trial)", + // provider: "free-trial", + // model: "codestral", + // }, { title: "GPT-4o (Free Trial)", provider: "free-trial", diff --git a/core/config/onboarding.ts b/core/config/onboarding.ts index 4dd94e0c2..5c4891ad5 100644 --- a/core/config/onboarding.ts +++ b/core/config/onboarding.ts @@ -6,6 +6,11 @@ export function setupOptimizedMode( return { ...config, models: [ + // { + // title: "Codestral (Free Trial)", + // provider: "free-trial", + // model: "codestral", + // }, { title: "GPT-4o (Free Trial)", provider: "free-trial", diff --git a/core/index.d.ts b/core/index.d.ts index cf658496c..6157ed3c6 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -58,7 +58,7 @@ export interface ILLM extends LLMOptions { contextLength: number; completionOptions: CompletionOptions; requestOptions?: RequestOptions; - promptTemplates?: Record; + promptTemplates?: Record; templateMessages?: (messages: ChatMessage[]) => string; writeLog?: (str: string) => Promise; llmRequestHook?: (model: string, prompt: string) => any; @@ -287,7 +287,7 @@ export interface LLMOptions { completionOptions?: CompletionOptions; requestOptions?: RequestOptions; template?: TemplateType; - promptTemplates?: Record; + promptTemplates?: Record; templateMessages?: (messages: ChatMessage[]) => string; writeLog?: (str: string) => Promise; llmRequestHook?: (model: string, prompt: string) => any; @@ -544,6 +544,12 @@ export type ModelName = | "gpt-4-turbo-preview" | "gpt-4-vision-preview" // Mistral + | "codestral-latest" + | "open-mistral-7b" + | "open-mixtral-8x7b" + | "open-mixtral-8x22b" + | "mistral-small-latest" + | "mistral-large-latest" | "mistral-7b" | "mistral-8x7b" // Llama 2 diff --git a/core/llm/autodetect.ts b/core/llm/autodetect.ts index a94345cf2..66f0217d0 100644 --- a/core/llm/autodetect.ts +++ b/core/llm/autodetect.ts @@ -42,6 +42,7 @@ const PROVIDER_HANDLES_TEMPLATING: ModelProvider[] = [ "anthropic", "bedrock", "continue-proxy", + "mistral", ]; const PROVIDER_SUPPORTS_IMAGES: ModelProvider[] = [ diff --git a/core/llm/index.ts b/core/llm/index.ts index 620426cd4..9d06370ae 100644 --- a/core/llm/index.ts +++ b/core/llm/index.ts @@ -55,21 +55,23 @@ export abstract class BaseLLM implements ILLM { if (this.providerName === "openai") { if ( this.apiBase?.includes("api.groq.com") || + this.apiBase?.includes("api.mistral.ai") || this.apiBase?.includes(":1337") || this._llmOptions.useLegacyCompletionsEndpoint?.valueOf() === false ) { - // Jan + Groq don't support completions : ( + // Jan + Groq + Mistral don't support completions : ( + // Seems to be going out of style... return false; } } - if (this.providerName === "groq") { + if (["groq", "mistral"].includes(this.providerName)) { return false; } return true; } supportsPrefill(): boolean { - return ["ollama", "anthropic"].includes(this.providerName); + return ["ollama", "anthropic", "mistral"].includes(this.providerName); } uniqueId: string; @@ -81,7 +83,7 @@ export abstract class BaseLLM implements ILLM { completionOptions: CompletionOptions; requestOptions?: RequestOptions; template?: TemplateType; - promptTemplates?: Record; + promptTemplates?: Record; templateMessages?: (messages: ChatMessage[]) => string; writeLog?: (str: string) => Promise; llmRequestHook?: (model: string, prompt: string) => any; diff --git a/core/llm/llms/FreeTrial.ts b/core/llm/llms/FreeTrial.ts index cd375d18f..db4414394 100644 --- a/core/llm/llms/FreeTrial.ts +++ b/core/llm/llms/FreeTrial.ts @@ -125,6 +125,7 @@ class FreeTrial extends BaseLLM { async listModels(): Promise { return [ + // "codestral-latest", "llama3-70b", "gpt-4o", "gpt-3.5-turbo", diff --git a/core/llm/llms/Mistral.ts b/core/llm/llms/Mistral.ts index 5ff9f20dd..5712c68f1 100644 --- a/core/llm/llms/Mistral.ts +++ b/core/llm/llms/Mistral.ts @@ -1,12 +1,35 @@ -import { LLMOptions, ModelProvider } from "../../index.js"; +import { ChatMessage, LLMOptions, ModelProvider } from "../../index.js"; +import { gptEditPrompt } from "../templates/edit.js"; import OpenAI from "./OpenAI.js"; class Mistral extends OpenAI { static providerName: ModelProvider = "mistral"; static defaultOptions: Partial = { apiBase: "https://api.mistral.ai/v1/", - model: "mistral-small", + model: "codestral-latest", + promptTemplates: { + edit: gptEditPrompt, + }, }; + + private static modelConversion: { [key: string]: string } = { + "mistral-7b": "open-mistral-7b", + "mistral-8x7b": "open-mixtral-8x7b", + }; + protected _convertModelName(model: string): string { + return Mistral.modelConversion[model] ?? model; + } + + protected _convertArgs(options: any, messages: ChatMessage[]) { + const finalOptions = super._convertArgs(options, messages); + + const lastMessage = finalOptions.messages[finalOptions.messages.length - 1]; + if (lastMessage.role === "assistant") { + (lastMessage as any).prefix = true; + } + + return finalOptions; + } } export default Mistral; diff --git a/core/llm/llms/Together.ts b/core/llm/llms/Together.ts index 6f254036d..277389c77 100644 --- a/core/llm/llms/Together.ts +++ b/core/llm/llms/Together.ts @@ -1,5 +1,4 @@ import type { - ChatMessage, CompletionOptions, LLMOptions, ModelProvider, @@ -29,16 +28,10 @@ class Together extends OpenAI { "wizardcoder-34b": "WizardLM/WizardCoder-Python-34B-V1.0", }; - private _getModelName(model: string) { + protected _convertModelName(model: string) { return Together.MODEL_IDS[model] || this.model; } - protected _convertArgs(options: any, messages: ChatMessage[]) { - const finalOptions = super._convertArgs(options, messages); - finalOptions.model = this._getModelName(options.model); - return finalOptions; - } - protected async *_streamComplete( prompt: string, options: CompletionOptions, diff --git a/docs/docs/walkthroughs/tab-autocomplete.md b/docs/docs/walkthroughs/tab-autocomplete.md index 127331a5c..05e8df148 100644 --- a/docs/docs/walkthroughs/tab-autocomplete.md +++ b/docs/docs/walkthroughs/tab-autocomplete.md @@ -2,17 +2,16 @@ Continue now provides support for tab autocomplete in [VS Code](https://marketplace.visualstudio.com/items?itemName=Continue.continue) and [JetBrains IDEs](https://plugins.jetbrains.com/plugin/22707-continue/edit). We will be greatly improving the experience over the next few releases, and it is always helpful to hear feedback. If you have any problems or suggestions, please let us know in our [Discord](https://discord.gg/vapESyrFmJ). -## Setting up with Starcoder 7b (recommended) +## Setting up with Codestral (recommended) -If you want to have the best autocomplete experience, we recommend using Starcoder 7b, which is available through [Fireworks AI](https://fireworks.ai/models/fireworks/starcoder-7b). To do this, obtain an API key and add it to your `config.json`: +If you want to have the best autocomplete experience, we recommend using Codestral, which is available through the [Mistral API](https://console.mistral.ai/). To do this, obtain an API key and add it to your `config.json`: ```json { "tabAutocompleteModel": { - "title": "Starcoder 7b", - "provider": "openai", - "model": "accounts/fireworks/models/starcoder-7b", - "apiBase": "https://api.fireworks.ai/inference/v1", + "title": "Codestral", + "provider": "mistral", + "model": "codestral-latest", "apiKey": "YOUR_API_KEY" } } diff --git a/docs/static/schemas/config.json b/docs/static/schemas/config.json index 80268de2b..41e5bd0dd 100644 --- a/docs/static/schemas/config.json +++ b/docs/static/schemas/config.json @@ -790,11 +790,11 @@ "properties": { "model": { "enum": [ + "codestral-latest", "open-mistral-7b", "open-mixtral-8x7b", "open-mixtral-8x22b", "mistral-small-latest", - "mistral-medium-latest", "mistral-large-latest" ] } diff --git a/extensions/intellij/src/main/resources/config_schema.json b/extensions/intellij/src/main/resources/config_schema.json index 80268de2b..41e5bd0dd 100644 --- a/extensions/intellij/src/main/resources/config_schema.json +++ b/extensions/intellij/src/main/resources/config_schema.json @@ -790,11 +790,11 @@ "properties": { "model": { "enum": [ + "codestral-latest", "open-mistral-7b", "open-mixtral-8x7b", "open-mixtral-8x22b", "mistral-small-latest", - "mistral-medium-latest", "mistral-large-latest" ] } diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index 80268de2b..41e5bd0dd 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -790,11 +790,11 @@ "properties": { "model": { "enum": [ + "codestral-latest", "open-mistral-7b", "open-mixtral-8x7b", "open-mixtral-8x22b", "mistral-small-latest", - "mistral-medium-latest", "mistral-large-latest" ] } diff --git a/extensions/vscode/continue_rc_schema.json b/extensions/vscode/continue_rc_schema.json index 0d807a8c1..31d93491d 100644 --- a/extensions/vscode/continue_rc_schema.json +++ b/extensions/vscode/continue_rc_schema.json @@ -867,11 +867,11 @@ "properties": { "model": { "enum": [ + "codestral-latest", "open-mistral-7b", "open-mixtral-8x7b", "open-mixtral-8x22b", "mistral-small-latest", - "mistral-medium-latest", "mistral-large-latest" ] } diff --git a/gui/src/util/modelData.ts b/gui/src/util/modelData.ts index 0c59b53f0..8e5f031c7 100644 --- a/gui/src/util/modelData.ts +++ b/gui/src/util/modelData.ts @@ -345,10 +345,10 @@ const phindCodeLlama: ModelPackage = { providerOptions: ["ollama", "lmstudio", "llamacpp", "replicate", "freetrial"], }; -const mistral: ModelPackage = { - title: "Mistral (7b)", +const mistralOs: ModelPackage = { + title: "Mistral", description: - "A 7b parameter base model created by Mistral AI, very competent for code generation and other tasks", + "A series of open-weight models created by Mistral AI, highly competent for code generation and other tasks", params: { title: "Mistral", model: "mistral-7b", @@ -374,60 +374,76 @@ const mistral: ModelPackage = { providerOptions: ["ollama", "lmstudio", "together", "llamacpp", "replicate"], }; -const mistralTiny: ModelPackage = { - title: "Mistral Tiny (7b)", - description: "An 7b parameter model created by Mistral AI", +const codestral: ModelPackage = { + title: "Codestral", + description: "", params: { - title: "Mistral", - model: "mistral-tiny", - contextLength: 4096, + title: "Codestral", + model: "codestral-latest", + contextLength: 32000, }, icon: "mistral.png", - providerOptions: [ - "ollama", - "lmstudio", - "together", - "llamacpp", - "replicate", - "mistral", - ], + providerOptions: ["mistral"], +}; +const mistral7b: ModelPackage = { + title: "Mistral 7B", + description: + "The first dense model released by Mistral AI, perfect for experimentation, customization, and quick iteration. At the time of the release, it matched the capabilities of models up to 30B parameters.", + params: { + title: "Mistral 7B", + model: "open-mistral-7b", + contextLength: 32000, + }, + icon: "mistral.png", + providerOptions: ["mistral"], +}; +const mistral8x7b: ModelPackage = { + title: "Mixtral 8x7B", + description: + "A sparse mixture of experts model. As such, it leverages up to 45B parameters but only uses about 12B during inference, leading to better inference throughput at the cost of more vRAM.", + params: { + title: "Mixtral 8x7B", + model: "open-mixtral-8x7b", + contextLength: 32000, + }, + icon: "mistral.png", + providerOptions: ["mistral"], +}; +const mistral8x22b: ModelPackage = { + title: "Mistral 8x22B", + description: + "A bigger sparse mixture of experts model. As such, it leverages up to 141B parameters but only uses about 39B during inference, leading to better inference throughput at the cost of more vRAM.", + params: { + title: "Mistral 8x22B", + model: "open-mixtral-8x22b", + contextLength: 64000, + }, + icon: "mistral.png", + providerOptions: ["mistral"], }; const mistralSmall: ModelPackage = { - title: "Mixtral (8x7b)", + title: "Mistral Small", description: - "An 8x7b parameter Mixture of Experts model created by Mistral AI (a.k.a Mistral Small)", + "Suitable for simple tasks that one can do in bulk (Classification, Customer Support, or Text Generation)", params: { - title: "Mixtral", - model: "mistral-small", - contextLength: 4096, + title: "Mistral Small", + model: "mistral-small-latest", + contextLength: 32000, }, icon: "mistral.png", - providerOptions: [ - "ollama", - "lmstudio", - "together", - "llamacpp", - "replicate", - "mistral", - ], + providerOptions: ["mistral"], }; -const mistralMedium: ModelPackage = { - title: "Mistral Medium", - description: "A highly capable model created by Mistral AI", +const mistralLarge: ModelPackage = { + title: "Mistral Large", + description: + "Mistral's flagship model that's ideal for complex tasks that require large reasoning capabilities or are highly specialized (Synthetic Text Generation, Code Generation, RAG, or Agents).", params: { - title: "Mistral Medium", - model: "mistral-medium", - contextLength: 4096, + title: "Mistral Large", + model: "mistral-large-latest", + contextLength: 32000, }, icon: "mistral.png", - providerOptions: [ - "ollama", - "lmstudio", - "together", - "llamacpp", - "replicate", - "mistral", - ], + providerOptions: ["mistral"], }; const geminiPro: ModelPackage = { @@ -534,7 +550,7 @@ const osModels = [ deepseek, wizardCoder, codeLlamaInstruct, - mistral, + mistralOs, phindCodeLlama, ]; @@ -660,13 +676,18 @@ export const MODEL_INFO: (ModelPackage | string)[] = [ "OpenAI", gpt4o, gpt4turbo, - // gpt4, gpt35turbo, "Anthropic", claude3Opus, claude3Sonnet, claude3Haiku, - // claude2, + "Mistral", + codestral, + mistralLarge, + mistralSmall, + mistral8x22b, + mistral8x7b, + mistral7b, "Cohere", commandR, commandRPlus, @@ -675,9 +696,9 @@ export const MODEL_INFO: (ModelPackage | string)[] = [ geminiPro, gemini15Flash, "Open Source", + mistralOs, llama3Chat, deepseek, - mistral, // wizardCoder, // codeLlamaInstruct, // phindCodeLlama, @@ -747,27 +768,38 @@ export const PROVIDER_INFO: { [key: string]: ModelInfo } = { // claude2 ], }, - cohere: { - title: "Cohere", - provider: "cohere", - refPage: "cohere", + mistral: { + title: "Mistral API", + provider: "mistral", description: - "Optimized for enterprise generative AI, search and discovery, and advanced retrieval.", - icon: "cohere.png", - tags: [ModelProviderTag["Requires API Key"]], - longDescription: - "To use Cohere, visit the [Cohere dashboard](https://dashboard.cohere.com/api-keys) to create an API key.", + "The Mistral API provides seamless access to their models, including Codestral, Mistral 8x22B, Mistral Large, and more.", + icon: "mistral.png", + longDescription: `To get access to the Mistral API, obtain your API key from the [Mistral platform](https://docs.mistral.ai/)`, + tags: [ + ModelProviderTag["Requires API Key"], + ModelProviderTag["Open-Source"], + ], + params: { + apiKey: "", + }, collectInputFor: [ { inputType: CollectInputType.text, key: "apiKey", label: "API Key", - placeholder: "Enter your Cohere API key", + placeholder: "Enter your Mistral API key", required: true, }, ...completionParamsInputs, ], - packages: [commandR, commandRPlus], + packages: [ + codestral, + mistralLarge, + mistralSmall, + mistral8x22b, + mistral8x7b, + mistral7b, + ], }, ollama: { title: "Ollama", @@ -793,35 +825,27 @@ export const PROVIDER_INFO: { [key: string]: ModelInfo } = { { ...apiBaseInput, defaultValue: "http://localhost:11434" }, ], }, - together: { - title: "TogetherAI", - provider: "together", - refPage: "togetherllm", + cohere: { + title: "Cohere", + provider: "cohere", + refPage: "cohere", description: - "Use the TogetherAI API for extremely fast streaming of open-source models", - icon: "together.png", - longDescription: `Together is a hosted service that provides extremely fast streaming of open-source language models. To get started with Together:\n1. Obtain an API key from [here](https://together.ai)\n2. Paste below\n3. Select a model preset`, - tags: [ - ModelProviderTag["Requires API Key"], - ModelProviderTag["Open-Source"], - ], - params: { - apiKey: "", - }, + "Optimized for enterprise generative AI, search and discovery, and advanced retrieval.", + icon: "cohere.png", + tags: [ModelProviderTag["Requires API Key"]], + longDescription: + "To use Cohere, visit the [Cohere dashboard](https://dashboard.cohere.com/api-keys) to create an API key.", collectInputFor: [ { inputType: CollectInputType.text, key: "apiKey", label: "API Key", - placeholder: "Enter your TogetherAI API key", + placeholder: "Enter your Cohere API key", required: true, }, ...completionParamsInputs, ], - packages: [llama3Chat, codeLlamaInstruct, mistral].map((p) => { - p.params.contextLength = 4096; - return p; - }), + packages: [commandR, commandRPlus], }, groq: { title: "Groq", @@ -859,6 +883,36 @@ export const PROVIDER_INFO: { [key: string]: ModelInfo } = { , ], }, + together: { + title: "TogetherAI", + provider: "together", + refPage: "togetherllm", + description: + "Use the TogetherAI API for extremely fast streaming of open-source models", + icon: "together.png", + longDescription: `Together is a hosted service that provides extremely fast streaming of open-source language models. To get started with Together:\n1. Obtain an API key from [here](https://together.ai)\n2. Paste below\n3. Select a model preset`, + tags: [ + ModelProviderTag["Requires API Key"], + ModelProviderTag["Open-Source"], + ], + params: { + apiKey: "", + }, + collectInputFor: [ + { + inputType: CollectInputType.text, + key: "apiKey", + label: "API Key", + placeholder: "Enter your TogetherAI API key", + required: true, + }, + ...completionParamsInputs, + ], + packages: [llama3Chat, codeLlamaInstruct, mistralOs].map((p) => { + p.params.contextLength = 4096; + return p; + }), + }, gemini: { title: "Google Gemini API", provider: "gemini", @@ -879,35 +933,6 @@ export const PROVIDER_INFO: { [key: string]: ModelInfo } = { ], packages: [gemini15Pro, geminiPro, gemini15Flash], }, - mistral: { - title: "Mistral API", - provider: "mistral", - description: - "The Mistral API provides hosted access to their models, including Mistral-7b, Mixtral, and the very capable mistral-medium", - icon: "mistral.png", - longDescription: `To get access to the Mistral API, obtain your API key from the [Mistral platform](https://docs.mistral.ai/)`, - tags: [ - ModelProviderTag["Requires API Key"], - ModelProviderTag["Open-Source"], - ], - params: { - apiKey: "", - }, - collectInputFor: [ - { - inputType: CollectInputType.text, - key: "apiKey", - label: "API Key", - placeholder: "Enter your Mistral API key", - required: true, - }, - ...completionParamsInputs, - ], - packages: [mistralTiny, mistralSmall, mistralMedium].map((p) => { - p.params.contextLength = 4096; - return p; - }), - }, lmstudio: { title: "LM Studio", provider: "lmstudio", @@ -967,7 +992,7 @@ export const PROVIDER_INFO: { [key: string]: ModelInfo } = { ModelProviderTag["Requires API Key"], ModelProviderTag["Open-Source"], ], - packages: [llama3Chat, codeLlamaInstruct, wizardCoder, mistral], + packages: [llama3Chat, codeLlamaInstruct, wizardCoder, mistralOs], }, llamacpp: { title: "llama.cpp", @@ -1040,9 +1065,9 @@ After it's up and running, you can start using Continue.`, provider: "free-trial", refPage: "freetrial", description: - "New users can try out Continue for free using a proxy server that securely makes calls to OpenAI, Google, or Together using our API key", + "New users can try out Continue for free using a proxy server that securely makes calls to OpenAI, Anthropic, or Together using our API key", longDescription: - 'New users can try out Continue for free using a proxy server that securely makes calls to OpenAI, Google, or Together using our API key. If you are ready to use your own API key or have used all 250 free uses, you can enter your API key in config.py where it says `apiKey=""` or select another model provider.', + 'New users can try out Continue for free using a proxy server that securely makes calls to OpenAI, Anthropic, or Together using our API key. If you are ready to use your own API key or have used all 250 free uses, you can enter your API key in config.py where it says `apiKey=""` or select another model provider.', icon: "openai.png", tags: [ModelProviderTag.Free], packages: [