diff --git a/binary/package-lock.json b/binary/package-lock.json index 11191c775..e4844b8ed 100644 --- a/binary/package-lock.json +++ b/binary/package-lock.json @@ -65,6 +65,7 @@ "dotenv": "^16.4.5", "fastest-levenshtein": "^1.0.16", "follow-redirects": "^1.15.5", + "google-auth-library": "^9.14.2", "handlebars": "^4.7.8", "http-proxy-agent": "^7.0.1", "https-proxy-agent": "^7.0.3", diff --git a/core/index.d.ts b/core/index.d.ts index 9fa3dcccd..e7c22db2f 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -612,6 +612,7 @@ type ModelProvider = | "openai" | "free-trial" | "anthropic" + | "anthropic-vertexai" | "cohere" | "together" | "ollama" @@ -624,7 +625,9 @@ type ModelProvider = | "lmstudio" | "llamafile" | "gemini" + | "gemini-vertexai" | "mistral" + | "mistral-vertexai" | "bedrock" | "bedrockimport" | "sagemaker" diff --git a/core/llm/autodetect.ts b/core/llm/autodetect.ts index 31eccfc8f..369421406 100644 --- a/core/llm/autodetect.ts +++ b/core/llm/autodetect.ts @@ -41,10 +41,12 @@ const PROVIDER_HANDLES_TEMPLATING: ModelProvider[] = [ "together", "msty", "anthropic", + "anthropic-vertexai", "bedrock", "sagemaker", "continue-proxy", "mistral", + "mistral-vertexai", "sambanova", ]; @@ -52,9 +54,11 @@ const PROVIDER_SUPPORTS_IMAGES: ModelProvider[] = [ "openai", "ollama", "gemini", + "gemini-vertexai", "free-trial", "msty", "anthropic", + "anthropic-vertexai", "bedrock", "sagemaker", "continue-proxy", @@ -103,13 +107,16 @@ function modelSupportsImages( } const PARALLEL_PROVIDERS: ModelProvider[] = [ "anthropic", + "anthropic-vertexai", "bedrock", "sagemaker", "deepinfra", "gemini", + "gemini-vertexai", "huggingface-inference-api", "huggingface-tgi", "mistral", + "mistral-vertexai", "free-trial", "replicate", "together", diff --git a/core/llm/llms/AnthropicVertexAI.ts b/core/llm/llms/AnthropicVertexAI.ts new file mode 100644 index 000000000..c910e8b85 --- /dev/null +++ b/core/llm/llms/AnthropicVertexAI.ts @@ -0,0 +1,142 @@ +import { + ChatMessage, + CompletionOptions, + LLMOptions, + ModelProvider, +} from "../../index.js"; +import { stripImages } from "../images.js"; +import { streamSse } from "../stream.js"; +import VertexAI from "./VertexAI.js"; + +class AnthropicVertexAI extends VertexAI { + static providerName: ModelProvider = "anthropic-vertexai"; + static defaultOptions: Partial = { + region: "us-east5", + model: "claude-3-5-sonnet", + }; + + private _convertArgs(options: CompletionOptions) { + const finalOptions = { + anthropic_version: "vertex-2023-10-16", + top_k: options.topK, + top_p: options.topP, + temperature: options.temperature, + max_tokens: options.maxTokens ?? 2048, + stop_sequences: options.stop?.filter((x) => x.trim() !== ""), + stream: options.stream ?? true, + }; + + return finalOptions; + } + + private _convertMessages(msgs: ChatMessage[]): any[] { + const filteredmessages = msgs.filter((m) => m.role !== "system") + const lastTwoUserMsgIndices = filteredmessages + .map((msg, index) => (msg.role === "user" ? index : -1)) + .filter((index) => index !== -1).slice(-2); + + const messages = filteredmessages.map((message, filteredMsgIdx) => { + // Add cache_control parameter to the last two user messages + // The second-to-last because it retrieves potentially already cached contents, + // The last one because we want it cached for later retrieval. + // See: https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching + const addCaching = this.cacheBehavior?.cacheConversation && lastTwoUserMsgIndices.includes(filteredMsgIdx); + + if (typeof message.content === "string") { + var chatMessage = { + ...message, + content: [{ + type: "text", + text: message.content, + ...(addCaching? { cache_control: { type: "ephemeral" } } : {}) + }] + }; + return chatMessage; + } + + return { + ...message, + content: message.content.map((part, contentIdx) => { + if (part.type === "text") { + const newpart = { + ...part, + // If multiple text parts, only add cache_control to the last one + ...((addCaching && contentIdx == message.content.length - 1) ? { cache_control: { type: "ephemeral" } } : {}) + }; + return newpart; + } + return { + type: "image", + source: { + type: "base64", + media_type: "image/jpeg", + data: part.imageUrl?.url.split(",")[1], + }, + }; + }), + }; + }); + return messages; + } + + protected async *_streamComplete( + prompt: string, + options: CompletionOptions, + ): AsyncGenerator { + const messages = [{ role: "user" as const, content: prompt }]; + for await (const update of this._streamChat(messages, options)) { + yield stripImages(update.content); + } + } + + protected async *_streamChat( + messages: ChatMessage[], + options: CompletionOptions, + ): AsyncGenerator { + const shouldCacheSystemMessage = !!this.systemMessage && this.cacheBehavior?.cacheSystemMessage; + const systemMessage: string = stripImages( + messages.filter((m) => m.role === "system")[0]?.content, + ); + const apiURL = new URL( + `publishers/anthropic/models/${options.model}:streamRawPredict`, + this.apiBase + ); + + const response = await this.fetch(apiURL, { + method: "POST", + headers: { + ...(shouldCacheSystemMessage || this.cacheBehavior?.cacheConversation + ? { "anthropic-beta": "prompt-caching-2024-07-31" } + : {}), + }, + body: JSON.stringify({ + ...this._convertArgs(options), + messages: this._convertMessages(messages), + system: shouldCacheSystemMessage + ? [ + { + type: "text", + text: this.systemMessage, + cache_control: { type: "ephemeral" }, + }, + ] + : systemMessage, + }), + }); + + if (options.stream === false) { + const data = await response.json(); + yield { role: "assistant", content: data.content[0].text }; + return; + } + + for await (const value of streamSse(response)) { + if (value.type == "message_start") console.log(value); + if (value.delta?.text) { + yield { role: "assistant", content: value.delta.text }; + } + } + } +} + +export default AnthropicVertexAI; diff --git a/core/llm/llms/GeminiVertexAI.ts b/core/llm/llms/GeminiVertexAI.ts new file mode 100644 index 000000000..2dc5e8cc1 --- /dev/null +++ b/core/llm/llms/GeminiVertexAI.ts @@ -0,0 +1,232 @@ +import { + ChatMessage, + CompletionOptions, + LLMOptions, + MessagePart, + ModelProvider, +} from "../../index.js"; +import { stripImages } from "../images.js"; +import { streamResponse } from "../stream.js"; +import VertexAI from "./VertexAI.js"; + +class GeminiVertexAI extends VertexAI { + static providerName: ModelProvider = "gemini-vertexai"; + + static defaultOptions: Partial = { + model: "gemini-pro", + region: "us-central1", + }; + + // Function to convert completion options to Gemini format + private _convertArgs(options: CompletionOptions) { + const finalOptions: any = {}; // Initialize an empty object + + // Map known options + if (options.topK) { + finalOptions.topK = options.topK; + } + if (options.topP) { + finalOptions.topP = options.topP; + } + if (options.temperature !== undefined && options.temperature !== null) { + finalOptions.temperature = options.temperature; + } + if (options.maxTokens) { + finalOptions.maxOutputTokens = options.maxTokens; + } + if (options.stop) { + finalOptions.stopSequences = options.stop.filter((x) => x.trim() !== ""); + } + + return { generationConfig: finalOptions }; // Wrap options under 'generationConfig' + } + + protected async *_streamComplete( + prompt: string, + options: CompletionOptions, + ): AsyncGenerator { + for await (const message of this._streamChat( + [{ content: prompt, role: "user" }], + options, + )) { + yield stripImages(message.content); + } + } + + private removeSystemMessage(messages: ChatMessage[]) { + const msgs = [...messages]; + + if (msgs[0]?.role === "system") { + const sysMsg = msgs.shift()?.content; + // @ts-ignore + if (msgs[0]?.role === "user") { + msgs[0].content = `System message - follow these instructions in every response: ${sysMsg}\n\n---\n\n${msgs[0].content}`; + } + } + + return msgs; + } + + protected async *_streamChat( + messages: ChatMessage[], + options: CompletionOptions, + ): AsyncGenerator { + const isV1API = this.apiBase.includes("/v1/"); + + // Conditionally apply removeSystemMessage + const convertedMsgs = isV1API + ? this.removeSystemMessage(messages) + : messages; + + if (options.model.includes("gemini")) { + yield* this.streamChatGemini(convertedMsgs, options); + } else { + yield* this.streamChatBison(convertedMsgs, options); + } + } + + 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, + ): AsyncGenerator { + const apiURL = new URL( + `publishers/google/models/${options.model}:streamGenerateContent`, + this.apiBase, + ); + // This feels hacky to repeat code from above function but was the quickest + // way to ensure system message re-formatting isn't done if user has specified v1 + const isV1API = this.apiBase.includes("/v1/"); + + const contents = messages + .map((msg) => { + if (msg.role === "system" && !isV1API) { + return null; // Don't include system message in contents + } + return { + role: msg.role === "assistant" ? "model" : "user", + parts: + typeof msg.content === "string" + ? [{ text: msg.content }] + : msg.content.map(this._continuePartToGeminiPart), + }; + }) + .filter((c) => c !== null); + + const body = { + ...this._convertArgs(options), + contents, + // if this.systemMessage is defined, reformat it for Gemini API + ...(this.systemMessage && + !isV1API && { + systemInstruction: { parts: [{ text: this.systemMessage }] }, + }), + }; + const response = await this.fetch(apiURL, { + method: "POST", + body: JSON.stringify(body), + }); + + let buffer = ""; + for await (const chunk of streamResponse(response)) { + buffer += chunk; + if (buffer.startsWith("[")) { + buffer = buffer.slice(1); + } + if (buffer.endsWith("]")) { + buffer = buffer.slice(0, -1); + } + if (buffer.startsWith(",")) { + buffer = buffer.slice(1); + } + + const parts = buffer.split("\n,"); + + let foundIncomplete = false; + for (let i = 0; i < parts.length; i++) { + const part = parts[i]; + let data; + try { + data = JSON.parse(part); + } catch (e) { + foundIncomplete = true; + continue; // yo! + } + if (data.error) { + throw new Error(data.error.message); + } + // Check for existence of each level before accessing the final 'text' property + if (data?.candidates?.[0]?.content?.parts?.[0]?.text) { + // Incrementally stream the content to make it smoother + const content = data.candidates[0].content.parts[0].text; + const words = content.split(/(\s+)/); + const delaySeconds = Math.min(4.0 / (words.length + 1), 0.1); + while (words.length > 0) { + const wordsToYield = Math.min(3, words.length); + yield { + role: "assistant", + content: words.splice(0, wordsToYield).join(""), + }; + await delay(delaySeconds); + } + } else { + // Handle the case where the expected data structure is not found + console.warn("Unexpected response format:", data); + } + } + if (foundIncomplete) { + buffer = parts[parts.length - 1]; + } else { + buffer = ""; + } + } + } + + private async *streamChatBison( + messages: ChatMessage[], + options: CompletionOptions, + ): AsyncGenerator { + const instances = messages.map((message) => ({ prompt: message.content })); + + const apiURL = new URL( + `publishers/google/models/${options.model}:predict`, + this.apiBase, + ); + const body = { + instances, + parameters: { + temperature: options.temperature, + maxOutputTokens: options.maxTokens, + topP: options.topP, + topK: options.topK, + stopSequences: options.stop, + presencePenalty: options.presencePenalty, + frequencyPenalty: options.frequencyPenalty, + }, + }; + const response = await this.fetch(apiURL, { + method: "POST", + body: JSON.stringify(body), + }); + const data = await response.json(); + yield { role: "assistant", content: data.predictions[0].content }; + } +} + +async function delay(seconds: number) { + return new Promise((resolve) => setTimeout(resolve, seconds * 1000)); +} + +export default GeminiVertexAI; diff --git a/core/llm/llms/MistralVertexAI.ts b/core/llm/llms/MistralVertexAI.ts new file mode 100644 index 000000000..af0fc6272 --- /dev/null +++ b/core/llm/llms/MistralVertexAI.ts @@ -0,0 +1,106 @@ +import { + ChatMessage, + CompletionOptions, + LLMOptions, + ModelProvider +} from "../../index.js"; +import { stripImages } from "../images.js"; +import { streamSse } from "../stream.js"; +import { gptEditPrompt } from "../templates/edit.js"; +import VertexAI from "./VertexAI.js"; + +class MistralVertexAI extends VertexAI { + static providerName: ModelProvider = "mistral-vertexai"; + static defaultOptions: Partial = { + region: "us-central1", + model: "codestral-latest", + promptTemplates: { + edit: gptEditPrompt, + }, + }; + + protected async *_streamComplete( + prompt: string, + options: CompletionOptions, + ): AsyncGenerator { + for await (const chunk of this._streamChat( + [{ role: "user", content: prompt }], + options, + )) { + yield stripImages(chunk.content); + } + } + + protected async *_streamChat( + messages: ChatMessage[], + options: CompletionOptions, + ): AsyncGenerator { + const apiBase = this.apiBase!; + const apiURL = new URL( + `publishers/mistralai/models/${options.model}:streamRawPredict`, + apiBase, + ); + + const lastMessage = messages[messages.length - 1]; + if (lastMessage?.role === "assistant") { + (lastMessage as any).prefix = true; + } + + const body = { + model: options.model, + temperature: options.temperature, + top_p: options.topP, + max_tokens: options.maxTokens, + stream: options.stream ?? true, + stop: options.stop, + messages, + }; + + const response = await this.fetch(apiURL, { + method: "POST", + body: JSON.stringify(body), + }); + + for await (const chunk of streamSse(response)) { + yield chunk.choices[0].delta; + } + } + + protected async *_streamFim( + prefix: string, + suffix: string, + options: CompletionOptions, + ): AsyncGenerator { + const apiBase = this.apiBase!; + const apiURL = new URL( + `publishers/mistralai/models/${options.model}:streamRawPredict`, + apiBase, + ); + + const body = { + model: options.model, + max_tokens: options.maxTokens, + temperature: options.temperature, + top_p: options.topP, + stream: options.stream ?? true, + stop: options.stop, + prompt: prefix, + suffix, + }; + + const response = await this.fetch(apiURL, { + method: "POST", + body: JSON.stringify(body), + }); + + for await (const chunk of streamSse(response)) { + yield chunk.choices[0].delta.content; + } + } + + supportsFim(): boolean { + return true; + } +} + +export default MistralVertexAI; diff --git a/core/llm/llms/VertexAI.ts b/core/llm/llms/VertexAI.ts new file mode 100644 index 000000000..772b30ea7 --- /dev/null +++ b/core/llm/llms/VertexAI.ts @@ -0,0 +1,46 @@ +import { GoogleAuth } from "google-auth-library"; +import { LLMOptions } from "../../index.js"; +import { BaseLLM } from "../index.js"; + +abstract class VertexAI extends BaseLLM { + declare apiBase: string; + + private clientPromise = new GoogleAuth({ + scopes: "https://www.googleapis.com/auth/cloud-platform", + }).getClient(); + + private static getDefaultApiBaseFrom(options: LLMOptions) { + const { region, projectId } = options; + if (!region || !projectId) { + throw new Error( + "region and projectId must be defined if apiBase is not provided", + ); + } + return `https://${region}-aiplatform.googleapis.com/v1/projects/${projectId}/locations/${region}/`; + } + + constructor(_options: LLMOptions) { + super(_options); + this.apiBase ??= VertexAI.getDefaultApiBaseFrom(_options); + } + + async fetch(url: RequestInfo | URL, init?: RequestInit) { + const client = await this.clientPromise; + const { token } = await client.getAccessToken(); + if (!token) { + throw new Error( + "Could not get an access token. Set up your Google Application Default Credentials.", + ); + } + return await super.fetch(url, { + ...init, + headers: { + "Content-Type": "application/json", + Authorization: `Bearer ${token}`, + ...init?.headers, + }, + }); + } +} + +export default VertexAI; diff --git a/core/llm/llms/index.ts b/core/llm/llms/index.ts index ea8968f5a..b504aa900 100644 --- a/core/llm/llms/index.ts +++ b/core/llm/llms/index.ts @@ -8,6 +8,7 @@ import { import { renderTemplatedString } from "../../promptFiles/renderTemplatedString"; import { BaseLLM } from "../index"; import Anthropic from "./Anthropic"; +import AnthropicVertexAI from "./AnthropicVertexAI"; import Azure from "./Azure"; import Bedrock from "./Bedrock"; import BedrockImport from "./BedrockImport"; @@ -20,6 +21,7 @@ import Fireworks from "./Fireworks"; import Flowise from "./Flowise"; import FreeTrial from "./FreeTrial"; import Gemini from "./Gemini"; +import GeminiVertexAI from "./GeminiVertexAI"; import Groq from "./Groq"; import HuggingFaceInferenceAPI from "./HuggingFaceInferenceAPI"; import HuggingFaceTGI from "./HuggingFaceTGI"; @@ -28,6 +30,7 @@ import LMStudio from "./LMStudio"; import LlamaCpp from "./LlamaCpp"; import Llamafile from "./Llamafile"; import Mistral from "./Mistral"; +import MistralVertexAI from "./MistralVertexAI"; import Mock from "./Mock"; import Msty from "./Msty"; import Nvidia from "./Nvidia"; @@ -45,9 +48,11 @@ import ContinueProxy from "./stubs/ContinueProxy"; const LLMs = [ Anthropic, + AnthropicVertexAI, Cohere, FreeTrial, Gemini, + GeminiVertexAI, Llamafile, Ollama, Replicate, @@ -60,6 +65,7 @@ const LLMs = [ OpenAI, LMStudio, Mistral, + MistralVertexAI, Bedrock, BedrockImport, SageMaker, diff --git a/core/package-lock.json b/core/package-lock.json index ade0b719d..81539dcf2 100644 --- a/core/package-lock.json +++ b/core/package-lock.json @@ -30,6 +30,7 @@ "dotenv": "^16.4.5", "fastest-levenshtein": "^1.0.16", "follow-redirects": "^1.15.5", + "google-auth-library": "^9.14.2", "handlebars": "^4.7.8", "http-proxy-agent": "^7.0.1", "https-proxy-agent": "^7.0.3", @@ -6093,6 +6094,15 @@ "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz", "integrity": "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==" }, + "node_modules/bignumber.js": { + "version": "9.1.2", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.2.tgz", + "integrity": "sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug==", + "license": "MIT", + "engines": { + "node": "*" + } + }, "node_modules/bindings": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", @@ -6261,6 +6271,12 @@ "node": "*" } }, + "node_modules/buffer-equal-constant-time": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", + "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==", + "license": "BSD-3-Clause" + }, "node_modules/buffer-from": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", @@ -7237,6 +7253,15 @@ "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", "integrity": "sha512-UVU9dibq2JcFWxQPA6KCqj5O42VOmAY3zQUfEKxU0KpTGXwNoCjkX1e13eHNvw/xPynt6pU0rZ1htjWTNTSXsg==" }, + "node_modules/ecdsa-sig-formatter": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", + "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", + "license": "Apache-2.0", + "dependencies": { + "safe-buffer": "^5.0.1" + } + }, "node_modules/eight-colors": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/eight-colors/-/eight-colors-1.3.0.tgz", @@ -8429,6 +8454,77 @@ "node": "^12.13.0 || ^14.15.0 || >=16.0.0" } }, + "node_modules/gaxios": { + "version": "6.7.1", + "resolved": "https://registry.npmjs.org/gaxios/-/gaxios-6.7.1.tgz", + "integrity": "sha512-LDODD4TMYx7XXdpwxAVRAIAuB0bzv0s+ywFonY46k126qzQHT9ygyoa9tncmOiQmmDrik65UYsEkv3lbfqQ3yQ==", + "license": "Apache-2.0", + "dependencies": { + "extend": "^3.0.2", + "https-proxy-agent": "^7.0.1", + "is-stream": "^2.0.0", + "node-fetch": "^2.6.9", + "uuid": "^9.0.1" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/gaxios/node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "license": "MIT", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/gaxios/node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "license": "MIT" + }, + "node_modules/gaxios/node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "license": "BSD-2-Clause" + }, + "node_modules/gaxios/node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "license": "MIT", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "node_modules/gcp-metadata": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-6.1.0.tgz", + "integrity": "sha512-Jh/AIwwgaxan+7ZUUmRLCjtchyDiqh4KjBJ5tW3plBZb5iL/BPcso8A5DlzeD9qlw0duCamnNdpFjxwaT0KyKg==", + "license": "Apache-2.0", + "dependencies": { + "gaxios": "^6.0.0", + "json-bigint": "^1.0.0" + }, + "engines": { + "node": ">=14" + } + }, "node_modules/generate-function": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.3.1.tgz", @@ -8642,6 +8738,23 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/google-auth-library": { + "version": "9.14.2", + "resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-9.14.2.tgz", + "integrity": "sha512-R+FRIfk1GBo3RdlRYWPdwk8nmtVUOn6+BkDomAC46KoU8kzXzE1HLmOasSCbWUByMMAGkknVF0G5kQ69Vj7dlA==", + "license": "Apache-2.0", + "dependencies": { + "base64-js": "^1.3.0", + "ecdsa-sig-formatter": "^1.0.11", + "gaxios": "^6.1.1", + "gcp-metadata": "^6.1.0", + "gtoken": "^7.0.0", + "jws": "^4.0.0" + }, + "engines": { + "node": ">=14" + } + }, "node_modules/gopd": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", @@ -8728,6 +8841,19 @@ "graphology-types": ">=0.23.0" } }, + "node_modules/gtoken": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/gtoken/-/gtoken-7.1.0.tgz", + "integrity": "sha512-pCcEwRi+TKpMlxAQObHDQ56KawURgyAf6jtIY046fJ5tIv3zDe/LEIubckAO8fj6JnAxLdmWkUfNyulQ2iKdEw==", + "license": "MIT", + "dependencies": { + "gaxios": "^6.0.0", + "jws": "^4.0.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/guid-typescript": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/guid-typescript/-/guid-typescript-1.0.9.tgz", @@ -9331,7 +9457,6 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", - "dev": true, "engines": { "node": ">=8" }, @@ -10463,6 +10588,15 @@ "node": ">=4" } }, + "node_modules/json-bigint": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-1.0.0.tgz", + "integrity": "sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==", + "license": "MIT", + "dependencies": { + "bignumber.js": "^9.0.0" + } + }, "node_modules/json-bignum": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/json-bignum/-/json-bignum-0.0.3.tgz", @@ -10547,6 +10681,27 @@ "node": ">=0.6.0" } }, + "node_modules/jwa": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-2.0.0.tgz", + "integrity": "sha512-jrZ2Qx916EA+fq9cEAeCROWPTfCwi1IVHqT2tapuqLEVVDKFDENFw1oL+MwrTvH6msKxsd1YTDVw6uKEcsrLEA==", + "license": "MIT", + "dependencies": { + "buffer-equal-constant-time": "1.0.1", + "ecdsa-sig-formatter": "1.0.11", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/jws": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jws/-/jws-4.0.0.tgz", + "integrity": "sha512-KDncfTmOZoOMTFG4mBlG0qUIOlc03fmzH+ru6RgYVZhPkyiy/92Owlt/8UEN+a4TXR1FQetfIpJE8ApdvdVxTg==", + "license": "MIT", + "dependencies": { + "jwa": "^2.0.0", + "safe-buffer": "^5.0.1" + } + }, "node_modules/keyv": { "version": "4.5.4", "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", diff --git a/core/package.json b/core/package.json index ffed10a93..7b8e235f9 100644 --- a/core/package.json +++ b/core/package.json @@ -62,6 +62,7 @@ "dotenv": "^16.4.5", "fastest-levenshtein": "^1.0.16", "follow-redirects": "^1.15.5", + "google-auth-library": "^9.14.2", "handlebars": "^4.7.8", "http-proxy-agent": "^7.0.1", "https-proxy-agent": "^7.0.3", diff --git a/docs/docs/customize/model-providers/more/anthropic-vertexai.md b/docs/docs/customize/model-providers/more/anthropic-vertexai.md new file mode 100644 index 000000000..3f00c17f6 --- /dev/null +++ b/docs/docs/customize/model-providers/more/anthropic-vertexai.md @@ -0,0 +1,70 @@ +--- +title: Anthropic Vertex AI +slug: ../anthropic-vertexai +--- + +:::info + +You need to enable the [Vertex AI API](https://console.cloud.google.com/marketplace/product/google/aiplatform.googleapis.com) and set up the [Google Application Default Credentials](https://cloud.google.com/docs/authentication/provide-credentials-adc). + +::: + +## Chat model + +We recommend configuring **Claude 3.5 Sonnet** as your chat model. + +```json title="config.json" +{ + "models": [ + { + "title": "Claude 3.5 Sonnet", + "provider": "anthropic-vertexai", + "model": "claude-3-5-sonnet-20240620", + "projectId": "[PROJECT_ID]", + "region": "us-east5" + } + ] +} +``` + +## Autocomplete model + +Anthropic Vertex AI currently does not offer any autocomplete models. + +[Click here](../../model-types/autocomplete.md) to see a list of autocomplete model providers. + +## Embeddings model + +Anthropic Vertex AI currently does not offer any embeddings models. + +[Click here](../../model-types/embeddings.md) to see a list of embeddings model providers. + +## Reranking model + +Anthropic Vertex AI currently does not offer any reranking models. + +[Click here](../../model-types/reranking.md) to see a list of reranking model providers. + +## Prompt caching + +Anthropic Vertex AI supports [prompt caching with Claude](https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching). + +To enable caching of the system message and the turn-by-turn conversation, update your your model configuration as following: + +```jsonc +{ + "models": [ + { + // Enable prompt caching + "cacheBehavior": { + "cacheSystemMessage": true, + "cacheConversation": true + }, + "title": "Anthropic", + "provider": "anthropic", + "model": "claude-3-5-sonnet-20240620", + "apiKey": "[API_KEY]" + } + ] +} +``` diff --git a/docs/docs/customize/model-providers/more/gemini-vertexai.md b/docs/docs/customize/model-providers/more/gemini-vertexai.md new file mode 100644 index 000000000..fb92e60ff --- /dev/null +++ b/docs/docs/customize/model-providers/more/gemini-vertexai.md @@ -0,0 +1,46 @@ +--- +title: Gemini Vertex AI +slug: ../gemini-vertexai +--- + +:::info + +You need to enable the [Vertex AI API](https://console.cloud.google.com/marketplace/product/google/aiplatform.googleapis.com) and set up the [Google Application Default Credentials](https://cloud.google.com/docs/authentication/provide-credentials-adc). + +::: + +## Chat model + +We recommend configuring **Gemini 1.5 Pro** as your chat model. + +```json title="config.json" +{ + "models": [ + { + "title": "Gemini 1.5 Pro (Vertex AI)", + "provider": "gemini-vertexai", + "model": "gemini-1.5-pro", + "projectId": "[PROJECT_ID]", + "region": "us-central1" + } + ] +} +``` + +## Autocomplete model + +Gemini Vertex AI currently does not offer any autocomplete models. + +[Click here](../../model-types/autocomplete.md) to see a list of autocomplete model providers. + +## Embeddings model + +Gemini Vertex AI currently does not offer any embeddings models. + +[Click here](../../model-types/embeddings.md) to see a list of embeddings model providers. + +## Reranking model + +Gemini Vertex AI currently does not offer any reranking models. + +[Click here](../../model-types/reranking.md) to see a list of reranking model providers. diff --git a/docs/docs/customize/model-providers/more/mistral-vertexai.md b/docs/docs/customize/model-providers/more/mistral-vertexai.md new file mode 100644 index 000000000..c4590e41b --- /dev/null +++ b/docs/docs/customize/model-providers/more/mistral-vertexai.md @@ -0,0 +1,56 @@ +--- +title: Mistral Vertex AI +slug: ../mistral-vertexai +--- + +:::info + +You need to enable the [Vertex AI API](https://console.cloud.google.com/marketplace/product/google/aiplatform.googleapis.com) and set up the [Google Application Default Credentials](https://cloud.google.com/docs/authentication/provide-credentials-adc). + +::: + +## Chat model + +We recommend configuring **Mistral Large** as your chat model. + +```json title="config.json" +{ + "models": [ + { + "title": "Mistral Large (Vertex AI)", + "provider": "mistral-vertexai", + "model": "mistral-large", + "projectId": "[PROJECT_ID]", + "region": "us-central1" + } + ] +} +``` + +## Autocomplete model + +We recommend configuring **Codestral** as your autocomplete model. + +```json title="config.json" +{ + "tabAutocompleteModel": { + "title": "Codestral (Vertex AI)", + "provider": "mistral-vertexai", + "model": "codestral", + "projectId": "[PROJECT_ID]", + "region": "us-central1" + } +} +``` + +## Embeddings model + +Mistral Vertex AI currently does not offer any embeddings models. + +[Click here](../../model-types/embeddings.md) to see a list of embeddings model providers. + +## Reranking model + +Mistral Vertex AI currently does not offer any reranking models. + +[Click here](../../model-types/reranking.md) to see a list of reranking model providers. diff --git a/docs/docs/customize/model-types/autocomplete.md b/docs/docs/customize/model-types/autocomplete.md index 8ecac28e6..a7eaa5e63 100644 --- a/docs/docs/customize/model-types/autocomplete.md +++ b/docs/docs/customize/model-types/autocomplete.md @@ -11,6 +11,6 @@ In Continue, these models are used to display inline [Autocomplete](../../autoco ## Recommended Autocomplete models -If you have the ability to use any model, we recommend `Codestral` with [Mistral](../model-providers/top-level/mistral.md#autocomplete-model). +If you have the ability to use any model, we recommend `Codestral` with [Mistral](../model-providers/top-level/mistral.md#autocomplete-model) or [Mistral Vertex AI](../model-providers/more/mistral-vertexai.md#autocomplete-model). If you want to run a model locally, we recommend `Starcoder2-3B` with [Ollama](../model-providers/top-level/ollama.md#autocomplete-model). diff --git a/docs/static/schemas/config.json b/docs/static/schemas/config.json index bd696e663..ce4e8e1a4 100644 --- a/docs/static/schemas/config.json +++ b/docs/static/schemas/config.json @@ -169,6 +169,7 @@ "openai", "free-trial", "anthropic", + "anthropic-vertexai", "cohere", "bedrock", "bedrockimport", @@ -180,9 +181,11 @@ "llama.cpp", "replicate", "gemini", + "gemini-vertexai", "lmstudio", "llamafile", "mistral", + "mistral-vertexai", "deepinfra", "groq", "fireworks", @@ -201,6 +204,7 @@ "### OpenAI\nUse 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.\n\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/openai)", "### Free Trial\nNew users can try out Continue for free using a proxy server that securely makes calls to OpenAI 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.json where it says `apiKey=\"\"` or select another model provider.\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/freetrial)", "### Anthropic\nTo get started with Anthropic models, you first need to sign up for the open beta [here](https://claude.ai/login) to obtain an API key.\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/anthropicllm)", + "### Anthropic Vertex AI\nTo get started you need to enable the [Vertex AI API](https://console.cloud.google.com/marketplace/product/google/aiplatform.googleapis.com) and set up the [Google Application Default Credentials](https://cloud.google.com/docs/authentication/provide-credentials-adc).", "### Cohere\nTo use Cohere, visit the [Cohere dashboard](https://dashboard.cohere.com/api-keys) to create an API key.\n\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/cohere)", "### Bedrock\nTo get started with Bedrock you need to sign up on AWS [here](https://aws.amazon.com/bedrock)", "### Bedrock Imported Models\nTo get started with Bedrock you need to sign up on AWS [here](https://aws.amazon.com/bedrock)", @@ -212,9 +216,11 @@ "### Llama.cpp\nllama.cpp comes with a [built-in server](https://github.com/ggerganov/llama.cpp/tree/master/examples/server#llamacppexampleserver) that can be run from source. To do this:\n\n1. Clone the repository with `git clone https://github.com/ggerganov/llama.cpp`.\n2. `cd llama.cpp`\n3. Run `make` to build the server.\n4. Download the model you'd like to use and place it in the `llama.cpp/models` directory (the best place to find models is [The Bloke on HuggingFace](https://huggingface.co/TheBloke))\n5. Run the llama.cpp server with the command below (replacing with the model you downloaded):\n\n```shell\n.\\server.exe -c 4096 --host 0.0.0.0 -t 16 --mlock -m models/codellama-7b-instruct.Q8_0.gguf\n```\n\nAfter it's up and running, you can start using Continue.\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/llamacpp)", "### Replicate\nReplicate is a hosted service that makes it easy to run ML models. To get started with Replicate:\n1. Obtain an API key from [here](https://replicate.com)\n2. Paste below\n3. Select a model preset\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/replicatellm)", "### Gemini API\nTo get started with Google Makersuite, obtain your API key from [here](https://makersuite.google.com) and paste it below.\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/geminiapi)", + "### Gemini API on Vertex AI\nTo get started you need to enable the [Vertex AI API](https://console.cloud.google.com/marketplace/product/google/aiplatform.googleapis.com) and set up the [Google Application Default Credentials](https://cloud.google.com/docs/authentication/provide-credentials-adc).", "### LMStudio\nLMStudio provides a professional and well-designed GUI for exploring, configuring, and serving LLMs. It is available on both Mac and Windows. To get started:\n1. Download from [lmstudio.ai](https://lmstudio.ai/) and open the application\n2. Search for and download the desired model from the home screen of LMStudio.\n3. In the left-bar, click the '<->' icon to open the Local Inference Server and press 'Start Server'.\n4. Once your model is loaded and the server has started, you can begin using Continue.\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/lmstudio)", "### Llamafile\nTo get started with llamafiles, find and download a binary on their [GitHub repo](https://github.com/Mozilla-Ocho/llamafile#binary-instructions). Then run it with the following command:\n\n```shell\nchmod +x ./llamafile\n./llamafile\n```\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/llamafile)", "### Mistral API\n\nTo get access to the Mistral API, obtain your API key from the [Mistral platform](https://docs.mistral.ai/)", + "### Mistral API on Vertex AI\nTo get started you need to enable the [Vertex AI API](https://console.cloud.google.com/marketplace/product/google/aiplatform.googleapis.com) and set up the [Google Application Default Credentials](https://cloud.google.com/docs/authentication/provide-credentials-adc).", "### DeepInfra\n\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/deepinfra)", "### Groq\nGroq provides extremely fast inference of open-source language models. To get started, obtain an API key from [their console](https://console.groq.com/keys).", "### Fireworks\nFireworks is a fast inference engine for open-source language models. To get started, obtain an API key from [their console](https://fireworks.ai/api-keys).", @@ -259,7 +265,36 @@ "eu-central-1", "ap-southeast-1", "ap-northeast-1", - "ap-south-1" + "ap-south-1", + "us-central1", + "us-east1", + "us-east4", + "us-east5", + "us-west1", + "us-west4", + "us-south1", + "northamerica-northeast1", + "southamerica-east1", + "europe-central2", + "europe-north1", + "europe-west1", + "europe-west2", + "europe-west3", + "europe-west4", + "europe-west6", + "europe-west8", + "europe-west9", + "europe-southwest1", + "asia-east1", + "asia-east2", + "asia-south1", + "asia-northeast1", + "asia-northeast3", + "asia-southeast1", + "australia-southeast1", + "me-central1", + "me-central2", + "me-west1" ], "type": "string" }, @@ -752,6 +787,49 @@ } } }, + { + "if": { + "properties": { + "provider": { + "enum": ["anthropic-vertexai"] + } + }, + "required": ["provider"] + }, + "then": { + "properties": { + "cacheBehavior": { + "title": "Caching Behavior", + "description": "Options for the prompt caching", + "properties": { + "cacheSystemMessage": { + "type": "boolean" + }, + "cacheConversation": { + "type": "boolean" + } + } + }, + "model": { + "anyOf": [ + { + "enum": [ + "claude-3-5-opus", + "claude-3-5-sonnet", + "claude-3-5-haiku", + "claude-3-opus", + "claude-3-sonnet", + "claude-3-haiku" + ] + }, + { + "type": "string" + } + ] + } + } + } + }, { "if": { "properties": { @@ -847,6 +925,35 @@ } } }, + { + "if": { + "properties": { + "provider": { + "enum": ["gemini-vertexai"] + } + }, + "required": ["provider"] + }, + "then": { + "properties": { + "model": { + "anyOf": [ + { + "enum": [ + "gemini-pro", + "gemini-1.5-pro-latest", + "gemini-1.5-pro", + "gemini-1.5-flash-latest", + "gemini-1.5-flash" + ] + }, + { "type": "string" } + ] + } + }, + "required": ["projectId", "region"] + } + }, { "if": { "properties": { @@ -1041,6 +1148,33 @@ } } }, + { + "if": { + "properties": { + "provider": { + "enum": ["mistral-vertexai"] + } + }, + "required": ["provider"] + }, + "then": { + "properties": { + "model": { + "anyOf": [ + { + "enum": [ + "codestral", + "mistral-nemo", + "mistral-large" + ] + }, + { "type": "string" } + ] + } + }, + "required": ["projectId", "region"] + } + }, { "if": { "properties": { diff --git a/extensions/intellij/src/main/resources/config_schema.json b/extensions/intellij/src/main/resources/config_schema.json index bd696e663..ce4e8e1a4 100644 --- a/extensions/intellij/src/main/resources/config_schema.json +++ b/extensions/intellij/src/main/resources/config_schema.json @@ -169,6 +169,7 @@ "openai", "free-trial", "anthropic", + "anthropic-vertexai", "cohere", "bedrock", "bedrockimport", @@ -180,9 +181,11 @@ "llama.cpp", "replicate", "gemini", + "gemini-vertexai", "lmstudio", "llamafile", "mistral", + "mistral-vertexai", "deepinfra", "groq", "fireworks", @@ -201,6 +204,7 @@ "### OpenAI\nUse 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.\n\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/openai)", "### Free Trial\nNew users can try out Continue for free using a proxy server that securely makes calls to OpenAI 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.json where it says `apiKey=\"\"` or select another model provider.\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/freetrial)", "### Anthropic\nTo get started with Anthropic models, you first need to sign up for the open beta [here](https://claude.ai/login) to obtain an API key.\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/anthropicllm)", + "### Anthropic Vertex AI\nTo get started you need to enable the [Vertex AI API](https://console.cloud.google.com/marketplace/product/google/aiplatform.googleapis.com) and set up the [Google Application Default Credentials](https://cloud.google.com/docs/authentication/provide-credentials-adc).", "### Cohere\nTo use Cohere, visit the [Cohere dashboard](https://dashboard.cohere.com/api-keys) to create an API key.\n\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/cohere)", "### Bedrock\nTo get started with Bedrock you need to sign up on AWS [here](https://aws.amazon.com/bedrock)", "### Bedrock Imported Models\nTo get started with Bedrock you need to sign up on AWS [here](https://aws.amazon.com/bedrock)", @@ -212,9 +216,11 @@ "### Llama.cpp\nllama.cpp comes with a [built-in server](https://github.com/ggerganov/llama.cpp/tree/master/examples/server#llamacppexampleserver) that can be run from source. To do this:\n\n1. Clone the repository with `git clone https://github.com/ggerganov/llama.cpp`.\n2. `cd llama.cpp`\n3. Run `make` to build the server.\n4. Download the model you'd like to use and place it in the `llama.cpp/models` directory (the best place to find models is [The Bloke on HuggingFace](https://huggingface.co/TheBloke))\n5. Run the llama.cpp server with the command below (replacing with the model you downloaded):\n\n```shell\n.\\server.exe -c 4096 --host 0.0.0.0 -t 16 --mlock -m models/codellama-7b-instruct.Q8_0.gguf\n```\n\nAfter it's up and running, you can start using Continue.\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/llamacpp)", "### Replicate\nReplicate is a hosted service that makes it easy to run ML models. To get started with Replicate:\n1. Obtain an API key from [here](https://replicate.com)\n2. Paste below\n3. Select a model preset\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/replicatellm)", "### Gemini API\nTo get started with Google Makersuite, obtain your API key from [here](https://makersuite.google.com) and paste it below.\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/geminiapi)", + "### Gemini API on Vertex AI\nTo get started you need to enable the [Vertex AI API](https://console.cloud.google.com/marketplace/product/google/aiplatform.googleapis.com) and set up the [Google Application Default Credentials](https://cloud.google.com/docs/authentication/provide-credentials-adc).", "### LMStudio\nLMStudio provides a professional and well-designed GUI for exploring, configuring, and serving LLMs. It is available on both Mac and Windows. To get started:\n1. Download from [lmstudio.ai](https://lmstudio.ai/) and open the application\n2. Search for and download the desired model from the home screen of LMStudio.\n3. In the left-bar, click the '<->' icon to open the Local Inference Server and press 'Start Server'.\n4. Once your model is loaded and the server has started, you can begin using Continue.\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/lmstudio)", "### Llamafile\nTo get started with llamafiles, find and download a binary on their [GitHub repo](https://github.com/Mozilla-Ocho/llamafile#binary-instructions). Then run it with the following command:\n\n```shell\nchmod +x ./llamafile\n./llamafile\n```\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/llamafile)", "### Mistral API\n\nTo get access to the Mistral API, obtain your API key from the [Mistral platform](https://docs.mistral.ai/)", + "### Mistral API on Vertex AI\nTo get started you need to enable the [Vertex AI API](https://console.cloud.google.com/marketplace/product/google/aiplatform.googleapis.com) and set up the [Google Application Default Credentials](https://cloud.google.com/docs/authentication/provide-credentials-adc).", "### DeepInfra\n\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/deepinfra)", "### Groq\nGroq provides extremely fast inference of open-source language models. To get started, obtain an API key from [their console](https://console.groq.com/keys).", "### Fireworks\nFireworks is a fast inference engine for open-source language models. To get started, obtain an API key from [their console](https://fireworks.ai/api-keys).", @@ -259,7 +265,36 @@ "eu-central-1", "ap-southeast-1", "ap-northeast-1", - "ap-south-1" + "ap-south-1", + "us-central1", + "us-east1", + "us-east4", + "us-east5", + "us-west1", + "us-west4", + "us-south1", + "northamerica-northeast1", + "southamerica-east1", + "europe-central2", + "europe-north1", + "europe-west1", + "europe-west2", + "europe-west3", + "europe-west4", + "europe-west6", + "europe-west8", + "europe-west9", + "europe-southwest1", + "asia-east1", + "asia-east2", + "asia-south1", + "asia-northeast1", + "asia-northeast3", + "asia-southeast1", + "australia-southeast1", + "me-central1", + "me-central2", + "me-west1" ], "type": "string" }, @@ -752,6 +787,49 @@ } } }, + { + "if": { + "properties": { + "provider": { + "enum": ["anthropic-vertexai"] + } + }, + "required": ["provider"] + }, + "then": { + "properties": { + "cacheBehavior": { + "title": "Caching Behavior", + "description": "Options for the prompt caching", + "properties": { + "cacheSystemMessage": { + "type": "boolean" + }, + "cacheConversation": { + "type": "boolean" + } + } + }, + "model": { + "anyOf": [ + { + "enum": [ + "claude-3-5-opus", + "claude-3-5-sonnet", + "claude-3-5-haiku", + "claude-3-opus", + "claude-3-sonnet", + "claude-3-haiku" + ] + }, + { + "type": "string" + } + ] + } + } + } + }, { "if": { "properties": { @@ -847,6 +925,35 @@ } } }, + { + "if": { + "properties": { + "provider": { + "enum": ["gemini-vertexai"] + } + }, + "required": ["provider"] + }, + "then": { + "properties": { + "model": { + "anyOf": [ + { + "enum": [ + "gemini-pro", + "gemini-1.5-pro-latest", + "gemini-1.5-pro", + "gemini-1.5-flash-latest", + "gemini-1.5-flash" + ] + }, + { "type": "string" } + ] + } + }, + "required": ["projectId", "region"] + } + }, { "if": { "properties": { @@ -1041,6 +1148,33 @@ } } }, + { + "if": { + "properties": { + "provider": { + "enum": ["mistral-vertexai"] + } + }, + "required": ["provider"] + }, + "then": { + "properties": { + "model": { + "anyOf": [ + { + "enum": [ + "codestral", + "mistral-nemo", + "mistral-large" + ] + }, + { "type": "string" } + ] + } + }, + "required": ["projectId", "region"] + } + }, { "if": { "properties": { diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index bd696e663..ce4e8e1a4 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -169,6 +169,7 @@ "openai", "free-trial", "anthropic", + "anthropic-vertexai", "cohere", "bedrock", "bedrockimport", @@ -180,9 +181,11 @@ "llama.cpp", "replicate", "gemini", + "gemini-vertexai", "lmstudio", "llamafile", "mistral", + "mistral-vertexai", "deepinfra", "groq", "fireworks", @@ -201,6 +204,7 @@ "### OpenAI\nUse 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.\n\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/openai)", "### Free Trial\nNew users can try out Continue for free using a proxy server that securely makes calls to OpenAI 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.json where it says `apiKey=\"\"` or select another model provider.\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/freetrial)", "### Anthropic\nTo get started with Anthropic models, you first need to sign up for the open beta [here](https://claude.ai/login) to obtain an API key.\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/anthropicllm)", + "### Anthropic Vertex AI\nTo get started you need to enable the [Vertex AI API](https://console.cloud.google.com/marketplace/product/google/aiplatform.googleapis.com) and set up the [Google Application Default Credentials](https://cloud.google.com/docs/authentication/provide-credentials-adc).", "### Cohere\nTo use Cohere, visit the [Cohere dashboard](https://dashboard.cohere.com/api-keys) to create an API key.\n\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/cohere)", "### Bedrock\nTo get started with Bedrock you need to sign up on AWS [here](https://aws.amazon.com/bedrock)", "### Bedrock Imported Models\nTo get started with Bedrock you need to sign up on AWS [here](https://aws.amazon.com/bedrock)", @@ -212,9 +216,11 @@ "### Llama.cpp\nllama.cpp comes with a [built-in server](https://github.com/ggerganov/llama.cpp/tree/master/examples/server#llamacppexampleserver) that can be run from source. To do this:\n\n1. Clone the repository with `git clone https://github.com/ggerganov/llama.cpp`.\n2. `cd llama.cpp`\n3. Run `make` to build the server.\n4. Download the model you'd like to use and place it in the `llama.cpp/models` directory (the best place to find models is [The Bloke on HuggingFace](https://huggingface.co/TheBloke))\n5. Run the llama.cpp server with the command below (replacing with the model you downloaded):\n\n```shell\n.\\server.exe -c 4096 --host 0.0.0.0 -t 16 --mlock -m models/codellama-7b-instruct.Q8_0.gguf\n```\n\nAfter it's up and running, you can start using Continue.\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/llamacpp)", "### Replicate\nReplicate is a hosted service that makes it easy to run ML models. To get started with Replicate:\n1. Obtain an API key from [here](https://replicate.com)\n2. Paste below\n3. Select a model preset\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/replicatellm)", "### Gemini API\nTo get started with Google Makersuite, obtain your API key from [here](https://makersuite.google.com) and paste it below.\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/geminiapi)", + "### Gemini API on Vertex AI\nTo get started you need to enable the [Vertex AI API](https://console.cloud.google.com/marketplace/product/google/aiplatform.googleapis.com) and set up the [Google Application Default Credentials](https://cloud.google.com/docs/authentication/provide-credentials-adc).", "### LMStudio\nLMStudio provides a professional and well-designed GUI for exploring, configuring, and serving LLMs. It is available on both Mac and Windows. To get started:\n1. Download from [lmstudio.ai](https://lmstudio.ai/) and open the application\n2. Search for and download the desired model from the home screen of LMStudio.\n3. In the left-bar, click the '<->' icon to open the Local Inference Server and press 'Start Server'.\n4. Once your model is loaded and the server has started, you can begin using Continue.\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/lmstudio)", "### Llamafile\nTo get started with llamafiles, find and download a binary on their [GitHub repo](https://github.com/Mozilla-Ocho/llamafile#binary-instructions). Then run it with the following command:\n\n```shell\nchmod +x ./llamafile\n./llamafile\n```\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/llamafile)", "### Mistral API\n\nTo get access to the Mistral API, obtain your API key from the [Mistral platform](https://docs.mistral.ai/)", + "### Mistral API on Vertex AI\nTo get started you need to enable the [Vertex AI API](https://console.cloud.google.com/marketplace/product/google/aiplatform.googleapis.com) and set up the [Google Application Default Credentials](https://cloud.google.com/docs/authentication/provide-credentials-adc).", "### DeepInfra\n\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/deepinfra)", "### Groq\nGroq provides extremely fast inference of open-source language models. To get started, obtain an API key from [their console](https://console.groq.com/keys).", "### Fireworks\nFireworks is a fast inference engine for open-source language models. To get started, obtain an API key from [their console](https://fireworks.ai/api-keys).", @@ -259,7 +265,36 @@ "eu-central-1", "ap-southeast-1", "ap-northeast-1", - "ap-south-1" + "ap-south-1", + "us-central1", + "us-east1", + "us-east4", + "us-east5", + "us-west1", + "us-west4", + "us-south1", + "northamerica-northeast1", + "southamerica-east1", + "europe-central2", + "europe-north1", + "europe-west1", + "europe-west2", + "europe-west3", + "europe-west4", + "europe-west6", + "europe-west8", + "europe-west9", + "europe-southwest1", + "asia-east1", + "asia-east2", + "asia-south1", + "asia-northeast1", + "asia-northeast3", + "asia-southeast1", + "australia-southeast1", + "me-central1", + "me-central2", + "me-west1" ], "type": "string" }, @@ -752,6 +787,49 @@ } } }, + { + "if": { + "properties": { + "provider": { + "enum": ["anthropic-vertexai"] + } + }, + "required": ["provider"] + }, + "then": { + "properties": { + "cacheBehavior": { + "title": "Caching Behavior", + "description": "Options for the prompt caching", + "properties": { + "cacheSystemMessage": { + "type": "boolean" + }, + "cacheConversation": { + "type": "boolean" + } + } + }, + "model": { + "anyOf": [ + { + "enum": [ + "claude-3-5-opus", + "claude-3-5-sonnet", + "claude-3-5-haiku", + "claude-3-opus", + "claude-3-sonnet", + "claude-3-haiku" + ] + }, + { + "type": "string" + } + ] + } + } + } + }, { "if": { "properties": { @@ -847,6 +925,35 @@ } } }, + { + "if": { + "properties": { + "provider": { + "enum": ["gemini-vertexai"] + } + }, + "required": ["provider"] + }, + "then": { + "properties": { + "model": { + "anyOf": [ + { + "enum": [ + "gemini-pro", + "gemini-1.5-pro-latest", + "gemini-1.5-pro", + "gemini-1.5-flash-latest", + "gemini-1.5-flash" + ] + }, + { "type": "string" } + ] + } + }, + "required": ["projectId", "region"] + } + }, { "if": { "properties": { @@ -1041,6 +1148,33 @@ } } }, + { + "if": { + "properties": { + "provider": { + "enum": ["mistral-vertexai"] + } + }, + "required": ["provider"] + }, + "then": { + "properties": { + "model": { + "anyOf": [ + { + "enum": [ + "codestral", + "mistral-nemo", + "mistral-large" + ] + }, + { "type": "string" } + ] + } + }, + "required": ["projectId", "region"] + } + }, { "if": { "properties": { diff --git a/extensions/vscode/continue_rc_schema.json b/extensions/vscode/continue_rc_schema.json index 63e4d25f5..b2b7dbb78 100644 --- a/extensions/vscode/continue_rc_schema.json +++ b/extensions/vscode/continue_rc_schema.json @@ -172,6 +172,7 @@ "openai", "free-trial", "anthropic", + "anthropic-vertexai", "cohere", "bedrock", "bedrockimport", @@ -183,9 +184,11 @@ "llama.cpp", "replicate", "gemini", + "gemini-vertexai", "lmstudio", "llamafile", "mistral", + "mistral-vertexai", "deepinfra", "groq", "fireworks", @@ -204,6 +207,7 @@ "### OpenAI\nUse 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.\n\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/openai)", "### Free Trial\nNew users can try out Continue for free using a proxy server that securely makes calls to OpenAI 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.json where it says `apiKey=\"\"` or select another model provider.\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/freetrial)", "### Anthropic\nTo get started with Anthropic models, you first need to sign up for the open beta [here](https://claude.ai/login) to obtain an API key.\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/anthropicllm)", + "### Anthropic Vertex AI\nTo get started you need to enable the [Vertex AI API](https://console.cloud.google.com/marketplace/product/google/aiplatform.googleapis.com) and set up the [Google Application Default Credentials](https://cloud.google.com/docs/authentication/provide-credentials-adc).", "### Cohere\nTo use Cohere, visit the [Cohere dashboard](https://dashboard.cohere.com/api-keys) to create an API key.\n\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/cohere)", "### Bedrock\nTo get started with Bedrock you need to sign up on AWS [here](https://aws.amazon.com/bedrock)", "### Bedrock Imported Models\nTo get started with Bedrock you need to sign up on AWS [here](https://aws.amazon.com/bedrock)", @@ -215,9 +219,11 @@ "### Llama.cpp\nllama.cpp comes with a [built-in server](https://github.com/ggerganov/llama.cpp/tree/master/examples/server#llamacppexampleserver) that can be run from source. To do this:\n\n1. Clone the repository with `git clone https://github.com/ggerganov/llama.cpp`.\n2. `cd llama.cpp`\n3. Run `make` to build the server.\n4. Download the model you'd like to use and place it in the `llama.cpp/models` directory (the best place to find models is [The Bloke on HuggingFace](https://huggingface.co/TheBloke))\n5. Run the llama.cpp server with the command below (replacing with the model you downloaded):\n\n```shell\n.\\server.exe -c 4096 --host 0.0.0.0 -t 16 --mlock -m models/codellama-7b-instruct.Q8_0.gguf\n```\n\nAfter it's up and running, you can start using Continue.\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/llamacpp)", "### Replicate\nReplicate is a hosted service that makes it easy to run ML models. To get started with Replicate:\n1. Obtain an API key from [here](https://replicate.com)\n2. Paste below\n3. Select a model preset\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/replicatellm)", "### Gemini API\nTo get started with Google Makersuite, obtain your API key from [here](https://makersuite.google.com) and paste it below.\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/geminiapi)", + "### Gemini API on Vertex AI\nTo get started you need to enable the [Vertex AI API](https://console.cloud.google.com/marketplace/product/google/aiplatform.googleapis.com) and set up the [Google Application Default Credentials](https://cloud.google.com/docs/authentication/provide-credentials-adc).", "### LMStudio\nLMStudio provides a professional and well-designed GUI for exploring, configuring, and serving LLMs. It is available on both Mac and Windows. To get started:\n1. Download from [lmstudio.ai](https://lmstudio.ai/) and open the application\n2. Search for and download the desired model from the home screen of LMStudio.\n3. In the left-bar, click the '<->' icon to open the Local Inference Server and press 'Start Server'.\n4. Once your model is loaded and the server has started, you can begin using Continue.\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/lmstudio)", "### Llamafile\nTo get started with llamafiles, find and download a binary on their [GitHub repo](https://github.com/Mozilla-Ocho/llamafile#binary-instructions). Then run it with the following command:\n\n```shell\nchmod +x ./llamafile\n./llamafile\n```\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/llamafile)", "### Mistral API\n\nTo get access to the Mistral API, obtain your API key from the [Mistral platform](https://docs.mistral.ai/)", + "### Mistral API on Vertex AI\nTo get started you need to enable the [Vertex AI API](https://console.cloud.google.com/marketplace/product/google/aiplatform.googleapis.com) and set up the [Google Application Default Credentials](https://cloud.google.com/docs/authentication/provide-credentials-adc).", "### DeepInfra\n\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/deepinfra)", "### Groq\nGroq provides extremely fast inference of open-source language models. To get started, obtain an API key from [their console](https://console.groq.com/keys).", "### Fireworks\nFireworks is a fast inference engine for open-source language models. To get started, obtain an API key from [their console](https://fireworks.ai/api-keys).", @@ -262,7 +268,36 @@ "eu-central-1", "ap-southeast-1", "ap-northeast-1", - "ap-south-1" + "ap-south-1", + "us-central1", + "us-east1", + "us-east4", + "us-east5", + "us-west1", + "us-west4", + "us-south1", + "northamerica-northeast1", + "southamerica-east1", + "europe-central2", + "europe-north1", + "europe-west1", + "europe-west2", + "europe-west3", + "europe-west4", + "europe-west6", + "europe-west8", + "europe-west9", + "europe-southwest1", + "asia-east1", + "asia-east2", + "asia-south1", + "asia-northeast1", + "asia-northeast3", + "asia-southeast1", + "australia-southeast1", + "me-central1", + "me-central2", + "me-west1" ], "type": "string" }, @@ -809,6 +844,53 @@ } } }, + { + "if": { + "properties": { + "provider": { + "enum": [ + "anthropic-vertexai" + ] + } + }, + "required": [ + "provider" + ] + }, + "then": { + "properties": { + "cacheBehavior": { + "title": "Caching Behavior", + "description": "Options for the prompt caching", + "properties": { + "cacheSystemMessage": { + "type": "boolean" + }, + "cacheConversation": { + "type": "boolean" + } + } + }, + "model": { + "anyOf": [ + { + "enum": [ + "claude-3-5-opus", + "claude-3-5-sonnet", + "claude-3-5-haiku", + "claude-3-opus", + "claude-3-sonnet", + "claude-3-haiku" + ] + }, + { + "type": "string" + } + ] + } + } + } + }, { "if": { "properties": { @@ -923,6 +1005,44 @@ } } }, + { + "if": { + "properties": { + "provider": { + "enum": [ + "gemini-vertexai" + ] + } + }, + "required": [ + "provider" + ] + }, + "then": { + "properties": { + "model": { + "anyOf": [ + { + "enum": [ + "gemini-pro", + "gemini-1.5-pro-latest", + "gemini-1.5-pro", + "gemini-1.5-flash-latest", + "gemini-1.5-flash" + ] + }, + { + "type": "string" + } + ] + } + }, + "required": [ + "projectId", + "region" + ] + } + }, { "if": { "properties": { @@ -1135,6 +1255,42 @@ } } }, + { + "if": { + "properties": { + "provider": { + "enum": [ + "mistral-vertexai" + ] + } + }, + "required": [ + "provider" + ] + }, + "then": { + "properties": { + "model": { + "anyOf": [ + { + "enum": [ + "codestral", + "mistral-nemo", + "mistral-large" + ] + }, + { + "type": "string" + } + ] + } + }, + "required": [ + "projectId", + "region" + ] + } + }, { "if": { "properties": { diff --git a/gui/package-lock.json b/gui/package-lock.json index 6da1e7b08..e86bfa61f 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -117,6 +117,7 @@ "dotenv": "^16.4.5", "fastest-levenshtein": "^1.0.16", "follow-redirects": "^1.15.5", + "google-auth-library": "^9.14.2", "handlebars": "^4.7.8", "http-proxy-agent": "^7.0.1", "https-proxy-agent": "^7.0.3",