Elffuss BraidHub

kikocis/continue public

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