✨ image support in free trial

This commit is contained in:
Nate Sesti 2024-01-25 13:50:41 -08:00
parent a79f66c4ca
commit 1260cb2be4
8 changed files with 82 additions and 21 deletions

View file

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

1
core/index.d.ts vendored
View file

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

View file

@ -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;
}

View file

@ -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,
}),
});

View file

@ -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),
};
}),
};

View file

@ -386,7 +386,7 @@
"gpt-4",
"phind-codellama-34b",
"gemini-pro",
"mistral-medium"
"gpt-4-vision-preview"
]
}
}

View file

@ -386,7 +386,7 @@
"gpt-4",
"phind-codellama-34b",
"gemini-pro",
"mistral-medium"
"gpt-4-vision-preview"
]
}
}

View file

@ -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)" },
],