Elffuss BraidHub

kikocis/continue public

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