Elffuss BraidHub

kikocis/continue public

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