Elffuss BraidHub

kikocis/continue public

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