Elffuss BraidHub

kikocis/continue public

99fe51849b68 · 7.5 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 const lowerCaseModel = model.toLowerCase();
87 // All gemini models except flash 2.0 lite support function calling
88 if (lowerCaseModel.includes("lite")) {
89 return false;
90 }
91 return ["claude", "gemini"].some((val) => lowerCaseModel.includes(val));
92 },
93 bedrock: (model) => {
94 if (
95 [
96 "claude-3-5-sonnet",
97 "claude-3.5-sonnet",
98 "claude-3-7-sonnet",
99 "claude-3.7-sonnet",
100 "claude-sonnet-4",
101 "claude-4-sonnet",
102 "claude-opus-4",
103 "nova-lite",
104 "nova-pro",
105 "nova-micro",
106 "nova-premier",
107 ].some((part) => model.toLowerCase().includes(part))
108 ) {
109 return true;
110 }
111
112 return false;
113 },
114 mistral: (model) => {
115 // https://docs.mistral.ai/capabilities/function_calling/
116 return (
117 !model.toLowerCase().includes("mamba") &&
118 [
119 "devstral",
120 "codestral",
121 "mistral-large",
122 "mistral-small",
123 "pixtral",
124 "ministral",
125 "mistral-nemo",
126 "devstral",
127 ].some((part) => model.toLowerCase().includes(part))
128 );
129 },
130 // https://ollama.com/search?c=tools
131 ollama: (model) => {
132 let modelName = "";
133 // Extract the model name after the last slash to support other registries
134 if (model.includes("/")) {
135 let parts = model.split("/");
136 modelName = parts[parts.length - 1];
137 } else {
138 modelName = model;
139 }
140
141 if (
142 ["vision", "math", "guard", "mistrallite", "mistral-openorca"].some(
143 (part) => modelName.toLowerCase().includes(part),
144 )
145 ) {
146 return false;
147 }
148 if (
149 [
150 "cogito",
151 "llama3.3",
152 "qwq",
153 "llama3.2",
154 "llama3.1",
155 "qwen2",
156 "qwen3",
157 "mixtral",
158 "command-r",
159 "command-a",
160 "smollm2",
161 "hermes3",
162 "athene-v2",
163 "nemotron",
164 "llama3-groq",
165 "granite3",
166 "granite-3",
167 "aya-expanse",
168 "firefunction-v2",
169 "mistral",
170 "devstral",
171 ].some((part) => modelName.toLowerCase().includes(part))
172 ) {
173 return true;
174 }
175
176 return false;
177 },
178 sambanova: (model) => {
179 // https://docs.sambanova.ai/cloud/docs/capabilities/function-calling
180 if (
181 model.toLowerCase().startsWith("meta-llama-3") ||
182 model.toLowerCase().includes("llama-4") ||
183 model.toLowerCase().includes("deepseek")
184 ) {
185 return true;
186 }
187
188 return false;
189 },
190 deepseek: (model) => {
191 // https://api-docs.deepseek.com/quick_start/pricing
192 // https://api-docs.deepseek.com/guides/function_calling
193 if (model === "deepseek-reasoner" || model === "deepseek-chat") {
194 return true;
195 }
196
197 return false;
198 },
199 watsonx: (model) => {
200 if (model.toLowerCase().includes("guard")) {
201 return false;
202 }
203 if (
204 [
205 "llama-3",
206 "llama-4",
207 "mistral",
208 "codestral",
209 "granite-3",
210 "devstral",
211 ].some((part) => model.toLowerCase().includes(part))
212 ) {
213 return true;
214 }
215
216 return false;
217 },
218 openrouter: (model) => {
219 // https://openrouter.ai/models?fmt=cards&supported_parameters=tools
220 if (
221 ["vision", "math", "guard", "mistrallite", "mistral-openorca"].some(
222 (part) => model.toLowerCase().includes(part),
223 )
224 ) {
225 return false;
226 }
227
228 const supportedPrefixes = [
229 "openai/gpt-3.5",
230 "openai/gpt-4",
231 "openai/o1",
232 "openai/o3",
233 "openai/o4",
234 "anthropic/claude-3",
235 "anthropic/claude-4",
236 "microsoft/phi-3",
237 "google/gemini-flash-1.5",
238 "google/gemini-2",
239 "google/gemini-pro",
240 "x-ai/grok",
241 "qwen/qwen3",
242 "qwen/qwen-",
243 "cohere/command-r",
244 "cohere/command-a",
245 "ai21/jamba-1.6",
246 "mistralai/mistral",
247 "mistralai/ministral",
248 "mistralai/codestral",
249 "mistralai/mixtral",
250 "mistral/ministral",
251 "mistral/devstral",
252 "mistralai/pixtral",
253 "meta-llama/llama-3.3",
254 "amazon/nova",
255 "deepseek/deepseek-r1",
256 "deepseek/deepseek-chat",
257 "meta-llama/llama-4",
258 "all-hands/openhands-lm-32b",
259 ];
260 for (const prefix of supportedPrefixes) {
261 if (model.toLowerCase().startsWith(prefix)) {
262 return true;
263 }
264 }
265
266 const specificModels = [
267 "qwen/qwq-32b",
268 "qwen/qwen-2.5-72b-instruct",
269 "meta-llama/llama-3.2-3b-instruct",
270 "meta-llama/llama-3-8b-instruct",
271 "meta-llama/llama-3-70b-instruct",
272 "arcee-ai/caller-large",
273 "nousresearch/hermes-3-llama-3.1-70b",
274 ];
275 for (const model of specificModels) {
276 if (model.toLowerCase() === model) {
277 return true;
278 }
279 }
280
281 const supportedContains = ["llama-3.1"];
282 for (const model of supportedContains) {
283 if (model.toLowerCase().includes(model)) {
284 return true;
285 }
286 }
287
288 return false;
289 },
290 };