Elffuss BraidHub

kikocis/continue public

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