Elffuss BraidHub

kikocis/continue public

99fe51849b68 · 10.1 KiBRawPermalink
1// core/llm/toolSupport.test.ts
2import { PROVIDER_TOOL_SUPPORT } from "./toolSupport";
3
4describe("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 O3 models", () => {
34 expect(supportsFn("ownerSlug/packageSlug/openai/o3-preview")).toBe(true);
35 });
36
37 it("should return true for Gemini models", () => {
38 expect(supportsFn("ownerSlug/packageSlug/gemini/gemini-pro")).toBe(true);
39 expect(supportsFn("ownerSlug/packageSlug/gemini/gemini-1.5-pro")).toBe(
40 true,
41 );
42 });
43
44 it("should return false for unsupported models", () => {
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);
52 });
53
54 it("should handle case insensitivity", () => {
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);
60 });
61 });
62
63 describe("anthropic", () => {
64 const supportsFn = PROVIDER_TOOL_SUPPORT["anthropic"];
65
66 it("should return true for Claude 3.5 models", () => {
67 expect(supportsFn("claude-3-5-sonnet")).toBe(true);
68 expect(supportsFn("claude-3.5-haiku")).toBe(true);
69 });
70
71 it("should return true for Claude 3.7 models", () => {
72 expect(supportsFn("claude-3-7-haiku")).toBe(true);
73 expect(supportsFn("claude-3.7-sonnet")).toBe(true);
74 });
75
76 it("should return undefined for unsupported models", () => {
77 expect(supportsFn("claude-2")).toBe(false);
78 expect(supportsFn("claude-instant")).toBe(false);
79 });
80
81 it("should handle case insensitivity", () => {
82 expect(supportsFn("CLAUDE-3-5-sonnet")).toBe(true);
83 expect(supportsFn("CLAUDE-3.7-haiku")).toBe(true);
84 });
85 });
86
87 describe("openai", () => {
88 const supportsFn = PROVIDER_TOOL_SUPPORT["openai"];
89
90 it("should return true for GPT-4 models", () => {
91 expect(supportsFn("gpt-4")).toBe(true);
92 expect(supportsFn("gpt-4-turbo")).toBe(true);
93 expect(supportsFn("gpt-4-1106-preview")).toBe(true);
94 });
95
96 it("should return true for O3 models", () => {
97 expect(supportsFn("o3")).toBe(true);
98 expect(supportsFn("o3-preview")).toBe(true);
99 });
100
101 it("should return undefined for unsupported models", () => {
102 expect(supportsFn("gpt-3.5-turbo")).toBe(false);
103 expect(supportsFn("davinci")).toBe(false);
104 });
105
106 it("should handle case insensitivity", () => {
107 expect(supportsFn("GPT-4-turbo")).toBe(true);
108 expect(supportsFn("O3-preview")).toBe(true);
109 });
110 });
111
112 describe("cohere", () => {
113 const supportsFn = PROVIDER_TOOL_SUPPORT["cohere"];
114
115 it("should return true for Command models", () => {
116 expect(supportsFn("command-r")).toBe(true);
117 expect(supportsFn("command-a")).toBe(true);
118 });
119
120 it("should return false for other models", () => {
121 expect(supportsFn("c4ai-aya-expanse-32b")).toBe(false);
122 });
123 });
124
125 describe("gemini", () => {
126 const supportsFn = PROVIDER_TOOL_SUPPORT["gemini"];
127
128 it("should return true for all Gemini models", () => {
129 expect(supportsFn("gemini-pro")).toBe(true);
130 expect(supportsFn("gemini-1.5-pro")).toBe(true);
131 expect(supportsFn("gemini-ultra")).toBe(true);
132 });
133
134 it("should return false for non-Gemini models", () => {
135 expect(supportsFn("gpt-4")).toBe(false);
136 expect(supportsFn("claude-3")).toBe(false);
137 });
138
139 it("should handle case insensitivity", () => {
140 expect(supportsFn("GEMINI-pro")).toBe(true);
141 expect(supportsFn("Gemini-1.5-Pro")).toBe(true);
142 });
143 });
144
145 describe("bedrock", () => {
146 const supportsFn = PROVIDER_TOOL_SUPPORT["bedrock"];
147
148 it("should return true for Claude 3.5 Sonnet models", () => {
149 expect(supportsFn("anthropic.claude-3-5-sonnet-20240620-v1:0")).toBe(
150 true,
151 );
152 expect(supportsFn("anthropic.claude-3.5-sonnet-20240620-v1:0")).toBe(
153 true,
154 );
155 });
156
157 it("should return true for Claude 3.7 Sonnet models", () => {
158 expect(supportsFn("anthropic.claude-3-7-sonnet-20240620-v1:0")).toBe(
159 true,
160 );
161 expect(supportsFn("anthropic.claude-3.7-sonnet-20240620-v1:0")).toBe(
162 true,
163 );
164 });
165
166 it("should return undefined for Claude Haiku and Opus models", () => {
167 expect(supportsFn("anthropic.claude-3-5-haiku-20240307-v1:0")).toBe(
168 false,
169 );
170 expect(supportsFn("anthropic.claude-3.5-haiku-20240620-v1:0")).toBe(
171 false,
172 );
173 expect(supportsFn("anthropic.claude-3-7-haiku-20240620-v1:0")).toBe(
174 false,
175 );
176 expect(supportsFn("anthropic.claude-3-5-opus-20240620-v1:0")).toBe(false);
177 expect(supportsFn("anthropic.claude-3.7-opus-20240620-v1:0")).toBe(false);
178 });
179
180 it("should return undefined for other unsupported models", () => {
181 expect(supportsFn("anthropic.claude-instant-v1")).toBe(false);
182 expect(supportsFn("anthropic.titan-text-express-v1")).toBe(false);
183 });
184
185 it("should handle case insensitivity", () => {
186 expect(supportsFn("ANTHROPIC.CLAUDE-3-5-SONNET-20240620-v1:0")).toBe(
187 true,
188 );
189 expect(supportsFn("ANTHROPIC.CLAUDE-3.7-SONNET-20240620-v1:0")).toBe(
190 true,
191 );
192 });
193 });
194
195 describe("mistral", () => {
196 const supportsFn = PROVIDER_TOOL_SUPPORT["mistral"];
197
198 it("should return true for supported models", () => {
199 expect(supportsFn("mistral-large-latest")).toBe(true);
200 expect(supportsFn("mistral-small-latest")).toBe(true);
201 expect(supportsFn("codestral-latest")).toBe(true);
202 expect(supportsFn("ministral-8b-latest")).toBe(true);
203 expect(supportsFn("ministral-3b-latest")).toBe(true);
204 expect(supportsFn("pixtral-12b-2409")).toBe(true);
205 expect(supportsFn("pixtral-large-latest")).toBe(true);
206 expect(supportsFn("open-mistral-nemo")).toBe(true);
207 expect(supportsFn("devstral-latest")).toBe(true);
208 });
209
210 it("should return false for other unsupported models", () => {
211 expect(supportsFn("mistral-saba-latest")).toBe(false);
212 expect(supportsFn("mistral-embed")).toBe(false);
213 expect(supportsFn("mistral-moderation-latest")).toBe(false);
214 expect(supportsFn("mistral-ocr-latest")).toBe(false);
215 expect(supportsFn("open-codestral-mamba")).toBe(false);
216 });
217
218 it("should handle case insensitivity", () => {
219 expect(supportsFn("MISTRAL-LARGE-LATEST")).toBe(true);
220 expect(supportsFn("CODESTRAL-LATEST")).toBe(true);
221 expect(supportsFn("MINISTRAL-8B-LATEST")).toBe(true);
222 expect(supportsFn("PIXTRAL-12B-2409")).toBe(true);
223 expect(supportsFn("DEVSTRAL-LATEST")).toBe(true);
224 });
225 });
226
227 describe("ollama", () => {
228 const supportsFn = PROVIDER_TOOL_SUPPORT["ollama"];
229
230 it("should return true for supported models", () => {
231 expect(supportsFn("llama3.1")).toBe(true);
232 expect(supportsFn("llama3.2-8b")).toBe(true);
233 expect(supportsFn("llama3.3-70b")).toBe(true);
234 expect(supportsFn("qwen2")).toBe(true);
235 expect(supportsFn("mixtral-8x7b")).toBe(true);
236 expect(supportsFn("command-r")).toBe(true);
237 expect(supportsFn("command-a")).toBe(true);
238 expect(supportsFn("smollm2")).toBe(true);
239 expect(supportsFn("hermes3")).toBe(true);
240 expect(supportsFn("athene-v2")).toBe(true);
241 expect(supportsFn("nemotron-4-340b")).toBe(true);
242 expect(supportsFn("llama3-groq")).toBe(true);
243 expect(supportsFn("granite3")).toBe(true);
244 expect(supportsFn("aya-expanse")).toBe(true);
245 expect(supportsFn("firefunction-v2")).toBe(true);
246 expect(supportsFn("mistral-7b")).toBe(true);
247 expect(supportsFn("devstral-24b")).toBe(true);
248 });
249
250 it("should return false for explicitly unsupported models", () => {
251 expect(supportsFn("vision")).toBe(false);
252 expect(supportsFn("math")).toBe(false);
253 expect(supportsFn("guard")).toBe(false);
254 expect(supportsFn("mistrallite")).toBe(false);
255 expect(supportsFn("mistral-openorca")).toBe(false);
256 });
257
258 it("should return undefined for other models", () => {
259 expect(supportsFn("llama2")).toBe(false);
260 expect(supportsFn("phi-2")).toBe(false);
261 expect(supportsFn("falcon")).toBe(false);
262 });
263
264 it("should handle case insensitivity", () => {
265 expect(supportsFn("LLAMA3.1")).toBe(true);
266 expect(supportsFn("MIXTRAL-8x7b")).toBe(true);
267 expect(supportsFn("VISION")).toBe(false);
268 });
269 });
270
271 describe("edge cases", () => {
272 it("should handle empty model names", () => {
273 expect(PROVIDER_TOOL_SUPPORT["continue-proxy"]("")).toBe(false);
274 expect(PROVIDER_TOOL_SUPPORT["anthropic"]("")).toBe(false);
275 expect(PROVIDER_TOOL_SUPPORT["openai"]("")).toBe(false);
276 expect(PROVIDER_TOOL_SUPPORT["gemini"]("")).toBe(false);
277 expect(PROVIDER_TOOL_SUPPORT["bedrock"]("")).toBe(false);
278 expect(PROVIDER_TOOL_SUPPORT["ollama"]("")).toBe(false);
279 });
280
281 it("should handle non-existent provider", () => {
282 // @ts-ignore - Testing runtime behavior with invalid provider
283 expect(PROVIDER_TOOL_SUPPORT["non-existent"]).toBe(undefined);
284 });
285 });
286});