Merge pull request #5759 from continuedev/nate/dev-data-updates
Fix dev data paper cuts
This commit is contained in:
commit
c51568250f
16 changed files with 436 additions and 276 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -244,7 +244,7 @@ export class CompletionProvider {
|
|||
prefix,
|
||||
suffix,
|
||||
prompt,
|
||||
modelProvider: llm.providerName,
|
||||
modelProvider: llm.underlyingProviderName,
|
||||
modelName: llm.model,
|
||||
completionOptions,
|
||||
cacheHit,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
3
core/index.d.ts
vendored
3
core/index.d.ts
vendored
|
|
@ -93,6 +93,7 @@ export interface ILLM
|
|||
extends Omit<LLMOptions, RequiredLLMOptions>,
|
||||
Required<Pick<LLMOptions, RequiredLLMOptions>> {
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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<string, any> {
|
||||
const continueProperties: ContinueProperties = {
|
||||
apiKeyLocation: this.apiKeyLocation,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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<string, (model: string) => 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;
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
43
packages/config-yaml/src/modelName.test.ts
Normal file
43
packages/config-yaml/src/modelName.test.ts
Normal file
|
|
@ -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");
|
||||
});
|
||||
});
|
||||
19
packages/config-yaml/src/modelName.ts
Normal file
19
packages/config-yaml/src/modelName.ts
Normal file
|
|
@ -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 };
|
||||
}
|
||||
|
|
@ -9,4 +9,5 @@ export const editInteractionEventAllSchema = baseDevDataAllSchema.extend({
|
|||
modelTitle: z.string(),
|
||||
prompt: z.string(),
|
||||
completion: z.string(),
|
||||
filepath: z.string(),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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 =
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue