Elffuss BraidHub

kikocis/continue public

e8214ab5fa65 · 9.7 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("gemini", () => {
113 const supportsFn = PROVIDER_TOOL_SUPPORT["gemini"];
114
115 it("should return true for all Gemini models", () => {
116 expect(supportsFn("gemini-pro")).toBe(true);
117 expect(supportsFn("gemini-1.5-pro")).toBe(true);
118 expect(supportsFn("gemini-ultra")).toBe(true);
119 });
120
121 it("should return false for non-Gemini models", () => {
122 expect(supportsFn("gpt-4")).toBe(false);
123 expect(supportsFn("claude-3")).toBe(false);
124 });
125
126 it("should handle case insensitivity", () => {
127 expect(supportsFn("GEMINI-pro")).toBe(true);
128 expect(supportsFn("Gemini-1.5-Pro")).toBe(true);
129 });
130 });
131
132 describe("bedrock", () => {
133 const supportsFn = PROVIDER_TOOL_SUPPORT["bedrock"];
134
135 it("should return true for Claude 3.5 Sonnet models", () => {
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 );
142 });
143
144 it("should return true for Claude 3.7 Sonnet models", () => {
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 );
151 });
152
153 it("should return undefined for Claude Haiku and Opus models", () => {
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);
165 });
166
167 it("should return undefined for other unsupported models", () => {
168 expect(supportsFn("anthropic.claude-instant-v1")).toBe(false);
169 expect(supportsFn("anthropic.titan-text-express-v1")).toBe(false);
170 });
171
172 it("should handle case insensitivity", () => {
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 );
179 });
180 });
181
182 describe("mistral", () => {
183 const supportsFn = PROVIDER_TOOL_SUPPORT["mistral"];
184
185 it("should return true for supported models", () => {
186 expect(supportsFn("mistral-large-latest")).toBe(true);
187 expect(supportsFn("mistral-small-latest")).toBe(true);
188 expect(supportsFn("codestral-latest")).toBe(true);
189 expect(supportsFn("ministral-8b-latest")).toBe(true);
190 expect(supportsFn("ministral-3b-latest")).toBe(true);
191 expect(supportsFn("pixtral-12b-2409")).toBe(true);
192 expect(supportsFn("pixtral-large-latest")).toBe(true);
193 expect(supportsFn("open-mistral-nemo")).toBe(true);
194 expect(supportsFn("devstral-latest")).toBe(true);
195 });
196
197 it("should return false for other unsupported models", () => {
198 expect(supportsFn("mistral-saba-latest")).toBe(false);
199 expect(supportsFn("mistral-embed")).toBe(false);
200 expect(supportsFn("mistral-moderation-latest")).toBe(false);
201 expect(supportsFn("mistral-ocr-latest")).toBe(false);
202 expect(supportsFn("open-codestral-mamba")).toBe(false);
203 });
204
205 it("should handle case insensitivity", () => {
206 expect(supportsFn("MISTRAL-LARGE-LATEST")).toBe(true);
207 expect(supportsFn("CODESTRAL-LATEST")).toBe(true);
208 expect(supportsFn("MINISTRAL-8B-LATEST")).toBe(true);
209 expect(supportsFn("PIXTRAL-12B-2409")).toBe(true);
210 expect(supportsFn("DEVSTRAL-LATEST")).toBe(true);
211 });
212 });
213
214 describe("ollama", () => {
215 const supportsFn = PROVIDER_TOOL_SUPPORT["ollama"];
216
217 it("should return true for supported models", () => {
218 expect(supportsFn("llama3.1")).toBe(true);
219 expect(supportsFn("llama3.2-8b")).toBe(true);
220 expect(supportsFn("llama3.3-70b")).toBe(true);
221 expect(supportsFn("qwen2")).toBe(true);
222 expect(supportsFn("mixtral-8x7b")).toBe(true);
223 expect(supportsFn("command-r")).toBe(true);
224 expect(supportsFn("smollm2")).toBe(true);
225 expect(supportsFn("hermes3")).toBe(true);
226 expect(supportsFn("athene-v2")).toBe(true);
227 expect(supportsFn("nemotron-4-340b")).toBe(true);
228 expect(supportsFn("llama3-groq")).toBe(true);
229 expect(supportsFn("granite3")).toBe(true);
230 expect(supportsFn("aya-expanse")).toBe(true);
231 expect(supportsFn("firefunction-v2")).toBe(true);
232 expect(supportsFn("mistral-7b")).toBe(true);
233 expect(supportsFn("devstral-24b")).toBe(true);
234 });
235
236 it("should return false for explicitly unsupported models", () => {
237 expect(supportsFn("vision")).toBe(false);
238 expect(supportsFn("math")).toBe(false);
239 expect(supportsFn("guard")).toBe(false);
240 expect(supportsFn("mistrallite")).toBe(false);
241 expect(supportsFn("mistral-openorca")).toBe(false);
242 });
243
244 it("should return undefined for other models", () => {
245 expect(supportsFn("llama2")).toBe(false);
246 expect(supportsFn("phi-2")).toBe(false);
247 expect(supportsFn("falcon")).toBe(false);
248 });
249
250 it("should handle case insensitivity", () => {
251 expect(supportsFn("LLAMA3.1")).toBe(true);
252 expect(supportsFn("MIXTRAL-8x7b")).toBe(true);
253 expect(supportsFn("VISION")).toBe(false);
254 });
255 });
256
257 describe("edge cases", () => {
258 it("should handle empty model names", () => {
259 expect(PROVIDER_TOOL_SUPPORT["continue-proxy"]("")).toBe(false);
260 expect(PROVIDER_TOOL_SUPPORT["anthropic"]("")).toBe(false);
261 expect(PROVIDER_TOOL_SUPPORT["openai"]("")).toBe(false);
262 expect(PROVIDER_TOOL_SUPPORT["gemini"]("")).toBe(false);
263 expect(PROVIDER_TOOL_SUPPORT["bedrock"]("")).toBe(false);
264 expect(PROVIDER_TOOL_SUPPORT["ollama"]("")).toBe(false);
265 });
266
267 it("should handle non-existent provider", () => {
268 // @ts-ignore - Testing runtime behavior with invalid provider
269 expect(PROVIDER_TOOL_SUPPORT["non-existent"]).toBe(undefined);
270 });
271 });
272});