| 1 | // core/llm/toolSupport.test.ts |
| 2 | import { PROVIDER_TOOL_SUPPORT } from "./toolSupport"; |
| 3 | |
| 4 | describe("PROVIDER_TOOL_SUPPORT", () => { |
| 5 | describe("continue-proxy", () => { |
| 6 | const supportsFn = PROVIDER_TOOL_SUPPORT["continue-proxy"]; |
| 7 | |
| 8 | it("should return true for Claude 3.5 models", () => { |
| 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); |
| 15 | }); |
| 16 | |
| 17 | it("should return true for Claude 3.7 models", () => { |
| 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); |
| 24 | }); |
| 25 | |
| 26 | it("should return true for GPT-4 models", () => { |
| 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); |
| 31 | }); |
| 32 | |
| 33 | it("should return true for Gemma models", () => { |
| 34 | expect(supportsFn("ownerSlug/packageSlug/openai/gemma")).toBe(true); |
| 35 | expect(supportsFn("ownerSlug/packageSlug/openai/gemma3")).toBe(true); |
| 36 | }); |
| 37 | |
| 38 | it("should return true for O3 models", () => { |
| 39 | expect(supportsFn("ownerSlug/packageSlug/openai/o3-preview")).toBe(true); |
| 40 | }); |
| 41 | |
| 42 | it("should return true for Gemini models", () => { |
| 43 | expect(supportsFn("ownerSlug/packageSlug/gemini/gemini-pro")).toBe(true); |
| 44 | expect(supportsFn("ownerSlug/packageSlug/gemini/gemini-1.5-pro")).toBe( |
| 45 | true, |
| 46 | ); |
| 47 | }); |
| 48 | |
| 49 | it("should return false for unsupported models", () => { |
| 50 | expect(supportsFn("ownerSlug/packageSlug/openai/gpt-3.5-turbo")).toBe( |
| 51 | false, |
| 52 | ); |
| 53 | expect(supportsFn("ownerSlug/packageSlug/anthropic/claude-2")).toBe( |
| 54 | false, |
| 55 | ); |
| 56 | expect(supportsFn("ownerSlug/packageSlug/together/llama-3")).toBe(false); |
| 57 | }); |
| 58 | |
| 59 | it("should handle case insensitivity", () => { |
| 60 | expect( |
| 61 | supportsFn("ownerSlug/packageSlug/anthropic/CLAUDE-3-5-sonnet"), |
| 62 | ).toBe(true); |
| 63 | expect(supportsFn("ownerSlug/packageSlug/openai/GPT-4-turbo")).toBe(true); |
| 64 | expect(supportsFn("ownerSlug/packageSlug/openai/Gemma3")).toBe(true); |
| 65 | expect(supportsFn("ownerSlug/packageSlug/gemini/GEMINI-pro")).toBe(true); |
| 66 | }); |
| 67 | }); |
| 68 | |
| 69 | describe("anthropic", () => { |
| 70 | const supportsFn = PROVIDER_TOOL_SUPPORT["anthropic"]; |
| 71 | |
| 72 | it("should return true for Claude 3.5 models", () => { |
| 73 | expect(supportsFn("claude-3-5-sonnet")).toBe(true); |
| 74 | expect(supportsFn("claude-3.5-haiku")).toBe(true); |
| 75 | }); |
| 76 | |
| 77 | it("should return true for Claude 3.7 models", () => { |
| 78 | expect(supportsFn("claude-3-7-haiku")).toBe(true); |
| 79 | expect(supportsFn("claude-3.7-sonnet")).toBe(true); |
| 80 | }); |
| 81 | |
| 82 | it("should return undefined for unsupported models", () => { |
| 83 | expect(supportsFn("claude-2")).toBe(false); |
| 84 | expect(supportsFn("claude-instant")).toBe(false); |
| 85 | }); |
| 86 | |
| 87 | it("should handle case insensitivity", () => { |
| 88 | expect(supportsFn("CLAUDE-3-5-sonnet")).toBe(true); |
| 89 | expect(supportsFn("CLAUDE-3.7-haiku")).toBe(true); |
| 90 | }); |
| 91 | }); |
| 92 | |
| 93 | describe("openai", () => { |
| 94 | const supportsFn = PROVIDER_TOOL_SUPPORT["openai"]; |
| 95 | |
| 96 | it("should return true for GPT-4 models", () => { |
| 97 | expect(supportsFn("gpt-4")).toBe(true); |
| 98 | expect(supportsFn("gpt-4-turbo")).toBe(true); |
| 99 | expect(supportsFn("gpt-4-1106-preview")).toBe(true); |
| 100 | }); |
| 101 | |
| 102 | it("should return true for O3 models", () => { |
| 103 | expect(supportsFn("o3")).toBe(true); |
| 104 | expect(supportsFn("o3-preview")).toBe(true); |
| 105 | }); |
| 106 | |
| 107 | it("should return true for Gemma models", () => { |
| 108 | expect(supportsFn("gemma")).toBe(true); |
| 109 | expect(supportsFn("gemma3")).toBe(true); |
| 110 | }); |
| 111 | |
| 112 | it("should return undefined for unsupported models", () => { |
| 113 | expect(supportsFn("gpt-3.5-turbo")).toBe(false); |
| 114 | expect(supportsFn("davinci")).toBe(false); |
| 115 | }); |
| 116 | |
| 117 | it("should handle case insensitivity", () => { |
| 118 | expect(supportsFn("GPT-4-turbo")).toBe(true); |
| 119 | expect(supportsFn("O3-preview")).toBe(true); |
| 120 | expect(supportsFn("Gemma3")).toBe(true); |
| 121 | }); |
| 122 | }); |
| 123 | |
| 124 | describe("cohere", () => { |
| 125 | const supportsFn = PROVIDER_TOOL_SUPPORT["cohere"]; |
| 126 | |
| 127 | it("should return true for Command models", () => { |
| 128 | expect(supportsFn("command-r")).toBe(true); |
| 129 | expect(supportsFn("command-a")).toBe(true); |
| 130 | }); |
| 131 | |
| 132 | it("should return false for other models", () => { |
| 133 | expect(supportsFn("c4ai-aya-expanse-32b")).toBe(false); |
| 134 | }); |
| 135 | }); |
| 136 | |
| 137 | describe("gemini", () => { |
| 138 | const supportsFn = PROVIDER_TOOL_SUPPORT["gemini"]; |
| 139 | |
| 140 | it("should return true for all Gemini models", () => { |
| 141 | expect(supportsFn("gemini-pro")).toBe(true); |
| 142 | expect(supportsFn("gemini-1.5-pro")).toBe(true); |
| 143 | expect(supportsFn("gemini-ultra")).toBe(true); |
| 144 | }); |
| 145 | |
| 146 | it("should return false for non-Gemini models", () => { |
| 147 | expect(supportsFn("gpt-4")).toBe(false); |
| 148 | expect(supportsFn("claude-3")).toBe(false); |
| 149 | }); |
| 150 | |
| 151 | it("should handle case insensitivity", () => { |
| 152 | expect(supportsFn("GEMINI-pro")).toBe(true); |
| 153 | expect(supportsFn("Gemini-1.5-Pro")).toBe(true); |
| 154 | }); |
| 155 | }); |
| 156 | |
| 157 | describe("bedrock", () => { |
| 158 | const supportsFn = PROVIDER_TOOL_SUPPORT["bedrock"]; |
| 159 | |
| 160 | it("should return true for Claude 3.5 Sonnet models", () => { |
| 161 | expect(supportsFn("anthropic.claude-3-5-sonnet-20240620-v1:0")).toBe( |
| 162 | true, |
| 163 | ); |
| 164 | expect(supportsFn("anthropic.claude-3.5-sonnet-20240620-v1:0")).toBe( |
| 165 | true, |
| 166 | ); |
| 167 | }); |
| 168 | |
| 169 | it("should return true for Claude 3.7 Sonnet models", () => { |
| 170 | expect(supportsFn("anthropic.claude-3-7-sonnet-20240620-v1:0")).toBe( |
| 171 | true, |
| 172 | ); |
| 173 | expect(supportsFn("anthropic.claude-3.7-sonnet-20240620-v1:0")).toBe( |
| 174 | true, |
| 175 | ); |
| 176 | }); |
| 177 | |
| 178 | it("should return undefined for Claude Haiku and Opus models", () => { |
| 179 | expect(supportsFn("anthropic.claude-3-5-haiku-20240307-v1:0")).toBe( |
| 180 | false, |
| 181 | ); |
| 182 | expect(supportsFn("anthropic.claude-3.5-haiku-20240620-v1:0")).toBe( |
| 183 | false, |
| 184 | ); |
| 185 | expect(supportsFn("anthropic.claude-3-7-haiku-20240620-v1:0")).toBe( |
| 186 | false, |
| 187 | ); |
| 188 | expect(supportsFn("anthropic.claude-3-5-opus-20240620-v1:0")).toBe(false); |
| 189 | expect(supportsFn("anthropic.claude-3.7-opus-20240620-v1:0")).toBe(false); |
| 190 | }); |
| 191 | |
| 192 | it("should return undefined for other unsupported models", () => { |
| 193 | expect(supportsFn("anthropic.claude-instant-v1")).toBe(false); |
| 194 | expect(supportsFn("anthropic.titan-text-express-v1")).toBe(false); |
| 195 | }); |
| 196 | |
| 197 | it("should handle case insensitivity", () => { |
| 198 | expect(supportsFn("ANTHROPIC.CLAUDE-3-5-SONNET-20240620-v1:0")).toBe( |
| 199 | true, |
| 200 | ); |
| 201 | expect(supportsFn("ANTHROPIC.CLAUDE-3.7-SONNET-20240620-v1:0")).toBe( |
| 202 | true, |
| 203 | ); |
| 204 | }); |
| 205 | }); |
| 206 | |
| 207 | describe("mistral", () => { |
| 208 | const supportsFn = PROVIDER_TOOL_SUPPORT["mistral"]; |
| 209 | |
| 210 | it("should return true for supported models", () => { |
| 211 | expect(supportsFn("mistral-large-latest")).toBe(true); |
| 212 | expect(supportsFn("mistral-small-latest")).toBe(true); |
| 213 | expect(supportsFn("codestral-latest")).toBe(true); |
| 214 | expect(supportsFn("ministral-8b-latest")).toBe(true); |
| 215 | expect(supportsFn("ministral-3b-latest")).toBe(true); |
| 216 | expect(supportsFn("pixtral-12b-2409")).toBe(true); |
| 217 | expect(supportsFn("pixtral-large-latest")).toBe(true); |
| 218 | expect(supportsFn("open-mistral-nemo")).toBe(true); |
| 219 | expect(supportsFn("devstral-latest")).toBe(true); |
| 220 | }); |
| 221 | |
| 222 | it("should return false for other unsupported models", () => { |
| 223 | expect(supportsFn("mistral-saba-latest")).toBe(false); |
| 224 | expect(supportsFn("mistral-embed")).toBe(false); |
| 225 | expect(supportsFn("mistral-moderation-latest")).toBe(false); |
| 226 | expect(supportsFn("mistral-ocr-latest")).toBe(false); |
| 227 | expect(supportsFn("open-codestral-mamba")).toBe(false); |
| 228 | }); |
| 229 | |
| 230 | it("should handle case insensitivity", () => { |
| 231 | expect(supportsFn("MISTRAL-LARGE-LATEST")).toBe(true); |
| 232 | expect(supportsFn("CODESTRAL-LATEST")).toBe(true); |
| 233 | expect(supportsFn("MINISTRAL-8B-LATEST")).toBe(true); |
| 234 | expect(supportsFn("PIXTRAL-12B-2409")).toBe(true); |
| 235 | expect(supportsFn("DEVSTRAL-LATEST")).toBe(true); |
| 236 | }); |
| 237 | }); |
| 238 | |
| 239 | describe("ollama", () => { |
| 240 | const supportsFn = PROVIDER_TOOL_SUPPORT["ollama"]; |
| 241 | |
| 242 | it("should return true for supported models", () => { |
| 243 | expect(supportsFn("llama3.1")).toBe(true); |
| 244 | expect(supportsFn("llama3.2-8b")).toBe(true); |
| 245 | expect(supportsFn("llama3.3-70b")).toBe(true); |
| 246 | expect(supportsFn("qwen2")).toBe(true); |
| 247 | expect(supportsFn("mixtral-8x7b")).toBe(true); |
| 248 | expect(supportsFn("command-r")).toBe(true); |
| 249 | expect(supportsFn("command-a")).toBe(true); |
| 250 | expect(supportsFn("smollm2")).toBe(true); |
| 251 | expect(supportsFn("hermes3")).toBe(true); |
| 252 | expect(supportsFn("athene-v2")).toBe(true); |
| 253 | expect(supportsFn("nemotron-4-340b")).toBe(true); |
| 254 | expect(supportsFn("llama3-groq")).toBe(true); |
| 255 | expect(supportsFn("granite3")).toBe(true); |
| 256 | expect(supportsFn("aya-expanse")).toBe(true); |
| 257 | expect(supportsFn("firefunction-v2")).toBe(true); |
| 258 | expect(supportsFn("mistral-7b")).toBe(true); |
| 259 | expect(supportsFn("devstral-24b")).toBe(true); |
| 260 | }); |
| 261 | |
| 262 | it("should return false for explicitly unsupported models", () => { |
| 263 | expect(supportsFn("vision")).toBe(false); |
| 264 | expect(supportsFn("math")).toBe(false); |
| 265 | expect(supportsFn("guard")).toBe(false); |
| 266 | expect(supportsFn("mistrallite")).toBe(false); |
| 267 | expect(supportsFn("mistral-openorca")).toBe(false); |
| 268 | }); |
| 269 | |
| 270 | it("should return undefined for other models", () => { |
| 271 | expect(supportsFn("llama2")).toBe(false); |
| 272 | expect(supportsFn("phi-2")).toBe(false); |
| 273 | expect(supportsFn("falcon")).toBe(false); |
| 274 | }); |
| 275 | |
| 276 | it("should handle case insensitivity", () => { |
| 277 | expect(supportsFn("LLAMA3.1")).toBe(true); |
| 278 | expect(supportsFn("MIXTRAL-8x7b")).toBe(true); |
| 279 | expect(supportsFn("VISION")).toBe(false); |
| 280 | }); |
| 281 | }); |
| 282 | |
| 283 | describe("novita", () => { |
| 284 | const supportsFn = PROVIDER_TOOL_SUPPORT["novita"]; |
| 285 | |
| 286 | it("should return true for exact match models", () => { |
| 287 | expect(supportsFn("deepseek/deepseek-r1-0528")).toBe(true); |
| 288 | expect(supportsFn("deepseek/deepseek-r1-turbo")).toBe(true); |
| 289 | expect(supportsFn("deepseek/deepseek-v3-0324")).toBe(true); |
| 290 | expect(supportsFn("deepseek/deepseek-v3-turbo")).toBe(true); |
| 291 | expect(supportsFn("meta-llama/llama-3.3-70b-instruct")).toBe(true); |
| 292 | expect(supportsFn("qwen/qwen-2.5-72b-instruct")).toBe(true); |
| 293 | expect(supportsFn("zai-org/glm-4.5")).toBe(true); |
| 294 | expect(supportsFn("moonshotai/kimi-k2-instruct")).toBe(true); |
| 295 | }); |
| 296 | |
| 297 | it("should return true for prefix match models", () => { |
| 298 | expect(supportsFn("qwen/qwen3-235b-a22b-instruct-2507")).toBe(true); |
| 299 | expect(supportsFn("openai/gpt-oss-20b")).toBe(true); |
| 300 | expect(supportsFn("openai/gpt-oss-120b")).toBe(true); |
| 301 | }); |
| 302 | |
| 303 | it("should return false for unsupported models", () => { |
| 304 | expect(supportsFn("deepseek/deepseek-chat")).toBe(false); |
| 305 | expect(supportsFn("meta-llama/llama-2-7b")).toBe(false); |
| 306 | expect(supportsFn("qwen/qwen-2.0-7b")).toBe(false); |
| 307 | expect(supportsFn("openai/gpt-4")).toBe(false); |
| 308 | }); |
| 309 | }); |
| 310 | |
| 311 | describe("openrouter", () => { |
| 312 | const supportsFn = PROVIDER_TOOL_SUPPORT["openrouter"]; |
| 313 | |
| 314 | it("should return false for moonshotai/kimi-k2:free model", () => { |
| 315 | // This fixes issue #6619 |
| 316 | expect(supportsFn("moonshotai/kimi-k2:free")).toBe(false); |
| 317 | }); |
| 318 | }); |
| 319 | |
| 320 | describe("edge cases", () => { |
| 321 | it("should handle empty model names", () => { |
| 322 | expect(PROVIDER_TOOL_SUPPORT["continue-proxy"]("")).toBe(false); |
| 323 | expect(PROVIDER_TOOL_SUPPORT["anthropic"]("")).toBe(false); |
| 324 | expect(PROVIDER_TOOL_SUPPORT["openai"]("")).toBe(false); |
| 325 | expect(PROVIDER_TOOL_SUPPORT["gemini"]("")).toBe(false); |
| 326 | expect(PROVIDER_TOOL_SUPPORT["bedrock"]("")).toBe(false); |
| 327 | expect(PROVIDER_TOOL_SUPPORT["ollama"]("")).toBe(false); |
| 328 | expect(PROVIDER_TOOL_SUPPORT["novita"]("")).toBe(false); |
| 329 | }); |
| 330 | |
| 331 | it("should handle non-existent provider", () => { |
| 332 | // @ts-ignore - Testing runtime behavior with invalid provider |
| 333 | expect(PROVIDER_TOOL_SUPPORT["non-existent"]).toBe(undefined); |
| 334 | }); |
| 335 | }); |
| 336 | }); |