diff --git a/core/config/default.ts b/core/config/default.ts index a61d1cdb1..9d69f733d 100644 --- a/core/config/default.ts +++ b/core/config/default.ts @@ -8,9 +8,9 @@ const defaultConfig: SerializedContinueConfig = { model: "gpt-4", }, { - title: "GPT-3.5-Turbo (Free Trial)", + title: "GPT-4 Vision (Free Trial)", provider: "free-trial", - model: "gpt-3.5-turbo", + model: "gpt-4-vision-preview", }, { title: "Phind CodeLlama (Free Trial)", diff --git a/core/index.d.ts b/core/index.d.ts index c9cee9f6d..1582a699c 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -428,6 +428,7 @@ export type ModelName = | "gpt-3.5-turbo-0613" | "gpt-4-32k" | "gpt-4-1106-preview" + | "gpt-4-vision-preview" // Open Source | "mistral-7b" | "mistral-8x7b" diff --git a/core/llm/index.ts b/core/llm/index.ts index 9946e8b8d..a38752df8 100644 --- a/core/llm/index.ts +++ b/core/llm/index.ts @@ -56,7 +56,12 @@ const PROVIDER_HANDLES_TEMPLATING: ModelProvider[] = [ "ollama", ]; -const PROVIDER_SUPPORTS_IMAGES: ModelProvider[] = ["openai", "ollama"]; +const PROVIDER_SUPPORTS_IMAGES: ModelProvider[] = [ + "openai", + "ollama", + "google-palm", + "free-trial", +]; export function modelSupportsImages( provider: ModelProvider, @@ -65,13 +70,22 @@ export function modelSupportsImages( if (!PROVIDER_SUPPORTS_IMAGES.includes(provider)) { return false; } + if (model.includes("llava")) { return true; } + if (["gpt-4-vision-preview"].includes(model)) { return true; } + if ( + model === "gemini-ultra" && + (provider === "google-palm" || provider === "free-trial") + ) { + return true; + } + return false; } diff --git a/core/llm/llms/FreeTrial.ts b/core/llm/llms/FreeTrial.ts index 27ce0b040..1ceb3084a 100644 --- a/core/llm/llms/FreeTrial.ts +++ b/core/llm/llms/FreeTrial.ts @@ -3,7 +3,7 @@ import { ChatMessage, CompletionOptions, ModelProvider } from "../.."; import { streamResponse } from "../stream"; // const SERVER_URL = "http://localhost:3000"; -const SERVER_URL = "https://node-proxy-server-l6vsfbzhba-uw.a.run.app"; +const SERVER_URL = "https://node-proxy-server-green-l6vsfbzhba-uw.a.run.app"; class FreeTrial extends BaseLLM { static providerName: ModelProvider = "free-trial"; @@ -47,6 +47,24 @@ class FreeTrial extends BaseLLM { } } + protected _convertMessage(message: ChatMessage) { + if (typeof message.content === "string") { + return message; + } + + const parts = message.content.map((part) => { + return { + type: part.type, + text: part.text, + image_url: { ...part.imageUrl, detail: "low" }, + }; + }); + return { + ...message, + content: parts, + }; + } + protected async *_streamChat( messages: ChatMessage[], options: CompletionOptions @@ -57,7 +75,7 @@ class FreeTrial extends BaseLLM { method: "POST", headers: this._getHeaders(), body: JSON.stringify({ - messages, + messages: messages.map(this._convertMessage), ...args, }), }); diff --git a/core/llm/llms/GooglePalm.ts b/core/llm/llms/GooglePalm.ts index 93a81943e..8a6d13f84 100644 --- a/core/llm/llms/GooglePalm.ts +++ b/core/llm/llms/GooglePalm.ts @@ -3,6 +3,7 @@ import { ChatMessage, CompletionOptions, LLMOptions, + MessagePart, ModelProvider, } from "../.."; import { stripImages } from "../countTokens"; @@ -42,6 +43,19 @@ class GooglePalm extends BaseLLM { } } + private _continuePartToGeminiPart(part: MessagePart) { + return part.type === "text" + ? { + text: part.text, + } + : { + inlineData: { + mimeType: "image/jpeg", + data: part.imageUrl?.url.split(",")[1], + }, + }; + } + private async *streamChatGemini( messages: ChatMessage[], options: CompletionOptions @@ -51,7 +65,10 @@ class GooglePalm extends BaseLLM { contents: messages.map((msg) => { return { role: msg.role === "assistant" ? "model" : "user", - parts: [{ text: msg.content }], + parts: + typeof msg.content === "string" + ? [{ text: msg.content }] + : msg.content.map(this._continuePartToGeminiPart), }; }), }; diff --git a/docs/static/schemas/config.json b/docs/static/schemas/config.json index d9af7c9fd..d266eb68a 100644 --- a/docs/static/schemas/config.json +++ b/docs/static/schemas/config.json @@ -386,7 +386,7 @@ "gpt-4", "phind-codellama-34b", "gemini-pro", - "mistral-medium" + "gpt-4-vision-preview" ] } } diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index d9af7c9fd..d266eb68a 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -386,7 +386,7 @@ "gpt-4", "phind-codellama-34b", "gemini-pro", - "mistral-medium" + "gpt-4-vision-preview" ] } } diff --git a/gui/src/util/modelData.ts b/gui/src/util/modelData.ts index 3242a66a1..aa851fc76 100644 --- a/gui/src/util/modelData.ts +++ b/gui/src/util/modelData.ts @@ -55,7 +55,7 @@ const contextLengthInput: InputDescriptor = { inputType: CollectInputType.number, key: "contextLength", label: "Context Length", - defaultValue: 2048, + defaultValue: undefined, required: false, }; const temperatureInput: InputDescriptor = { @@ -173,7 +173,7 @@ const codeLlamaInstruct: ModelPackage = { params: { title: "CodeLlama-7b", model: "codellama-7b", - contextLength: 2048, + contextLength: 4096, }, icon: "meta.png", dimensions: [ @@ -206,7 +206,7 @@ const llama2Chat: ModelPackage = { params: { title: "Llama2-7b", model: "llama2-7b", - contextLength: 2048, + contextLength: 4096, }, icon: "meta.png", dimensions: [ @@ -240,7 +240,7 @@ const wizardCoder: ModelPackage = { params: { title: "WizardCoder-7b", model: "wizardcoder-7b", - contextLength: 2048, + contextLength: 4096, }, icon: "wizardlm.png", dimensions: [ @@ -273,7 +273,7 @@ const phindCodeLlama: ModelPackage = { params: { title: "Phind CodeLlama", model: "phind-codellama-34b", - contextLength: 2048, + contextLength: 4096, }, providerOptions: ["ollama", "lmstudio", "llamacpp", "replicate", "freetrial"], }; @@ -383,7 +383,7 @@ const zephyr: ModelPackage = { params: { title: "Zephyr", model: "zephyr-7b", - contextLength: 2048, + contextLength: 4096, }, icon: "mistral.png", providerOptions: ["ollama", "lmstudio", "llamacpp", "replicate"], @@ -396,7 +396,7 @@ const deepseek: ModelPackage = { params: { title: "DeepSeek", model: "deepseek-7b", - contextLength: 2048, + contextLength: 4096, }, providerOptions: ["lmstudio", "llamacpp"], }; @@ -407,7 +407,7 @@ const codeup: ModelPackage = { params: { title: "CodeUp", model: "codeup-13b", - contextLength: 2048, + contextLength: 4096, }, providerOptions: ["ollama", "lmstudio", "llamacpp", "replicate"], }; @@ -419,7 +419,7 @@ const neuralChat: ModelPackage = { params: { title: "NeuralChat", model: "neural-chat-7b", - contextLength: 2048, + contextLength: 4096, }, providerOptions: ["ollama", "lmstudio", "llamacpp", "replicate"], }; @@ -443,7 +443,6 @@ const gpt4turbo: ModelPackage = { model: "gpt-4-1106-preview", contextLength: 128_000, title: "GPT-4 Turbo", - apiKey: "", }, providerOptions: ["openai", "freetrial"], icon: "openai.png", @@ -455,13 +454,25 @@ const gpt4: ModelPackage = { params: { model: "gpt-4", contextLength: 8096, - apiKey: "", title: "GPT-4", }, providerOptions: ["openai", "freetrial"], icon: "openai.png", }; +const gpt4vision: ModelPackage = { + title: "GPT-4 Vision", + description: + "A faster version of GPT-4 with longer context length and image support", + params: { + model: "gpt-4-vision-preview", + contextLength: 128_000, + title: "GPT-4 Vision", + }, + providerOptions: ["openai", "freetrial"], + icon: "openai.png", +}; + const gpt35turbo: ModelPackage = { title: "GPT-3.5-Turbo", description: @@ -470,7 +481,6 @@ const gpt35turbo: ModelPackage = { model: "gpt-3.5-turbo", contextLength: 8096, title: "GPT-3.5-Turbo", - apiKey: "", }, providerOptions: ["openai", "freetrial"], icon: "openai.png", @@ -529,7 +539,7 @@ export const PROVIDER_INFO: { [key: string]: ModelInfo } = { "Use gpt-4, gpt-3.5-turbo, or any other OpenAI model. See [here](https://openai.com/product#made-for-developers) to obtain an API key.", icon: "openai.png", tags: [ModelProviderTag["Requires API Key"]], - packages: [gpt4, gpt35turbo, gpt4turbo], + packages: [gpt4, gpt35turbo, gpt4turbo, gpt4vision], collectInputFor: [ { inputType: CollectInputType.text, @@ -795,6 +805,7 @@ After it's up and running, you can start using Continue.`, packages: [ { ...gpt4, title: "GPT-4 (trial)" }, { ...gpt35turbo, title: "GPT-3.5-Turbo (trial)" }, + { ...gpt4vision, title: "GPT-4 Vision (trial)" }, { ...phindCodeLlama, title: "Phind CodeLlama (trial)" }, { ...gemini, title: "Gemini Pro (trial)" }, ],