Elffuss BraidHub

kikocis/continue public

0ecf3844803c · 7.4 KiBRawPermalink
1import { parseProxyModelName } from "@continuedev/config-yaml";
2
3export const PROVIDER_TOOL_SUPPORT: Record<string, (model: string) => boolean> =
4 {
5 "continue-proxy": (model) => {
6 try {
7 const { provider, model: _model } = parseProxyModelName(model);
8 if (provider && _model && provider !== "continue-proxy") {
9 const fn = PROVIDER_TOOL_SUPPORT[provider];
10 if (fn) {
11 return fn(_model);
12 }
13 }
14 } catch (e) {}
15
16 return [
17 "claude-3-5",
18 "claude-3.5",
19 "claude-3-7",
20 "claude-3.7",
21 "claude-sonnet-4",
22 "claude-4-sonnet",
23 "gpt-4",
24 "o3",
25 "gemini",
26 "claude-opus-4",
27 ].some((part) => model.toLowerCase().startsWith(part));
28 },
29 anthropic: (model) => {
30 if (
31 [
32 "claude-3-5",
33 "claude-3.5",
34 "claude-3-7",
35 "claude-3.7",
36 "claude-sonnet-4",
37 "claude-4-sonnet",
38 "claude-opus-4",
39 ].some((part) => model.toLowerCase().startsWith(part))
40 ) {
41 return true;
42 }
43
44 return false;
45 },
46 azure: (model) => {
47 if (
48 model.toLowerCase().startsWith("gpt-4") ||
49 model.toLowerCase().startsWith("o3")
50 )
51 return true;
52 return false;
53 },
54 openai: (model) => {
55 // https://platform.openai.com/docs/guides/function-calling#models-supporting-function-calling
56 if (
57 model.toLowerCase().startsWith("gpt-4") ||
58 model.toLowerCase().startsWith("o3")
59 ) {
60 return true;
61 }
62 // firworks-ai https://docs.fireworks.ai/guides/function-calling
63 if (model.startsWith("accounts/fireworks/models/")) {
64 switch (model.substring(26)) {
65 case "llama-v3p1-405b-instruct":
66 case "llama-v3p1-70b-instruct":
67 case "qwen2p5-72b-instruct":
68 case "firefunction-v1":
69 case "firefunction-v2":
70 return true;
71 default:
72 return false;
73 }
74 }
75
76 return false;
77 },
78 cohere: (model) => {
79 return model.toLowerCase().startsWith("command");
80 },
81 gemini: (model) => {
82 // All gemini models support function calling
83 return model.toLowerCase().includes("gemini");
84 },
85 vertexai: (model) => {
86 // All gemini models except flash 2.0 lite support function calling
87 return (
88 model.toLowerCase().includes("gemini") &&
89 !model.toLowerCase().includes("lite")
90 );
91 },
92 bedrock: (model) => {
93 if (
94 [
95 "claude-3-5-sonnet",
96 "claude-3.5-sonnet",
97 "claude-3-7-sonnet",
98 "claude-3.7-sonnet",
99 "claude-sonnet-4",
100 "claude-4-sonnet",
101 "claude-opus-4",
102 "nova-lite",
103 "nova-pro",
104 "nova-micro",
105 "nova-premier",
106 ].some((part) => model.toLowerCase().includes(part))
107 ) {
108 return true;
109 }
110
111 return false;
112 },
113 mistral: (model) => {
114 // https://docs.mistral.ai/capabilities/function_calling/
115 return (
116 !model.toLowerCase().includes("mamba") &&
117 [
118 "devstral",
119 "codestral",
120 "mistral-large",
121 "mistral-small",
122 "pixtral",
123 "ministral",
124 "mistral-nemo",
125 "devstral",
126 ].some((part) => model.toLowerCase().includes(part))
127 );
128 },
129 // https://ollama.com/search?c=tools
130 ollama: (model) => {
131 let modelName = "";
132 // Extract the model name after the last slash to support other registries
133 if (model.includes("/")) {
134 let parts = model.split("/");
135 modelName = parts[parts.length - 1];
136 } else {
137 modelName = model;
138 }
139
140 if (
141 ["vision", "math", "guard", "mistrallite", "mistral-openorca"].some(
142 (part) => modelName.toLowerCase().includes(part),
143 )
144 ) {
145 return false;
146 }
147 if (
148 [
149 "cogito",
150 "llama3.3",
151 "qwq",
152 "llama3.2",
153 "llama3.1",
154 "qwen2",
155 "qwen3",
156 "mixtral",
157 "command-r",
158 "command-a",
159 "smollm2",
160 "hermes3",
161 "athene-v2",
162 "nemotron",
163 "llama3-groq",
164 "granite3",
165 "granite-3",
166 "aya-expanse",
167 "firefunction-v2",
168 "mistral",
169 "devstral",
170 ].some((part) => modelName.toLowerCase().includes(part))
171 ) {
172 return true;
173 }
174
175 return false;
176 },
177 sambanova: (model) => {
178 // https://docs.sambanova.ai/cloud/docs/capabilities/function-calling
179 if (
180 model.toLowerCase().startsWith("meta-llama-3") ||
181 model.toLowerCase().includes("llama-4") ||
182 model.toLowerCase().includes("deepseek")
183 ) {
184 return true;
185 }
186
187 return false;
188 },
189 deepseek: (model) => {
190 // https://api-docs.deepseek.com/quick_start/pricing
191 // https://api-docs.deepseek.com/guides/function_calling
192 if (model === "deepseek-reasoner" || model === "deepseek-chat") {
193 return true;
194 }
195
196 return false;
197 },
198 watsonx: (model) => {
199 if (model.toLowerCase().includes("guard")) {
200 return false;
201 }
202 if (
203 [
204 "llama-3",
205 "llama-4",
206 "mistral",
207 "codestral",
208 "granite-3",
209 "devstral",
210 ].some((part) => model.toLowerCase().includes(part))
211 ) {
212 return true;
213 }
214
215 return false;
216 },
217 openrouter: (model) => {
218 // https://openrouter.ai/models?fmt=cards&supported_parameters=tools
219 if (
220 ["vision", "math", "guard", "mistrallite", "mistral-openorca"].some(
221 (part) => model.toLowerCase().includes(part),
222 )
223 ) {
224 return false;
225 }
226
227 const supportedPrefixes = [
228 "openai/gpt-3.5",
229 "openai/gpt-4",
230 "openai/o1",
231 "openai/o3",
232 "openai/o4",
233 "anthropic/claude-3",
234 "anthropic/claude-4",
235 "microsoft/phi-3",
236 "google/gemini-flash-1.5",
237 "google/gemini-2",
238 "google/gemini-pro",
239 "x-ai/grok",
240 "qwen/qwen3",
241 "qwen/qwen-",
242 "cohere/command-r",
243 "cohere/command-a",
244 "ai21/jamba-1.6",
245 "mistralai/mistral",
246 "mistralai/ministral",
247 "mistralai/codestral",
248 "mistralai/mixtral",
249 "mistral/ministral",
250 "mistral/devstral",
251 "mistralai/pixtral",
252 "meta-llama/llama-3.3",
253 "amazon/nova",
254 "deepseek/deepseek-r1",
255 "deepseek/deepseek-chat",
256 "meta-llama/llama-4",
257 "all-hands/openhands-lm-32b",
258 ];
259 for (const prefix of supportedPrefixes) {
260 if (model.toLowerCase().startsWith(prefix)) {
261 return true;
262 }
263 }
264
265 const specificModels = [
266 "qwen/qwq-32b",
267 "qwen/qwen-2.5-72b-instruct",
268 "meta-llama/llama-3.2-3b-instruct",
269 "meta-llama/llama-3-8b-instruct",
270 "meta-llama/llama-3-70b-instruct",
271 "arcee-ai/caller-large",
272 "nousresearch/hermes-3-llama-3.1-70b",
273 ];
274 for (const model of specificModels) {
275 if (model.toLowerCase() === model) {
276 return true;
277 }
278 }
279
280 const supportedContains = ["llama-3.1"];
281 for (const model of supportedContains) {
282 if (model.toLowerCase().includes(model)) {
283 return true;
284 }
285 }
286
287 return false;
288 },
289 };