Changesets · Branches · Tags · Compare
| Changeset | 2b5a128962b1f24ebc4fe17ff1fd785f6cd35d510031617741745a56a433ee50 |
|---|---|
| Author | Nate <sestinj@gmail.com> · 2025-05-21 14:58 -07:00 |
| Committer | Nate <sestinj@gmail.com> · 2025-05-21 14:58 -07:00 |
| Parents | 71fd2e7d4456 |
2 files changed
modified core/llm/toolSupport.test.ts +76 −40
| @@ -6,39 +6,57 @@ | ||
| 6 | 6 | const supportsFn = PROVIDER_TOOL_SUPPORT["continue-proxy"]; |
| 7 | 7 | |
| 8 | 8 | it("should return true for Claude 3.5 models", () => { |
| 9 | - expect(supportsFn("claude-3-5-sonnet")).toBe(true); | |
| 10 | - expect(supportsFn("claude-3.5-sonnet")).toBe(true); | |
| 9 | + expect( | |
| 10 | + supportsFn("ownerSlug/packageSlug/anthropic/claude-3-5-sonnet"), | |
| 11 | + ).toBe(true); | |
| 12 | + expect( | |
| 13 | + supportsFn("ownerSlug/packageSlug/anthropic/claude-3.5-sonnet"), | |
| 14 | + ).toBe(true); | |
| 11 | 15 | }); |
| 12 | 16 | |
| 13 | 17 | it("should return true for Claude 3.7 models", () => { |
| 14 | - expect(supportsFn("claude-3-7-haiku")).toBe(true); | |
| 15 | - expect(supportsFn("claude-3.7-sonnet")).toBe(true); | |
| 18 | + expect( | |
| 19 | + supportsFn("ownerSlug/packageSlug/anthropic/claude-3-7-haiku"), | |
| 20 | + ).toBe(true); | |
| 21 | + expect( | |
| 22 | + supportsFn("ownerSlug/packageSlug/anthropic/claude-3.7-sonnet"), | |
| 23 | + ).toBe(true); | |
| 16 | 24 | }); |
| 17 | 25 | |
| 18 | 26 | it("should return true for GPT-4 models", () => { |
| 19 | - expect(supportsFn("gpt-4-turbo")).toBe(true); | |
| 20 | - expect(supportsFn("gpt-4-1106-preview")).toBe(true); | |
| 27 | + expect(supportsFn("ownerSlug/packageSlug/openai/gpt-4-turbo")).toBe(true); | |
| 28 | + expect( | |
| 29 | + supportsFn("ownerSlug/packageSlug/openai/gpt-4-1106-preview"), | |
| 30 | + ).toBe(true); | |
| 21 | 31 | }); |
| 22 | 32 | |
| 23 | 33 | it("should return true for O3 models", () => { |
| 24 | - expect(supportsFn("o3-preview")).toBe(true); | |
| 34 | + expect(supportsFn("ownerSlug/packageSlug/openai/o3-preview")).toBe(true); | |
| 25 | 35 | }); |
| 26 | 36 | |
| 27 | 37 | it("should return true for Gemini models", () => { |
| 28 | - expect(supportsFn("gemini-pro")).toBe(true); | |
| 29 | - expect(supportsFn("gemini-1.5-pro")).toBe(true); | |
| 38 | + expect(supportsFn("ownerSlug/packageSlug/gemini/gemini-pro")).toBe(true); | |
| 39 | + expect(supportsFn("ownerSlug/packageSlug/gemini/gemini-1.5-pro")).toBe( | |
| 40 | + true, | |
| 41 | + ); | |
| 30 | 42 | }); |
| 31 | 43 | |
| 32 | 44 | it("should return false for unsupported models", () => { |
| 33 | - expect(supportsFn("gpt-3.5-turbo")).toBe(false); | |
| 34 | - expect(supportsFn("claude-2")).toBe(false); | |
| 35 | - expect(supportsFn("llama-3")).toBe(false); | |
| 45 | + expect(supportsFn("ownerSlug/packageSlug/openai/gpt-3.5-turbo")).toBe( | |
| 46 | + false, | |
| 47 | + ); | |
| 48 | + expect(supportsFn("ownerSlug/packageSlug/anthropic/claude-2")).toBe( | |
| 49 | + false, | |
| 50 | + ); | |
| 51 | + expect(supportsFn("ownerSlug/packageSlug/together/llama-3")).toBe(false); | |
| 36 | 52 | }); |
| 37 | 53 | |
| 38 | 54 | it("should handle case insensitivity", () => { |
| 39 | - expect(supportsFn("CLAUDE-3-5-sonnet")).toBe(true); | |
| 40 | - expect(supportsFn("GPT-4-turbo")).toBe(true); | |
| 41 | - expect(supportsFn("GEMINI-pro")).toBe(true); | |
| 55 | + expect( | |
| 56 | + supportsFn("ownerSlug/packageSlug/anthropic/CLAUDE-3-5-sonnet"), | |
| 57 | + ).toBe(true); | |
| 58 | + expect(supportsFn("ownerSlug/packageSlug/openai/GPT-4-turbo")).toBe(true); | |
| 59 | + expect(supportsFn("ownerSlug/packageSlug/gemini/GEMINI-pro")).toBe(true); | |
| 42 | 60 | }); |
| 43 | 61 | }); |
| 44 | 62 | |
| @@ -56,8 +74,8 @@ | ||
| 56 | 74 | }); |
| 57 | 75 | |
| 58 | 76 | it("should return undefined for unsupported models", () => { |
| 59 | - expect(supportsFn("claude-2")).toBeUndefined(); | |
| 60 | - expect(supportsFn("claude-instant")).toBeUndefined(); | |
| 77 | + expect(supportsFn("claude-2")).toBe(false); | |
| 78 | + expect(supportsFn("claude-instant")).toBe(false); | |
| 61 | 79 | }); |
| 62 | 80 | |
| 63 | 81 | it("should handle case insensitivity", () => { |
| @@ -81,8 +99,8 @@ | ||
| 81 | 99 | }); |
| 82 | 100 | |
| 83 | 101 | it("should return undefined for unsupported models", () => { |
| 84 | - expect(supportsFn("gpt-3.5-turbo")).toBeUndefined(); | |
| 85 | - expect(supportsFn("davinci")).toBeUndefined(); | |
| 102 | + expect(supportsFn("gpt-3.5-turbo")).toBe(false); | |
| 103 | + expect(supportsFn("davinci")).toBe(false); | |
| 86 | 104 | }); |
| 87 | 105 | |
| 88 | 106 | it("should handle case insensitivity", () => { |
| @@ -115,31 +133,49 @@ | ||
| 115 | 133 | const supportsFn = PROVIDER_TOOL_SUPPORT["bedrock"]; |
| 116 | 134 | |
| 117 | 135 | it("should return true for Claude 3.5 Sonnet models", () => { |
| 118 | - expect(supportsFn("anthropic.claude-3-5-sonnet-20240620-v1:0")).toBe(true); | |
| 119 | - expect(supportsFn("anthropic.claude-3.5-sonnet-20240620-v1:0")).toBe(true); | |
| 136 | + expect(supportsFn("anthropic.claude-3-5-sonnet-20240620-v1:0")).toBe( | |
| 137 | + true, | |
| 138 | + ); | |
| 139 | + expect(supportsFn("anthropic.claude-3.5-sonnet-20240620-v1:0")).toBe( | |
| 140 | + true, | |
| 141 | + ); | |
| 120 | 142 | }); |
| 121 | 143 | |
| 122 | 144 | it("should return true for Claude 3.7 Sonnet models", () => { |
| 123 | - expect(supportsFn("anthropic.claude-3-7-sonnet-20240620-v1:0")).toBe(true); | |
| 124 | - expect(supportsFn("anthropic.claude-3.7-sonnet-20240620-v1:0")).toBe(true); | |
| 145 | + expect(supportsFn("anthropic.claude-3-7-sonnet-20240620-v1:0")).toBe( | |
| 146 | + true, | |
| 147 | + ); | |
| 148 | + expect(supportsFn("anthropic.claude-3.7-sonnet-20240620-v1:0")).toBe( | |
| 149 | + true, | |
| 150 | + ); | |
| 125 | 151 | }); |
| 126 | 152 | |
| 127 | 153 | it("should return undefined for Claude Haiku and Opus models", () => { |
| 128 | - expect(supportsFn("anthropic.claude-3-5-haiku-20240307-v1:0")).toBeUndefined(); | |
| 129 | - expect(supportsFn("anthropic.claude-3.5-haiku-20240620-v1:0")).toBeUndefined(); | |
| 130 | - expect(supportsFn("anthropic.claude-3-7-haiku-20240620-v1:0")).toBeUndefined(); | |
| 131 | - expect(supportsFn("anthropic.claude-3-5-opus-20240620-v1:0")).toBeUndefined(); | |
| 132 | - expect(supportsFn("anthropic.claude-3.7-opus-20240620-v1:0")).toBeUndefined(); | |
| 154 | + expect(supportsFn("anthropic.claude-3-5-haiku-20240307-v1:0")).toBe( | |
| 155 | + false, | |
| 156 | + ); | |
| 157 | + expect(supportsFn("anthropic.claude-3.5-haiku-20240620-v1:0")).toBe( | |
| 158 | + false, | |
| 159 | + ); | |
| 160 | + expect(supportsFn("anthropic.claude-3-7-haiku-20240620-v1:0")).toBe( | |
| 161 | + false, | |
| 162 | + ); | |
| 163 | + expect(supportsFn("anthropic.claude-3-5-opus-20240620-v1:0")).toBe(false); | |
| 164 | + expect(supportsFn("anthropic.claude-3.7-opus-20240620-v1:0")).toBe(false); | |
| 133 | 165 | }); |
| 134 | 166 | |
| 135 | 167 | it("should return undefined for other unsupported models", () => { |
| 136 | - expect(supportsFn("anthropic.claude-instant-v1")).toBeUndefined(); | |
| 137 | - expect(supportsFn("anthropic.titan-text-express-v1")).toBeUndefined(); | |
| 168 | + expect(supportsFn("anthropic.claude-instant-v1")).toBe(false); | |
| 169 | + expect(supportsFn("anthropic.titan-text-express-v1")).toBe(false); | |
| 138 | 170 | }); |
| 139 | 171 | |
| 140 | 172 | it("should handle case insensitivity", () => { |
| 141 | - expect(supportsFn("ANTHROPIC.CLAUDE-3-5-SONNET-20240620-v1:0")).toBe(true); | |
| 142 | - expect(supportsFn("ANTHROPIC.CLAUDE-3.7-SONNET-20240620-v1:0")).toBe(true); | |
| 173 | + expect(supportsFn("ANTHROPIC.CLAUDE-3-5-SONNET-20240620-v1:0")).toBe( | |
| 174 | + true, | |
| 175 | + ); | |
| 176 | + expect(supportsFn("ANTHROPIC.CLAUDE-3.7-SONNET-20240620-v1:0")).toBe( | |
| 177 | + true, | |
| 178 | + ); | |
| 143 | 179 | }); |
| 144 | 180 | }); |
| 145 | 181 | |
| @@ -203,9 +239,9 @@ | ||
| 203 | 239 | }); |
| 204 | 240 | |
| 205 | 241 | it("should return undefined for other models", () => { |
| 206 | - expect(supportsFn("llama2")).toBeUndefined(); | |
| 207 | - expect(supportsFn("phi-2")).toBeUndefined(); | |
| 208 | - expect(supportsFn("falcon")).toBeUndefined(); | |
| 242 | + expect(supportsFn("llama2")).toBe(false); | |
| 243 | + expect(supportsFn("phi-2")).toBe(false); | |
| 244 | + expect(supportsFn("falcon")).toBe(false); | |
| 209 | 245 | }); |
| 210 | 246 | |
| 211 | 247 | it("should handle case insensitivity", () => { |
| @@ -218,16 +254,16 @@ | ||
| 218 | 254 | describe("edge cases", () => { |
| 219 | 255 | it("should handle empty model names", () => { |
| 220 | 256 | expect(PROVIDER_TOOL_SUPPORT["continue-proxy"]("")).toBe(false); |
| 221 | - expect(PROVIDER_TOOL_SUPPORT["anthropic"]("")).toBeUndefined(); | |
| 222 | - expect(PROVIDER_TOOL_SUPPORT["openai"]("")).toBeUndefined(); | |
| 257 | + expect(PROVIDER_TOOL_SUPPORT["anthropic"]("")).toBe(false); | |
| 258 | + expect(PROVIDER_TOOL_SUPPORT["openai"]("")).toBe(false); | |
| 223 | 259 | expect(PROVIDER_TOOL_SUPPORT["gemini"]("")).toBe(false); |
| 224 | - expect(PROVIDER_TOOL_SUPPORT["bedrock"]("")).toBeUndefined(); | |
| 225 | - expect(PROVIDER_TOOL_SUPPORT["ollama"]("")).toBeUndefined(); | |
| 260 | + expect(PROVIDER_TOOL_SUPPORT["bedrock"]("")).toBe(false); | |
| 261 | + expect(PROVIDER_TOOL_SUPPORT["ollama"]("")).toBe(false); | |
| 226 | 262 | }); |
| 227 | 263 | |
| 228 | 264 | it("should handle non-existent provider", () => { |
| 229 | 265 | // @ts-ignore - Testing runtime behavior with invalid provider |
| 230 | - expect(PROVIDER_TOOL_SUPPORT["non-existent"]).toBeUndefined(); | |
| 266 | + expect(PROVIDER_TOOL_SUPPORT["non-existent"]).toBe(undefined); | |
| 231 | 267 | }); |
| 232 | 268 | }); |
| 233 | 269 | }); |
modified core/llm/toolSupport.ts +238 −218
| @@ -1,235 +1,255 @@ | ||
| 1 | 1 | import { parseProxyModelName } from "@continuedev/config-yaml"; |
| 2 | 2 | |
| 3 | -export const PROVIDER_TOOL_SUPPORT: Record< | |
| 4 | - string, | |
| 5 | - (model: string) => boolean | undefined | |
| 6 | -> = { | |
| 7 | - "continue-proxy": (model) => { | |
| 8 | - const { provider, model: _model } = parseProxyModelName(model); | |
| 9 | - if (provider && _model && provider !== "continue-proxy") { | |
| 10 | - const fn = PROVIDER_TOOL_SUPPORT[provider]; | |
| 11 | - if (fn) { | |
| 12 | - return fn(_model); | |
| 3 | +export const PROVIDER_TOOL_SUPPORT: Record<string, (model: string) => boolean> = | |
| 4 | + { | |
| 5 | + "continue-proxy": (model) => { | |
| 6 | + try { | |
| 7 | + const { provider, model: _model } = parseProxyModelName(model); | |
| 8 | + if (provider && _model && provider !== "continue-proxy") { | |
| 9 | + const fn = PROVIDER_TOOL_SUPPORT[provider]; | |
| 10 | + if (fn) { | |
| 11 | + return fn(_model); | |
| 12 | + } | |
| 13 | + } | |
| 14 | + } catch (e) {} | |
| 15 | + | |
| 16 | + return [ | |
| 17 | + "claude-3-5", | |
| 18 | + "claude-3.5", | |
| 19 | + "claude-3-7", | |
| 20 | + "claude-3.7", | |
| 21 | + "gpt-4", | |
| 22 | + "o3", | |
| 23 | + "gemini", | |
| 24 | + ].some((part) => model.toLowerCase().startsWith(part)); | |
| 25 | + }, | |
| 26 | + anthropic: (model) => { | |
| 27 | + if ( | |
| 28 | + ["claude-3-5", "claude-3.5", "claude-3-7", "claude-3.7"].some((part) => | |
| 29 | + model.toLowerCase().startsWith(part), | |
| 30 | + ) | |
| 31 | + ) { | |
| 32 | + return true; | |
| 13 | 33 | } |
| 14 | - } | |
| 15 | - return [ | |
| 16 | - "claude-3-5", | |
| 17 | - "claude-3.5", | |
| 18 | - "claude-3-7", | |
| 19 | - "claude-3.7", | |
| 20 | - "gpt-4", | |
| 21 | - "o3", | |
| 22 | - "gemini", | |
| 23 | - ].some((part) => model.toLowerCase().startsWith(part)); | |
| 24 | - }, | |
| 25 | - anthropic: (model) => { | |
| 26 | - if ( | |
| 27 | - ["claude-3-5", "claude-3.5", "claude-3-7", "claude-3.7"].some((part) => | |
| 28 | - model.toLowerCase().startsWith(part), | |
| 34 | + | |
| 35 | + return false; | |
| 36 | + }, | |
| 37 | + azure: (model) => { | |
| 38 | + if ( | |
| 39 | + model.toLowerCase().startsWith("gpt-4") || | |
| 40 | + model.toLowerCase().startsWith("o3") | |
| 29 | 41 | ) |
| 30 | - ) { | |
| 31 | - return true; | |
| 32 | - } | |
| 33 | - }, | |
| 34 | - azure: (model) => { | |
| 35 | - if ( | |
| 36 | - model.toLowerCase().startsWith("gpt-4") || | |
| 37 | - model.toLowerCase().startsWith("o3") | |
| 38 | - ) | |
| 39 | - return true; | |
| 40 | - return false; | |
| 41 | - }, | |
| 42 | - openai: (model) => { | |
| 43 | - // https://platform.openai.com/docs/guides/function-calling#models-supporting-function-calling | |
| 44 | - if ( | |
| 45 | - model.toLowerCase().startsWith("gpt-4") || | |
| 46 | - model.toLowerCase().startsWith("o3") | |
| 47 | - ) { | |
| 48 | - return true; | |
| 49 | - } | |
| 50 | - // firworks-ai https://docs.fireworks.ai/guides/function-calling | |
| 51 | - if (model.startsWith("accounts/fireworks/models/")) { | |
| 52 | - switch (model.substring(26)) { | |
| 53 | - case "llama-v3p1-405b-instruct": | |
| 54 | - case "llama-v3p1-70b-instruct": | |
| 55 | - case "qwen2p5-72b-instruct": | |
| 56 | - case "firefunction-v1": | |
| 57 | - case "firefunction-v2": | |
| 58 | - return true; | |
| 59 | - default: | |
| 60 | - return false; | |
| 42 | + return true; | |
| 43 | + return false; | |
| 44 | + }, | |
| 45 | + openai: (model) => { | |
| 46 | + // https://platform.openai.com/docs/guides/function-calling#models-supporting-function-calling | |
| 47 | + if ( | |
| 48 | + model.toLowerCase().startsWith("gpt-4") || | |
| 49 | + model.toLowerCase().startsWith("o3") | |
| 50 | + ) { | |
| 51 | + return true; | |
| 52 | + } | |
| 53 | + // firworks-ai https://docs.fireworks.ai/guides/function-calling | |
| 54 | + if (model.startsWith("accounts/fireworks/models/")) { | |
| 55 | + switch (model.substring(26)) { | |
| 56 | + case "llama-v3p1-405b-instruct": | |
| 57 | + case "llama-v3p1-70b-instruct": | |
| 58 | + case "qwen2p5-72b-instruct": | |
| 59 | + case "firefunction-v1": | |
| 60 | + case "firefunction-v2": | |
| 61 | + return true; | |
| 62 | + default: | |
| 63 | + return false; | |
| 64 | + } | |
| 61 | 65 | } |
| 62 | - } | |
| 63 | - }, | |
| 64 | - gemini: (model) => { | |
| 65 | - // All gemini models support function calling | |
| 66 | - return model.toLowerCase().includes("gemini"); | |
| 67 | - }, | |
| 68 | - vertexai: (model) => { | |
| 69 | - // All gemini models except flash 2.0 lite support function calling | |
| 70 | - return ( | |
| 71 | - model.toLowerCase().includes("gemini") && | |
| 72 | - !model.toLowerCase().includes("lite") | |
| 73 | - ); | |
| 74 | - }, | |
| 75 | - bedrock: (model) => { | |
| 76 | - // For Bedrock, only support Claude Sonnet models with versions 3.5/3-5 and 3.7/3-7 | |
| 77 | - if ( | |
| 78 | - model.toLowerCase().includes("sonnet") && | |
| 79 | - ["claude-3-5", "claude-3.5", "claude-3-7", "claude-3.7"].some((part) => | |
| 80 | - model.toLowerCase().includes(part), | |
| 81 | - ) | |
| 82 | - ) { | |
| 83 | - return true; | |
| 84 | - } | |
| 85 | - }, | |
| 86 | - mistral: (model) => { | |
| 87 | - // https://docs.mistral.ai/capabilities/function_calling/ | |
| 88 | - return ( | |
| 89 | - !model.toLowerCase().includes("mamba") && | |
| 90 | - [ | |
| 91 | - "codestral", | |
| 92 | - "mistral-large", | |
| 93 | - "mistral-small", | |
| 94 | - "pixtral", | |
| 95 | - "ministral", | |
| 96 | - "mistral-nemo", | |
| 97 | - ].some((part) => model.toLowerCase().includes(part)) | |
| 98 | - ); | |
| 99 | - }, | |
| 100 | - // https://ollama.com/search?c=tools | |
| 101 | - ollama: (model) => { | |
| 102 | - let modelName = ""; | |
| 103 | - // Extract the model name after the last slash to support other registries | |
| 104 | - if (model.includes("/")) { | |
| 105 | - let parts = model.split("/"); | |
| 106 | - modelName = parts[parts.length - 1]; | |
| 107 | - } else { | |
| 108 | - modelName = model; | |
| 109 | - } | |
| 110 | 66 | |
| 111 | - if ( | |
| 112 | - ["vision", "math", "guard", "mistrallite", "mistral-openorca"].some( | |
| 113 | - (part) => modelName.toLowerCase().includes(part), | |
| 114 | - ) | |
| 115 | - ) { | |
| 116 | 67 | return false; |
| 117 | - } | |
| 118 | - if ( | |
| 119 | - [ | |
| 120 | - "cogito", | |
| 121 | - "llama3.3", | |
| 122 | - "qwq", | |
| 123 | - "llama3.2", | |
| 124 | - "llama3.1", | |
| 125 | - "qwen2", | |
| 126 | - "qwen3", | |
| 127 | - "mixtral", | |
| 128 | - "command-r", | |
| 129 | - "smollm2", | |
| 130 | - "hermes3", | |
| 131 | - "athene-v2", | |
| 132 | - "nemotron", | |
| 133 | - "llama3-groq", | |
| 134 | - "granite3", | |
| 135 | - "granite-3", | |
| 136 | - "aya-expanse", | |
| 137 | - "firefunction-v2", | |
| 138 | - "mistral", | |
| 139 | - ].some((part) => modelName.toLowerCase().includes(part)) | |
| 140 | - ) { | |
| 141 | - return true; | |
| 142 | - } | |
| 143 | - }, | |
| 144 | - sambanova: (model) => { | |
| 145 | - // https://docs.sambanova.ai/cloud/docs/capabilities/function-calling | |
| 146 | - if ( | |
| 147 | - model.toLowerCase().startsWith("meta-llama-3") || | |
| 148 | - model.toLowerCase().includes("llama-4") || | |
| 149 | - model.toLowerCase().includes("deepseek") | |
| 150 | - ) { | |
| 151 | - return true; | |
| 152 | - } | |
| 153 | - }, | |
| 154 | - deepseek: (model) => { | |
| 155 | - if (model !== "deepseek-reasoner") { | |
| 156 | - return true; | |
| 157 | - } | |
| 158 | - }, | |
| 159 | - watsonx: (model) => { | |
| 160 | - if (model.toLowerCase().includes("guard")) return false; | |
| 161 | - if ( | |
| 162 | - ["llama-3", "llama-4", "mistral", "codestral", "granite-3"].some((part) => | |
| 163 | - model.toLowerCase().includes(part), | |
| 164 | - ) | |
| 165 | - ) | |
| 166 | - return true; | |
| 167 | - }, | |
| 168 | - openrouter: (model) => { | |
| 169 | - // https://openrouter.ai/models?fmt=cards&supported_parameters=tools | |
| 170 | - if ( | |
| 171 | - ["vision", "math", "guard", "mistrallite", "mistral-openorca"].some( | |
| 172 | - (part) => model.toLowerCase().includes(part), | |
| 173 | - ) | |
| 174 | - ) { | |
| 68 | + }, | |
| 69 | + gemini: (model) => { | |
| 70 | + // All gemini models support function calling | |
| 71 | + return model.toLowerCase().includes("gemini"); | |
| 72 | + }, | |
| 73 | + vertexai: (model) => { | |
| 74 | + // All gemini models except flash 2.0 lite support function calling | |
| 75 | + return ( | |
| 76 | + model.toLowerCase().includes("gemini") && | |
| 77 | + !model.toLowerCase().includes("lite") | |
| 78 | + ); | |
| 79 | + }, | |
| 80 | + bedrock: (model) => { | |
| 81 | + // For Bedrock, only support Claude Sonnet models with versions 3.5/3-5 and 3.7/3-7 | |
| 82 | + if ( | |
| 83 | + model.toLowerCase().includes("sonnet") && | |
| 84 | + ["claude-3-5", "claude-3.5", "claude-3-7", "claude-3.7"].some((part) => | |
| 85 | + model.toLowerCase().includes(part), | |
| 86 | + ) | |
| 87 | + ) { | |
| 88 | + return true; | |
| 89 | + } | |
| 90 | + | |
| 175 | 91 | return false; |
| 176 | - } | |
| 92 | + }, | |
| 93 | + mistral: (model) => { | |
| 94 | + // https://docs.mistral.ai/capabilities/function_calling/ | |
| 95 | + return ( | |
| 96 | + !model.toLowerCase().includes("mamba") && | |
| 97 | + [ | |
| 98 | + "codestral", | |
| 99 | + "mistral-large", | |
| 100 | + "mistral-small", | |
| 101 | + "pixtral", | |
| 102 | + "ministral", | |
| 103 | + "mistral-nemo", | |
| 104 | + ].some((part) => model.toLowerCase().includes(part)) | |
| 105 | + ); | |
| 106 | + }, | |
| 107 | + // https://ollama.com/search?c=tools | |
| 108 | + ollama: (model) => { | |
| 109 | + let modelName = ""; | |
| 110 | + // Extract the model name after the last slash to support other registries | |
| 111 | + if (model.includes("/")) { | |
| 112 | + let parts = model.split("/"); | |
| 113 | + modelName = parts[parts.length - 1]; | |
| 114 | + } else { | |
| 115 | + modelName = model; | |
| 116 | + } | |
| 117 | + | |
| 118 | + if ( | |
| 119 | + ["vision", "math", "guard", "mistrallite", "mistral-openorca"].some( | |
| 120 | + (part) => modelName.toLowerCase().includes(part), | |
| 121 | + ) | |
| 122 | + ) { | |
| 123 | + return false; | |
| 124 | + } | |
| 125 | + if ( | |
| 126 | + [ | |
| 127 | + "cogito", | |
| 128 | + "llama3.3", | |
| 129 | + "qwq", | |
| 130 | + "llama3.2", | |
| 131 | + "llama3.1", | |
| 132 | + "qwen2", | |
| 133 | + "qwen3", | |
| 134 | + "mixtral", | |
| 135 | + "command-r", | |
| 136 | + "smollm2", | |
| 137 | + "hermes3", | |
| 138 | + "athene-v2", | |
| 139 | + "nemotron", | |
| 140 | + "llama3-groq", | |
| 141 | + "granite3", | |
| 142 | + "granite-3", | |
| 143 | + "aya-expanse", | |
| 144 | + "firefunction-v2", | |
| 145 | + "mistral", | |
| 146 | + ].some((part) => modelName.toLowerCase().includes(part)) | |
| 147 | + ) { | |
| 148 | + return true; | |
| 149 | + } | |
| 177 | 150 | |
| 178 | - const supportedPrefixes = [ | |
| 179 | - "openai/gpt-3.5", | |
| 180 | - "openai/gpt-4", | |
| 181 | - "openai/o1", | |
| 182 | - "openai/o3", | |
| 183 | - "openai/o4", | |
| 184 | - "anthropic/claude-3", | |
| 185 | - "microsoft/phi-3", | |
| 186 | - "google/gemini-flash-1.5", | |
| 187 | - "google/gemini-2", | |
| 188 | - "google/gemini-pro", | |
| 189 | - "x-ai/grok", | |
| 190 | - "qwen/qwen3", | |
| 191 | - "qwen/qwen-", | |
| 192 | - "cohere/command-r", | |
| 193 | - "ai21/jamba-1.6", | |
| 194 | - "mistralai/mistral", | |
| 195 | - "mistralai/ministral", | |
| 196 | - "mistralai/codestral", | |
| 197 | - "mistralai/mixtral", | |
| 198 | - "mistral/ministral", | |
| 199 | - "mistralai/pixtral", | |
| 200 | - "meta-llama/llama-3.3", | |
| 201 | - "amazon/nova", | |
| 202 | - "deepseek/deepseek-r1", | |
| 203 | - "deepseek/deepseek-chat", | |
| 204 | - "meta-llama/llama-4", | |
| 205 | - "all-hands/openhands-lm-32b", | |
| 206 | - ]; | |
| 207 | - for (const prefix of supportedPrefixes) { | |
| 208 | - if (model.toLowerCase().startsWith(prefix)) { | |
| 151 | + return false; | |
| 152 | + }, | |
| 153 | + sambanova: (model) => { | |
| 154 | + // https://docs.sambanova.ai/cloud/docs/capabilities/function-calling | |
| 155 | + if ( | |
| 156 | + model.toLowerCase().startsWith("meta-llama-3") || | |
| 157 | + model.toLowerCase().includes("llama-4") || | |
| 158 | + model.toLowerCase().includes("deepseek") | |
| 159 | + ) { | |
| 209 | 160 | return true; |
| 210 | 161 | } |
| 211 | - } | |
| 212 | 162 | |
| 213 | - const specificModels = [ | |
| 214 | - "qwen/qwq-32b", | |
| 215 | - "qwen/qwen-2.5-72b-instruct", | |
| 216 | - "meta-llama/llama-3.2-3b-instruct", | |
| 217 | - "meta-llama/llama-3-8b-instruct", | |
| 218 | - "meta-llama/llama-3-70b-instruct", | |
| 219 | - "arcee-ai/caller-large", | |
| 220 | - "nousresearch/hermes-3-llama-3.1-70b", | |
| 221 | - ]; | |
| 222 | - for (const model of specificModels) { | |
| 223 | - if (model.toLowerCase() === model) { | |
| 163 | + return false; | |
| 164 | + }, | |
| 165 | + deepseek: (model) => { | |
| 166 | + if (model !== "deepseek-reasoner") { | |
| 224 | 167 | return true; |
| 225 | 168 | } |
| 226 | - } | |
| 227 | 169 | |
| 228 | - const supportedContains = ["llama-3.1"]; | |
| 229 | - for (const model of supportedContains) { | |
| 230 | - if (model.toLowerCase().includes(model)) { | |
| 170 | + return false; | |
| 171 | + }, | |
| 172 | + watsonx: (model) => { | |
| 173 | + if (model.toLowerCase().includes("guard")) { | |
| 174 | + return false; | |
| 175 | + } | |
| 176 | + if ( | |
| 177 | + ["llama-3", "llama-4", "mistral", "codestral", "granite-3"].some( | |
| 178 | + (part) => model.toLowerCase().includes(part), | |
| 179 | + ) | |
| 180 | + ) { | |
| 231 | 181 | return true; |
| 232 | 182 | } |
| 233 | - } | |
| 234 | - }, | |
| 235 | -}; | |
| 183 | + | |
| 184 | + return false; | |
| 185 | + }, | |
| 186 | + openrouter: (model) => { | |
| 187 | + // https://openrouter.ai/models?fmt=cards&supported_parameters=tools | |
| 188 | + if ( | |
| 189 | + ["vision", "math", "guard", "mistrallite", "mistral-openorca"].some( | |
| 190 | + (part) => model.toLowerCase().includes(part), | |
| 191 | + ) | |
| 192 | + ) { | |
| 193 | + return false; | |
| 194 | + } | |
| 195 | + | |
| 196 | + const supportedPrefixes = [ | |
| 197 | + "openai/gpt-3.5", | |
| 198 | + "openai/gpt-4", | |
| 199 | + "openai/o1", | |
| 200 | + "openai/o3", | |
| 201 | + "openai/o4", | |
| 202 | + "anthropic/claude-3", | |
| 203 | + "microsoft/phi-3", | |
| 204 | + "google/gemini-flash-1.5", | |
| 205 | + "google/gemini-2", | |
| 206 | + "google/gemini-pro", | |
| 207 | + "x-ai/grok", | |
| 208 | + "qwen/qwen3", | |
| 209 | + "qwen/qwen-", | |
| 210 | + "cohere/command-r", | |
| 211 | + "ai21/jamba-1.6", | |
| 212 | + "mistralai/mistral", | |
| 213 | + "mistralai/ministral", | |
| 214 | + "mistralai/codestral", | |
| 215 | + "mistralai/mixtral", | |
| 216 | + "mistral/ministral", | |
| 217 | + "mistralai/pixtral", | |
| 218 | + "meta-llama/llama-3.3", | |
| 219 | + "amazon/nova", | |
| 220 | + "deepseek/deepseek-r1", | |
| 221 | + "deepseek/deepseek-chat", | |
| 222 | + "meta-llama/llama-4", | |
| 223 | + "all-hands/openhands-lm-32b", | |
| 224 | + ]; | |
| 225 | + for (const prefix of supportedPrefixes) { | |
| 226 | + if (model.toLowerCase().startsWith(prefix)) { | |
| 227 | + return true; | |
| 228 | + } | |
| 229 | + } | |
| 230 | + | |
| 231 | + const specificModels = [ | |
| 232 | + "qwen/qwq-32b", | |
| 233 | + "qwen/qwen-2.5-72b-instruct", | |
| 234 | + "meta-llama/llama-3.2-3b-instruct", | |
| 235 | + "meta-llama/llama-3-8b-instruct", | |
| 236 | + "meta-llama/llama-3-70b-instruct", | |
| 237 | + "arcee-ai/caller-large", | |
| 238 | + "nousresearch/hermes-3-llama-3.1-70b", | |
| 239 | + ]; | |
| 240 | + for (const model of specificModels) { | |
| 241 | + if (model.toLowerCase() === model) { | |
| 242 | + return true; | |
| 243 | + } | |
| 244 | + } | |
| 245 | + | |
| 246 | + const supportedContains = ["llama-3.1"]; | |
| 247 | + for (const model of supportedContains) { | |
| 248 | + if (model.toLowerCase().includes(model)) { | |
| 249 | + return true; | |
| 250 | + } | |
| 251 | + } | |
| 252 | + | |
| 253 | + return false; | |
| 254 | + }, | |
| 255 | + }; |