Elffuss BraidHub

kikocis/continue public

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