| 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(supportsFn("claude-3-5-sonnet")).toBe(true); |
| 10 | expect(supportsFn("claude-3.5-sonnet")).toBe(true); |
| 11 | }); |
| 12 | |
| 13 | 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); |
| 16 | }); |
| 17 | |
| 18 | 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); |
| 21 | }); |
| 22 | |
| 23 | it("should return true for O3 models", () => { |
| 24 | expect(supportsFn("o3-preview")).toBe(true); |
| 25 | }); |
| 26 | |
| 27 | it("should return true for Gemini models", () => { |
| 28 | expect(supportsFn("gemini-pro")).toBe(true); |
| 29 | expect(supportsFn("gemini-1.5-pro")).toBe(true); |
| 30 | }); |
| 31 | |
| 32 | 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); |
| 36 | }); |
| 37 | |
| 38 | 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); |
| 42 | }); |
| 43 | }); |
| 44 | |
| 45 | describe("anthropic", () => { |
| 46 | const supportsFn = PROVIDER_TOOL_SUPPORT["anthropic"]; |
| 47 | |
| 48 | it("should return true for Claude 3.5 models", () => { |
| 49 | expect(supportsFn("claude-3-5-sonnet")).toBe(true); |
| 50 | expect(supportsFn("claude-3.5-haiku")).toBe(true); |
| 51 | }); |
| 52 | |
| 53 | it("should return true for Claude 3.7 models", () => { |
| 54 | expect(supportsFn("claude-3-7-haiku")).toBe(true); |
| 55 | expect(supportsFn("claude-3.7-sonnet")).toBe(true); |
| 56 | }); |
| 57 | |
| 58 | it("should return undefined for unsupported models", () => { |
| 59 | expect(supportsFn("claude-2")).toBeUndefined(); |
| 60 | expect(supportsFn("claude-instant")).toBeUndefined(); |
| 61 | }); |
| 62 | |
| 63 | it("should handle case insensitivity", () => { |
| 64 | expect(supportsFn("CLAUDE-3-5-sonnet")).toBe(true); |
| 65 | expect(supportsFn("CLAUDE-3.7-haiku")).toBe(true); |
| 66 | }); |
| 67 | }); |
| 68 | |
| 69 | describe("openai", () => { |
| 70 | const supportsFn = PROVIDER_TOOL_SUPPORT["openai"]; |
| 71 | |
| 72 | it("should return true for GPT-4 models", () => { |
| 73 | expect(supportsFn("gpt-4")).toBe(true); |
| 74 | expect(supportsFn("gpt-4-turbo")).toBe(true); |
| 75 | expect(supportsFn("gpt-4-1106-preview")).toBe(true); |
| 76 | }); |
| 77 | |
| 78 | it("should return true for O3 models", () => { |
| 79 | expect(supportsFn("o3")).toBe(true); |
| 80 | expect(supportsFn("o3-preview")).toBe(true); |
| 81 | }); |
| 82 | |
| 83 | it("should return undefined for unsupported models", () => { |
| 84 | expect(supportsFn("gpt-3.5-turbo")).toBeUndefined(); |
| 85 | expect(supportsFn("davinci")).toBeUndefined(); |
| 86 | }); |
| 87 | |
| 88 | it("should handle case insensitivity", () => { |
| 89 | expect(supportsFn("GPT-4-turbo")).toBe(true); |
| 90 | expect(supportsFn("O3-preview")).toBe(true); |
| 91 | }); |
| 92 | }); |
| 93 | |
| 94 | describe("gemini", () => { |
| 95 | const supportsFn = PROVIDER_TOOL_SUPPORT["gemini"]; |
| 96 | |
| 97 | it("should return true for all Gemini models", () => { |
| 98 | expect(supportsFn("gemini-pro")).toBe(true); |
| 99 | expect(supportsFn("gemini-1.5-pro")).toBe(true); |
| 100 | expect(supportsFn("gemini-ultra")).toBe(true); |
| 101 | }); |
| 102 | |
| 103 | it("should return false for non-Gemini models", () => { |
| 104 | expect(supportsFn("gpt-4")).toBe(false); |
| 105 | expect(supportsFn("claude-3")).toBe(false); |
| 106 | }); |
| 107 | |
| 108 | it("should handle case insensitivity", () => { |
| 109 | expect(supportsFn("GEMINI-pro")).toBe(true); |
| 110 | expect(supportsFn("Gemini-1.5-Pro")).toBe(true); |
| 111 | }); |
| 112 | }); |
| 113 | |
| 114 | describe("bedrock", () => { |
| 115 | const supportsFn = PROVIDER_TOOL_SUPPORT["bedrock"]; |
| 116 | |
| 117 | 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); |
| 120 | }); |
| 121 | |
| 122 | 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); |
| 125 | }); |
| 126 | |
| 127 | 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(); |
| 133 | }); |
| 134 | |
| 135 | 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(); |
| 138 | }); |
| 139 | |
| 140 | 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); |
| 143 | }); |
| 144 | }); |
| 145 | |
| 146 | describe("mistral", () => { |
| 147 | const supportsFn = PROVIDER_TOOL_SUPPORT["mistral"]; |
| 148 | |
| 149 | it("should return true for supported models", () => { |
| 150 | expect(supportsFn("mistral-large-latest")).toBe(true); |
| 151 | expect(supportsFn("mistral-small-latest")).toBe(true); |
| 152 | expect(supportsFn("codestral-latest")).toBe(true); |
| 153 | expect(supportsFn("ministral-8b-latest")).toBe(true); |
| 154 | expect(supportsFn("ministral-3b-latest")).toBe(true); |
| 155 | expect(supportsFn("pixtral-12b-2409")).toBe(true); |
| 156 | expect(supportsFn("pixtral-large-latest")).toBe(true); |
| 157 | expect(supportsFn("open-mistral-nemo")).toBe(true); |
| 158 | }); |
| 159 | |
| 160 | it("should return false for other unsupported models", () => { |
| 161 | expect(supportsFn("mistral-saba-latest")).toBe(false); |
| 162 | expect(supportsFn("mistral-embed")).toBe(false); |
| 163 | expect(supportsFn("mistral-moderation-latest")).toBe(false); |
| 164 | expect(supportsFn("mistral-ocr-latest")).toBe(false); |
| 165 | expect(supportsFn("open-codestral-mamba")).toBe(false); |
| 166 | }); |
| 167 | |
| 168 | it("should handle case insensitivity", () => { |
| 169 | expect(supportsFn("MISTRAL-LARGE-LATEST")).toBe(true); |
| 170 | expect(supportsFn("CODESTRAL-LATEST")).toBe(true); |
| 171 | expect(supportsFn("MINISTRAL-8B-LATEST")).toBe(true); |
| 172 | expect(supportsFn("PIXTRAL-12B-2409")).toBe(true); |
| 173 | }); |
| 174 | }); |
| 175 | |
| 176 | describe("ollama", () => { |
| 177 | const supportsFn = PROVIDER_TOOL_SUPPORT["ollama"]; |
| 178 | |
| 179 | it("should return true for supported models", () => { |
| 180 | expect(supportsFn("llama3.1")).toBe(true); |
| 181 | expect(supportsFn("llama3.2-8b")).toBe(true); |
| 182 | expect(supportsFn("llama3.3-70b")).toBe(true); |
| 183 | expect(supportsFn("qwen2")).toBe(true); |
| 184 | expect(supportsFn("mixtral-8x7b")).toBe(true); |
| 185 | expect(supportsFn("command-r")).toBe(true); |
| 186 | expect(supportsFn("smollm2")).toBe(true); |
| 187 | expect(supportsFn("hermes3")).toBe(true); |
| 188 | expect(supportsFn("athene-v2")).toBe(true); |
| 189 | expect(supportsFn("nemotron-4-340b")).toBe(true); |
| 190 | expect(supportsFn("llama3-groq")).toBe(true); |
| 191 | expect(supportsFn("granite3")).toBe(true); |
| 192 | expect(supportsFn("aya-expanse")).toBe(true); |
| 193 | expect(supportsFn("firefunction-v2")).toBe(true); |
| 194 | expect(supportsFn("mistral-7b")).toBe(true); |
| 195 | }); |
| 196 | |
| 197 | it("should return false for explicitly unsupported models", () => { |
| 198 | expect(supportsFn("vision")).toBe(false); |
| 199 | expect(supportsFn("math")).toBe(false); |
| 200 | expect(supportsFn("guard")).toBe(false); |
| 201 | expect(supportsFn("mistrallite")).toBe(false); |
| 202 | expect(supportsFn("mistral-openorca")).toBe(false); |
| 203 | }); |
| 204 | |
| 205 | it("should return undefined for other models", () => { |
| 206 | expect(supportsFn("llama2")).toBeUndefined(); |
| 207 | expect(supportsFn("phi-2")).toBeUndefined(); |
| 208 | expect(supportsFn("falcon")).toBeUndefined(); |
| 209 | }); |
| 210 | |
| 211 | it("should handle case insensitivity", () => { |
| 212 | expect(supportsFn("LLAMA3.1")).toBe(true); |
| 213 | expect(supportsFn("MIXTRAL-8x7b")).toBe(true); |
| 214 | expect(supportsFn("VISION")).toBe(false); |
| 215 | }); |
| 216 | }); |
| 217 | |
| 218 | describe("edge cases", () => { |
| 219 | it("should handle empty model names", () => { |
| 220 | expect(PROVIDER_TOOL_SUPPORT["continue-proxy"]("")).toBe(false); |
| 221 | expect(PROVIDER_TOOL_SUPPORT["anthropic"]("")).toBeUndefined(); |
| 222 | expect(PROVIDER_TOOL_SUPPORT["openai"]("")).toBeUndefined(); |
| 223 | expect(PROVIDER_TOOL_SUPPORT["gemini"]("")).toBe(false); |
| 224 | expect(PROVIDER_TOOL_SUPPORT["bedrock"]("")).toBeUndefined(); |
| 225 | expect(PROVIDER_TOOL_SUPPORT["ollama"]("")).toBeUndefined(); |
| 226 | }); |
| 227 | |
| 228 | it("should handle non-existent provider", () => { |
| 229 | // @ts-ignore - Testing runtime behavior with invalid provider |
| 230 | expect(PROVIDER_TOOL_SUPPORT["non-existent"]).toBeUndefined(); |
| 231 | }); |
| 232 | }); |
| 233 | }); |