diff --git a/binary/test/binary.test.ts b/binary/test/binary.test.ts index fb1be39bb..307368ce8 100644 --- a/binary/test/binary.test.ts +++ b/binary/test/binary.test.ts @@ -226,6 +226,7 @@ describe("Test Suite", () => { title: "Test Model", provider: "openai", model: "gpt-3.5-turbo", + underlyingProviderName: "openai", }; await messenger.request("config/addModel", { model, @@ -252,6 +253,7 @@ describe("Test Suite", () => { title: "Test Model", provider: "mock", model: "gpt-3.5-turbo", + underlyingProviderName: "mock", }; await messenger.request("config/addModel", { model, diff --git a/core/autocomplete/CompletionProvider.ts b/core/autocomplete/CompletionProvider.ts index fd9cf2923..171a6df98 100644 --- a/core/autocomplete/CompletionProvider.ts +++ b/core/autocomplete/CompletionProvider.ts @@ -244,7 +244,7 @@ export class CompletionProvider { prefix, suffix, prompt, - modelProvider: llm.providerName, + modelProvider: llm.underlyingProviderName, modelName: llm.model, completionOptions, cacheHit, diff --git a/core/config/load.ts b/core/config/load.ts index de08ecfc7..e3d83a6b6 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -627,6 +627,7 @@ async function intermediateToFinalConfig({ function llmToSerializedModelDescription(llm: ILLM): ModelDescription { return { provider: llm.providerName, + underlyingProviderName: llm.underlyingProviderName, model: llm.model, title: llm.title ?? llm.model, apiKey: llm.apiKey, diff --git a/core/index.d.ts b/core/index.d.ts index 1a46f53d0..703c98b87 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -93,6 +93,7 @@ export interface ILLM extends Omit, Required> { get providerName(): string; + get underlyingProviderName(): string; complete( prompt: string, @@ -1035,6 +1036,7 @@ export interface ModelCapability { export interface ModelDescription { title: string; provider: string; + underlyingProviderName: string; model: string; apiKey?: string; @@ -1333,6 +1335,7 @@ export interface AnalyticsConfig { export interface JSONModelDescription { title: string; provider: string; + underlyingProviderName: string; model: string; apiKey?: string; apiBase?: string; diff --git a/core/llm/index.ts b/core/llm/index.ts index 68623d2e2..0d25d882c 100644 --- a/core/llm/index.ts +++ b/core/llm/index.ts @@ -88,6 +88,14 @@ export abstract class BaseLLM implements ILLM { return (this.constructor as typeof BaseLLM).providerName; } + /** + * This exists because for the continue-proxy, sometimes we want to get the value of the underlying provider that is used on the server + * For example, the underlying provider should always be sent with dev data + */ + get underlyingProviderName(): string { + return this.providerName; + } + supportsFim(): boolean { return false; } @@ -332,7 +340,7 @@ export abstract class BaseLLM implements ILLM { name: "tokensGenerated", data: { model: model, - provider: this.providerName, + provider: this.underlyingProviderName, promptTokens: promptTokens, generatedTokens: generatedTokens, }, diff --git a/core/llm/llms/stubs/ContinueProxy.ts b/core/llm/llms/stubs/ContinueProxy.ts index 29c892bc8..6cd5c6c96 100644 --- a/core/llm/llms/stubs/ContinueProxy.ts +++ b/core/llm/llms/stubs/ContinueProxy.ts @@ -1,6 +1,7 @@ import { ContinueProperties, decodeSecretLocation, + parseProxyModelName, SecretType, } from "@continuedev/config-yaml"; @@ -47,6 +48,11 @@ class ContinueProxy extends OpenAI { useLegacyCompletionsEndpoint: false, }; + get underlyingProviderName(): string { + const { provider } = parseProxyModelName(this.model); + return provider; + } + protected extraBodyProperties(): Record { const continueProperties: ContinueProperties = { apiKeyLocation: this.apiKeyLocation, diff --git a/core/llm/toolSupport.test.ts b/core/llm/toolSupport.test.ts index 416a4c9eb..d3100a61b 100644 --- a/core/llm/toolSupport.test.ts +++ b/core/llm/toolSupport.test.ts @@ -6,39 +6,57 @@ describe("PROVIDER_TOOL_SUPPORT", () => { const supportsFn = PROVIDER_TOOL_SUPPORT["continue-proxy"]; it("should return true for Claude 3.5 models", () => { - expect(supportsFn("claude-3-5-sonnet")).toBe(true); - expect(supportsFn("claude-3.5-sonnet")).toBe(true); + expect( + supportsFn("ownerSlug/packageSlug/anthropic/claude-3-5-sonnet"), + ).toBe(true); + expect( + supportsFn("ownerSlug/packageSlug/anthropic/claude-3.5-sonnet"), + ).toBe(true); }); it("should return true for Claude 3.7 models", () => { - expect(supportsFn("claude-3-7-haiku")).toBe(true); - expect(supportsFn("claude-3.7-sonnet")).toBe(true); + expect( + supportsFn("ownerSlug/packageSlug/anthropic/claude-3-7-haiku"), + ).toBe(true); + expect( + supportsFn("ownerSlug/packageSlug/anthropic/claude-3.7-sonnet"), + ).toBe(true); }); it("should return true for GPT-4 models", () => { - expect(supportsFn("gpt-4-turbo")).toBe(true); - expect(supportsFn("gpt-4-1106-preview")).toBe(true); + expect(supportsFn("ownerSlug/packageSlug/openai/gpt-4-turbo")).toBe(true); + expect( + supportsFn("ownerSlug/packageSlug/openai/gpt-4-1106-preview"), + ).toBe(true); }); it("should return true for O3 models", () => { - expect(supportsFn("o3-preview")).toBe(true); + expect(supportsFn("ownerSlug/packageSlug/openai/o3-preview")).toBe(true); }); it("should return true for Gemini models", () => { - expect(supportsFn("gemini-pro")).toBe(true); - expect(supportsFn("gemini-1.5-pro")).toBe(true); + expect(supportsFn("ownerSlug/packageSlug/gemini/gemini-pro")).toBe(true); + expect(supportsFn("ownerSlug/packageSlug/gemini/gemini-1.5-pro")).toBe( + true, + ); }); it("should return false for unsupported models", () => { - expect(supportsFn("gpt-3.5-turbo")).toBe(false); - expect(supportsFn("claude-2")).toBe(false); - expect(supportsFn("llama-3")).toBe(false); + expect(supportsFn("ownerSlug/packageSlug/openai/gpt-3.5-turbo")).toBe( + false, + ); + expect(supportsFn("ownerSlug/packageSlug/anthropic/claude-2")).toBe( + false, + ); + expect(supportsFn("ownerSlug/packageSlug/together/llama-3")).toBe(false); }); it("should handle case insensitivity", () => { - expect(supportsFn("CLAUDE-3-5-sonnet")).toBe(true); - expect(supportsFn("GPT-4-turbo")).toBe(true); - expect(supportsFn("GEMINI-pro")).toBe(true); + expect( + supportsFn("ownerSlug/packageSlug/anthropic/CLAUDE-3-5-sonnet"), + ).toBe(true); + expect(supportsFn("ownerSlug/packageSlug/openai/GPT-4-turbo")).toBe(true); + expect(supportsFn("ownerSlug/packageSlug/gemini/GEMINI-pro")).toBe(true); }); }); @@ -56,8 +74,8 @@ describe("PROVIDER_TOOL_SUPPORT", () => { }); it("should return undefined for unsupported models", () => { - expect(supportsFn("claude-2")).toBeUndefined(); - expect(supportsFn("claude-instant")).toBeUndefined(); + expect(supportsFn("claude-2")).toBe(false); + expect(supportsFn("claude-instant")).toBe(false); }); it("should handle case insensitivity", () => { @@ -81,8 +99,8 @@ describe("PROVIDER_TOOL_SUPPORT", () => { }); it("should return undefined for unsupported models", () => { - expect(supportsFn("gpt-3.5-turbo")).toBeUndefined(); - expect(supportsFn("davinci")).toBeUndefined(); + expect(supportsFn("gpt-3.5-turbo")).toBe(false); + expect(supportsFn("davinci")).toBe(false); }); it("should handle case insensitivity", () => { @@ -115,31 +133,49 @@ describe("PROVIDER_TOOL_SUPPORT", () => { const supportsFn = PROVIDER_TOOL_SUPPORT["bedrock"]; it("should return true for Claude 3.5 Sonnet models", () => { - expect(supportsFn("anthropic.claude-3-5-sonnet-20240620-v1:0")).toBe(true); - expect(supportsFn("anthropic.claude-3.5-sonnet-20240620-v1:0")).toBe(true); + expect(supportsFn("anthropic.claude-3-5-sonnet-20240620-v1:0")).toBe( + true, + ); + expect(supportsFn("anthropic.claude-3.5-sonnet-20240620-v1:0")).toBe( + true, + ); }); it("should return true for Claude 3.7 Sonnet models", () => { - expect(supportsFn("anthropic.claude-3-7-sonnet-20240620-v1:0")).toBe(true); - expect(supportsFn("anthropic.claude-3.7-sonnet-20240620-v1:0")).toBe(true); + expect(supportsFn("anthropic.claude-3-7-sonnet-20240620-v1:0")).toBe( + true, + ); + expect(supportsFn("anthropic.claude-3.7-sonnet-20240620-v1:0")).toBe( + true, + ); }); it("should return undefined for Claude Haiku and Opus models", () => { - expect(supportsFn("anthropic.claude-3-5-haiku-20240307-v1:0")).toBeUndefined(); - expect(supportsFn("anthropic.claude-3.5-haiku-20240620-v1:0")).toBeUndefined(); - expect(supportsFn("anthropic.claude-3-7-haiku-20240620-v1:0")).toBeUndefined(); - expect(supportsFn("anthropic.claude-3-5-opus-20240620-v1:0")).toBeUndefined(); - expect(supportsFn("anthropic.claude-3.7-opus-20240620-v1:0")).toBeUndefined(); + expect(supportsFn("anthropic.claude-3-5-haiku-20240307-v1:0")).toBe( + false, + ); + expect(supportsFn("anthropic.claude-3.5-haiku-20240620-v1:0")).toBe( + false, + ); + expect(supportsFn("anthropic.claude-3-7-haiku-20240620-v1:0")).toBe( + false, + ); + expect(supportsFn("anthropic.claude-3-5-opus-20240620-v1:0")).toBe(false); + expect(supportsFn("anthropic.claude-3.7-opus-20240620-v1:0")).toBe(false); }); it("should return undefined for other unsupported models", () => { - expect(supportsFn("anthropic.claude-instant-v1")).toBeUndefined(); - expect(supportsFn("anthropic.titan-text-express-v1")).toBeUndefined(); + expect(supportsFn("anthropic.claude-instant-v1")).toBe(false); + expect(supportsFn("anthropic.titan-text-express-v1")).toBe(false); }); it("should handle case insensitivity", () => { - expect(supportsFn("ANTHROPIC.CLAUDE-3-5-SONNET-20240620-v1:0")).toBe(true); - expect(supportsFn("ANTHROPIC.CLAUDE-3.7-SONNET-20240620-v1:0")).toBe(true); + expect(supportsFn("ANTHROPIC.CLAUDE-3-5-SONNET-20240620-v1:0")).toBe( + true, + ); + expect(supportsFn("ANTHROPIC.CLAUDE-3.7-SONNET-20240620-v1:0")).toBe( + true, + ); }); }); @@ -206,9 +242,9 @@ describe("PROVIDER_TOOL_SUPPORT", () => { }); it("should return undefined for other models", () => { - expect(supportsFn("llama2")).toBeUndefined(); - expect(supportsFn("phi-2")).toBeUndefined(); - expect(supportsFn("falcon")).toBeUndefined(); + expect(supportsFn("llama2")).toBe(false); + expect(supportsFn("phi-2")).toBe(false); + expect(supportsFn("falcon")).toBe(false); }); it("should handle case insensitivity", () => { @@ -221,16 +257,16 @@ describe("PROVIDER_TOOL_SUPPORT", () => { describe("edge cases", () => { it("should handle empty model names", () => { expect(PROVIDER_TOOL_SUPPORT["continue-proxy"]("")).toBe(false); - expect(PROVIDER_TOOL_SUPPORT["anthropic"]("")).toBeUndefined(); - expect(PROVIDER_TOOL_SUPPORT["openai"]("")).toBeUndefined(); + expect(PROVIDER_TOOL_SUPPORT["anthropic"]("")).toBe(false); + expect(PROVIDER_TOOL_SUPPORT["openai"]("")).toBe(false); expect(PROVIDER_TOOL_SUPPORT["gemini"]("")).toBe(false); - expect(PROVIDER_TOOL_SUPPORT["bedrock"]("")).toBeUndefined(); - expect(PROVIDER_TOOL_SUPPORT["ollama"]("")).toBeUndefined(); + expect(PROVIDER_TOOL_SUPPORT["bedrock"]("")).toBe(false); + expect(PROVIDER_TOOL_SUPPORT["ollama"]("")).toBe(false); }); it("should handle non-existent provider", () => { // @ts-ignore - Testing runtime behavior with invalid provider - expect(PROVIDER_TOOL_SUPPORT["non-existent"]).toBeUndefined(); + expect(PROVIDER_TOOL_SUPPORT["non-existent"]).toBe(undefined); }); }); }); diff --git a/core/llm/toolSupport.ts b/core/llm/toolSupport.ts index f08e3cf8a..cb67c1112 100644 --- a/core/llm/toolSupport.ts +++ b/core/llm/toolSupport.ts @@ -1,238 +1,273 @@ -export const PROVIDER_TOOL_SUPPORT: Record< - string, - (model: string) => boolean | undefined -> = { - "continue-proxy": (model) => { - // see getContinueProxyModelName - const provider = model.split("/")[2]; - const _model = model.split("/")[3]; - if (provider && _model && provider !== "continue-proxy") { - const fn = PROVIDER_TOOL_SUPPORT[provider]; - if (fn) { - return fn(_model); +import { parseProxyModelName } from "@continuedev/config-yaml"; + +export const PROVIDER_TOOL_SUPPORT: Record boolean> = + { + "continue-proxy": (model) => { + try { + const { provider, model: _model } = parseProxyModelName(model); + if (provider && _model && provider !== "continue-proxy") { + const fn = PROVIDER_TOOL_SUPPORT[provider]; + if (fn) { + return fn(_model); + } + } + } catch (e) {} + + return [ + "claude-3-5", + "claude-3.5", + "claude-3-7", + "claude-3.7", + "claude-4", + "gpt-4", + "o3", + "gemini", + ].some((part) => model.toLowerCase().startsWith(part)); + }, + anthropic: (model) => { + if ( + [ + "claude-3-5", + "claude-3.5", + "claude-3-7", + "claude-3.7", + "claude-4", + ].some((part) => model.toLowerCase().startsWith(part)) + ) { + return true; } - } - return [ - "claude-3-5", - "claude-3.5", - "claude-3-7", - "claude-3.7", - "claude-sonnet-4", - "gpt-4", - "o3", - "gemini", - ].some((part) => model.toLowerCase().startsWith(part)); - }, - anthropic: (model) => { - if ( - ["claude-3-5", "claude-3.5", "claude-3-7", "claude-3.7","claude-sonnet-4"].some((part) => - model.toLowerCase().startsWith(part), + + return false; + }, + azure: (model) => { + if ( + model.toLowerCase().startsWith("gpt-4") || + model.toLowerCase().startsWith("o3") ) - ) { - return true; - } - }, - azure: (model) => { - if ( - model.toLowerCase().startsWith("gpt-4") || - model.toLowerCase().startsWith("o3") - ) - return true; - return false; - }, - openai: (model) => { - // https://platform.openai.com/docs/guides/function-calling#models-supporting-function-calling - if ( - model.toLowerCase().startsWith("gpt-4") || - model.toLowerCase().startsWith("o3") - ) { - return true; - } - // firworks-ai https://docs.fireworks.ai/guides/function-calling - if (model.startsWith("accounts/fireworks/models/")) { - switch (model.substring(26)) { - case "llama-v3p1-405b-instruct": - case "llama-v3p1-70b-instruct": - case "qwen2p5-72b-instruct": - case "firefunction-v1": - case "firefunction-v2": + return true; + return false; + }, + openai: (model) => { + // https://platform.openai.com/docs/guides/function-calling#models-supporting-function-calling + if ( + model.toLowerCase().startsWith("gpt-4") || + model.toLowerCase().startsWith("o3") + ) { + return true; + } + // firworks-ai https://docs.fireworks.ai/guides/function-calling + if (model.startsWith("accounts/fireworks/models/")) { + switch (model.substring(26)) { + case "llama-v3p1-405b-instruct": + case "llama-v3p1-70b-instruct": + case "qwen2p5-72b-instruct": + case "firefunction-v1": + case "firefunction-v2": + return true; + default: + return false; + } + } + + return false; + }, + gemini: (model) => { + // All gemini models support function calling + return model.toLowerCase().includes("gemini"); + }, + vertexai: (model) => { + // All gemini models except flash 2.0 lite support function calling + return ( + model.toLowerCase().includes("gemini") && + !model.toLowerCase().includes("lite") + ); + }, + bedrock: (model) => { + // For Bedrock, only support Claude Sonnet models with versions 3.5/3-5 and 3.7/3-7 + if ( + model.toLowerCase().includes("sonnet") && + [ + "claude-3-5", + "claude-3.5", + "claude-3-7", + "claude-3.7", + "claude-4", + ].some((part) => model.toLowerCase().includes(part)) + ) { + return true; + } + + return false; + }, + mistral: (model) => { + // https://docs.mistral.ai/capabilities/function_calling/ + return ( + !model.toLowerCase().includes("mamba") && + [ + "codestral", + "mistral-large", + "mistral-small", + "pixtral", + "ministral", + "mistral-nemo", + "devstral", + ].some((part) => model.toLowerCase().includes(part)) + ); + }, + // https://ollama.com/search?c=tools + ollama: (model) => { + let modelName = ""; + // Extract the model name after the last slash to support other registries + if (model.includes("/")) { + let parts = model.split("/"); + modelName = parts[parts.length - 1]; + } else { + modelName = model; + } + + if ( + ["vision", "math", "guard", "mistrallite", "mistral-openorca"].some( + (part) => modelName.toLowerCase().includes(part), + ) + ) { + return false; + } + if ( + [ + "cogito", + "llama3.3", + "qwq", + "llama3.2", + "llama3.1", + "qwen2", + "qwen3", + "mixtral", + "command-r", + "smollm2", + "hermes3", + "athene-v2", + "nemotron", + "llama3-groq", + "granite3", + "granite-3", + "aya-expanse", + "firefunction-v2", + "mistral", + "devstral", + ].some((part) => modelName.toLowerCase().includes(part)) + ) { + return true; + } + + return false; + }, + sambanova: (model) => { + // https://docs.sambanova.ai/cloud/docs/capabilities/function-calling + if ( + model.toLowerCase().startsWith("meta-llama-3") || + model.toLowerCase().includes("llama-4") || + model.toLowerCase().includes("deepseek") + ) { + return true; + } + + return false; + }, + deepseek: (model) => { + if (model !== "deepseek-reasoner") { + return true; + } + + return false; + }, + watsonx: (model) => { + if (model.toLowerCase().includes("guard")) { + return false; + } + if ( + [ + "llama-3", + "llama-4", + "mistral", + "codestral", + "granite-3", + "devstral", + ].some((part) => model.toLowerCase().includes(part)) + ) { + return true; + } + + return false; + }, + openrouter: (model) => { + // https://openrouter.ai/models?fmt=cards&supported_parameters=tools + if ( + ["vision", "math", "guard", "mistrallite", "mistral-openorca"].some( + (part) => model.toLowerCase().includes(part), + ) + ) { + return false; + } + + const supportedPrefixes = [ + "openai/gpt-3.5", + "openai/gpt-4", + "openai/o1", + "openai/o3", + "openai/o4", + "anthropic/claude-3", + "anthropic/claude-4", + "microsoft/phi-3", + "google/gemini-flash-1.5", + "google/gemini-2", + "google/gemini-pro", + "x-ai/grok", + "qwen/qwen3", + "qwen/qwen-", + "cohere/command-r", + "ai21/jamba-1.6", + "mistralai/mistral", + "mistralai/ministral", + "mistralai/codestral", + "mistralai/mixtral", + "mistral/ministral", + "mistral/devstral", + "mistralai/pixtral", + "meta-llama/llama-3.3", + "amazon/nova", + "deepseek/deepseek-r1", + "deepseek/deepseek-chat", + "meta-llama/llama-4", + "all-hands/openhands-lm-32b", + ]; + for (const prefix of supportedPrefixes) { + if (model.toLowerCase().startsWith(prefix)) { return true; - default: - return false; + } + } + + const specificModels = [ + "qwen/qwq-32b", + "qwen/qwen-2.5-72b-instruct", + "meta-llama/llama-3.2-3b-instruct", + "meta-llama/llama-3-8b-instruct", + "meta-llama/llama-3-70b-instruct", + "arcee-ai/caller-large", + "nousresearch/hermes-3-llama-3.1-70b", + ]; + for (const model of specificModels) { + if (model.toLowerCase() === model) { + return true; + } + } + + const supportedContains = ["llama-3.1"]; + for (const model of supportedContains) { + if (model.toLowerCase().includes(model)) { + return true; + } } - } - }, - gemini: (model) => { - // All gemini models support function calling - return model.toLowerCase().includes("gemini"); - }, - vertexai: (model) => { - // All gemini models except flash 2.0 lite support function calling - return ( - model.toLowerCase().includes("gemini") && - !model.toLowerCase().includes("lite") - ); - }, - bedrock: (model) => { - // For Bedrock, only support Claude Sonnet models with versions 3.5/3-5 and 3.7/3-7 - if ( - model.toLowerCase().includes("sonnet") && - ["claude-3-5", "claude-3.5", "claude-3-7", "claude-3.7","claude-sonnet-4"].some((part) => - model.toLowerCase().includes(part), - ) - ) { - return true; - } - }, - mistral: (model) => { - // https://docs.mistral.ai/capabilities/function_calling/ - return ( - !model.toLowerCase().includes("mamba") && - [ - "devstral", - "codestral", - "mistral-large", - "mistral-small", - "pixtral", - "ministral", - "mistral-nemo", - ].some((part) => model.toLowerCase().includes(part)) - ); - }, - // https://ollama.com/search?c=tools - ollama: (model) => { - let modelName = ""; - // Extract the model name after the last slash to support other registries - if (model.includes("/")) { - let parts = model.split("/"); - modelName = parts[parts.length - 1]; - } else { - modelName = model; - } - if ( - ["vision", "math", "guard", "mistrallite", "mistral-openorca"].some( - (part) => modelName.toLowerCase().includes(part), - ) - ) { return false; - } - if ( - [ - "cogito", - "llama3.3", - "qwq", - "llama3.2", - "llama3.1", - "qwen2", - "qwen3", - "mixtral", - "command-r", - "smollm2", - "hermes3", - "athene-v2", - "nemotron", - "llama3-groq", - "granite3", - "granite-3", - "aya-expanse", - "firefunction-v2", - "mistral", - "devstral", - ].some((part) => modelName.toLowerCase().includes(part)) - ) { - return true; - } - }, - sambanova: (model) => { - // https://docs.sambanova.ai/cloud/docs/capabilities/function-calling - if ( - model.toLowerCase().startsWith("meta-llama-3") || - model.toLowerCase().includes("llama-4") || - model.toLowerCase().includes("deepseek") - ) { - return true; - } - }, - deepseek: (model) => { - if (model !== "deepseek-reasoner") { - return true; - } - }, - watsonx: (model) => { - if (model.toLowerCase().includes("guard")) return false; - if ( - ["llama-3", "llama-4", "mistral", "codestral", "granite-3"].some((part) => - model.toLowerCase().includes(part), - ) - ) - return true; - }, - openrouter: (model) => { - // https://openrouter.ai/models?fmt=cards&supported_parameters=tools - if ( - ["vision", "math", "guard", "mistrallite", "mistral-openorca"].some( - (part) => model.toLowerCase().includes(part), - ) - ) { - return false; - } - - const supportedPrefixes = [ - "openai/gpt-3.5", - "openai/gpt-4", - "openai/o1", - "openai/o3", - "openai/o4", - "anthropic/claude-3", - "microsoft/phi-3", - "google/gemini-flash-1.5", - "google/gemini-2", - "google/gemini-pro", - "x-ai/grok", - "qwen/qwen3", - "qwen/qwen-", - "cohere/command-r", - "ai21/jamba-1.6", - "mistralai/mistral", - "mistralai/ministral", - "mistralai/codestral", - "mistralai/mixtral", - "mistral/ministral", - "mistralai/pixtral", - "meta-llama/llama-3.3", - "amazon/nova", - "deepseek/deepseek-r1", - "deepseek/deepseek-chat", - "meta-llama/llama-4", - "all-hands/openhands-lm-32b", - ]; - for (const prefix of supportedPrefixes) { - if (model.toLowerCase().startsWith(prefix)) { - return true; - } - } - - const specificModels = [ - "qwen/qwq-32b", - "qwen/qwen-2.5-72b-instruct", - "meta-llama/llama-3.2-3b-instruct", - "meta-llama/llama-3-8b-instruct", - "meta-llama/llama-3-70b-instruct", - "arcee-ai/caller-large", - "nousresearch/hermes-3-llama-3.1-70b", - ]; - for (const model of specificModels) { - if (model.toLowerCase() === model) { - return true; - } - } - - const supportedContains = ["llama-3.1"]; - for (const model of supportedContains) { - if (model.toLowerCase().includes(model)) { - return true; - } - } - }, -}; + }, + }; diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts index 9008969c2..e5f054caa 100644 --- a/extensions/vscode/src/extension/VsCodeMessenger.ts +++ b/extensions/vscode/src/extension/VsCodeMessenger.ts @@ -236,8 +236,9 @@ export class VsCodeMessenger { data: { prompt: stripImages(prompt), completion: fileAfterEdit ?? "", - modelProvider: model.providerName, + modelProvider: model.underlyingProviderName, modelTitle: model.title ?? "", + filepath: msg.data.range.filepath, }, }); diff --git a/gui/src/components/OnboardingCard/components/BestExperienceConfigForm.tsx b/gui/src/components/OnboardingCard/components/BestExperienceConfigForm.tsx index d739a8434..0929aad8b 100644 --- a/gui/src/components/OnboardingCard/components/BestExperienceConfigForm.tsx +++ b/gui/src/components/OnboardingCard/components/BestExperienceConfigForm.tsx @@ -40,6 +40,7 @@ function BestExperienceConfigForm({ const chatModelConfig = { model: chatModel.params.model, provider: chatProvider.provider, + underlyingProviderName: chatProvider.provider, apiKey: chatApiKey, title: chatModel.params.title, }; @@ -47,6 +48,7 @@ function BestExperienceConfigForm({ const repoMapConfig = { model: repoMapModel.params.model, provider: chatProvider.provider, + underlyingProviderName: chatProvider.provider, apiKey: chatApiKey, title: repoMapModel.params.title, }; @@ -54,6 +56,7 @@ function BestExperienceConfigForm({ const autocompleteModelConfig = { title: autocompleteModel.params.title, provider: autocompleteProvider.provider, + underlyingProviderName: autocompleteProvider.provider, model: autocompleteModel.params.model, apiKey: autocompleteApiKey, }; diff --git a/gui/src/redux/thunks/streamNormalInput.ts b/gui/src/redux/thunks/streamNormalInput.ts index 43e431271..8776aa1a6 100644 --- a/gui/src/redux/thunks/streamNormalInput.ts +++ b/gui/src/redux/thunks/streamNormalInput.ts @@ -79,7 +79,7 @@ export const streamNormalInput = createAsyncThunk< data: { prompt: next.value.prompt, completion: next.value.completion, - modelProvider: selectedChatModel.provider, + modelProvider: selectedChatModel.underlyingProviderName, modelTitle: selectedChatModel.title, sessionId: state.session.id, }, diff --git a/packages/config-yaml/src/index.ts b/packages/config-yaml/src/index.ts index 0a70b1c01..18a7098fb 100644 --- a/packages/config-yaml/src/index.ts +++ b/packages/config-yaml/src/index.ts @@ -8,6 +8,7 @@ export * from "./load/merge.js"; export * from "./load/proxySecretResolution.js"; export * from "./load/typeGuards.js"; export * from "./load/unroll.js"; +export * from "./modelName.js"; export * from "./registryClient.js"; export * from "./schemas/data/index.js"; export * from "./schemas/index.js"; diff --git a/packages/config-yaml/src/modelName.test.ts b/packages/config-yaml/src/modelName.test.ts new file mode 100644 index 000000000..626d4b379 --- /dev/null +++ b/packages/config-yaml/src/modelName.test.ts @@ -0,0 +1,43 @@ +import { parseProxyModelName } from "./modelName.js"; + +describe("parseProxyModelName", () => { + it("parses a basic model name correctly", () => { + const result = parseProxyModelName("owner/package/provider/model"); + expect(result).toEqual({ + ownerSlug: "owner", + packageSlug: "package", + provider: "provider", + model: "model", + }); + }); + + it("handles model names with slashes in the model part", () => { + const result = parseProxyModelName( + "owner/package/provider/model/with/slashes", + ); + expect(result).toEqual({ + ownerSlug: "owner", + packageSlug: "package", + provider: "provider", + model: "model/with/slashes", + }); + }); + + it("throws an error for invalid model formats (missing provider)", () => { + expect(() => { + parseProxyModelName("owner/package"); + }).toThrow("Invalid model format"); + }); + + it("throws an error for invalid model formats (missing model)", () => { + expect(() => { + parseProxyModelName("owner/package/provider"); + }).toThrow("Invalid model format"); + }); + + it("throws an error for empty string", () => { + expect(() => { + parseProxyModelName(""); + }).toThrow("Invalid model format"); + }); +}); diff --git a/packages/config-yaml/src/modelName.ts b/packages/config-yaml/src/modelName.ts new file mode 100644 index 000000000..5c15f790b --- /dev/null +++ b/packages/config-yaml/src/modelName.ts @@ -0,0 +1,19 @@ +export interface ProxyModelName { + ownerSlug: string; + packageSlug: string; + provider: string; + model: string; +} + +export function parseProxyModelName(modelName: string): ProxyModelName { + const parts = modelName.split("/"); + + const [ownerSlug, packageSlug, provider, ...modelParts] = parts; + const model = modelParts.join("/"); + + if (!provider || !model) { + throw new Error("Invalid model format"); + } + + return { provider, model, ownerSlug, packageSlug }; +} diff --git a/packages/config-yaml/src/schemas/data/editInteraction/index.ts b/packages/config-yaml/src/schemas/data/editInteraction/index.ts index fd1ba3657..86613d762 100644 --- a/packages/config-yaml/src/schemas/data/editInteraction/index.ts +++ b/packages/config-yaml/src/schemas/data/editInteraction/index.ts @@ -9,4 +9,5 @@ export const editInteractionEventAllSchema = baseDevDataAllSchema.extend({ modelTitle: z.string(), prompt: z.string(), completion: z.string(), + filepath: z.string(), }); diff --git a/packages/config-yaml/src/schemas/data/editInteraction/v0.2.0.ts b/packages/config-yaml/src/schemas/data/editInteraction/v0.2.0.ts index c95e163c9..ef0b0c952 100644 --- a/packages/config-yaml/src/schemas/data/editInteraction/v0.2.0.ts +++ b/packages/config-yaml/src/schemas/data/editInteraction/v0.2.0.ts @@ -15,6 +15,7 @@ export const editInteractionEventSchema_0_2_0 = completion: true, modelTitle: true, modelProvider: true, + filepath: true, }); export const editInteractionEventSchema_0_2_0_noCode =