Elffuss BraidHub

kikocis/continue public

ed46f5b1432f · 9.0 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(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 expect(supportsFn("devstral-latest")).toBe(true);
159 });
160
161 it("should return false for other unsupported models", () => {
162 expect(supportsFn("mistral-saba-latest")).toBe(false);
163 expect(supportsFn("mistral-embed")).toBe(false);
164 expect(supportsFn("mistral-moderation-latest")).toBe(false);
165 expect(supportsFn("mistral-ocr-latest")).toBe(false);
166 expect(supportsFn("open-codestral-mamba")).toBe(false);
167 });
168
169 it("should handle case insensitivity", () => {
170 expect(supportsFn("MISTRAL-LARGE-LATEST")).toBe(true);
171 expect(supportsFn("CODESTRAL-LATEST")).toBe(true);
172 expect(supportsFn("MINISTRAL-8B-LATEST")).toBe(true);
173 expect(supportsFn("PIXTRAL-12B-2409")).toBe(true);
174 expect(supportsFn("DEVSTRAL-LATEST")).toBe(true);
175 });
176 });
177
178 describe("ollama", () => {
179 const supportsFn = PROVIDER_TOOL_SUPPORT["ollama"];
180
181 it("should return true for supported models", () => {
182 expect(supportsFn("llama3.1")).toBe(true);
183 expect(supportsFn("llama3.2-8b")).toBe(true);
184 expect(supportsFn("llama3.3-70b")).toBe(true);
185 expect(supportsFn("qwen2")).toBe(true);
186 expect(supportsFn("mixtral-8x7b")).toBe(true);
187 expect(supportsFn("command-r")).toBe(true);
188 expect(supportsFn("smollm2")).toBe(true);
189 expect(supportsFn("hermes3")).toBe(true);
190 expect(supportsFn("athene-v2")).toBe(true);
191 expect(supportsFn("nemotron-4-340b")).toBe(true);
192 expect(supportsFn("llama3-groq")).toBe(true);
193 expect(supportsFn("granite3")).toBe(true);
194 expect(supportsFn("aya-expanse")).toBe(true);
195 expect(supportsFn("firefunction-v2")).toBe(true);
196 expect(supportsFn("mistral-7b")).toBe(true);
197 expect(supportsFn("devstral-24b")).toBe(true);
198 });
199
200 it("should return false for explicitly unsupported models", () => {
201 expect(supportsFn("vision")).toBe(false);
202 expect(supportsFn("math")).toBe(false);
203 expect(supportsFn("guard")).toBe(false);
204 expect(supportsFn("mistrallite")).toBe(false);
205 expect(supportsFn("mistral-openorca")).toBe(false);
206 });
207
208 it("should return undefined for other models", () => {
209 expect(supportsFn("llama2")).toBeUndefined();
210 expect(supportsFn("phi-2")).toBeUndefined();
211 expect(supportsFn("falcon")).toBeUndefined();
212 });
213
214 it("should handle case insensitivity", () => {
215 expect(supportsFn("LLAMA3.1")).toBe(true);
216 expect(supportsFn("MIXTRAL-8x7b")).toBe(true);
217 expect(supportsFn("VISION")).toBe(false);
218 });
219 });
220
221 describe("edge cases", () => {
222 it("should handle empty model names", () => {
223 expect(PROVIDER_TOOL_SUPPORT["continue-proxy"]("")).toBe(false);
224 expect(PROVIDER_TOOL_SUPPORT["anthropic"]("")).toBeUndefined();
225 expect(PROVIDER_TOOL_SUPPORT["openai"]("")).toBeUndefined();
226 expect(PROVIDER_TOOL_SUPPORT["gemini"]("")).toBe(false);
227 expect(PROVIDER_TOOL_SUPPORT["bedrock"]("")).toBeUndefined();
228 expect(PROVIDER_TOOL_SUPPORT["ollama"]("")).toBeUndefined();
229 });
230
231 it("should handle non-existent provider", () => {
232 // @ts-ignore - Testing runtime behavior with invalid provider
233 expect(PROVIDER_TOOL_SUPPORT["non-existent"]).toBeUndefined();
234 });
235 });
236});