Elffuss BraidHub

kikocis/continue public

87f9fb32eb22 · 7.1 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 if (model !== "deepseek-reasoner") {
183 return true;
184 }
185
186 return false;
187 },
188 watsonx: (model) => {
189 if (model.toLowerCase().includes("guard")) {
190 return false;
191 }
192 if (
193 [
194 "llama-3",
195 "llama-4",
196 "mistral",
197 "codestral",
198 "granite-3",
199 "devstral",
200 ].some((part) => model.toLowerCase().includes(part))
201 ) {
202 return true;
203 }
204
205 return false;
206 },
207 openrouter: (model) => {
208 // https://openrouter.ai/models?fmt=cards&supported_parameters=tools
209 if (
210 ["vision", "math", "guard", "mistrallite", "mistral-openorca"].some(
211 (part) => model.toLowerCase().includes(part),
212 )
213 ) {
214 return false;
215 }
216
217 const supportedPrefixes = [
218 "openai/gpt-3.5",
219 "openai/gpt-4",
220 "openai/o1",
221 "openai/o3",
222 "openai/o4",
223 "anthropic/claude-3",
224 "anthropic/claude-4",
225 "microsoft/phi-3",
226 "google/gemini-flash-1.5",
227 "google/gemini-2",
228 "google/gemini-pro",
229 "x-ai/grok",
230 "qwen/qwen3",
231 "qwen/qwen-",
232 "cohere/command-r",
233 "cohere/command-a",
234 "ai21/jamba-1.6",
235 "mistralai/mistral",
236 "mistralai/ministral",
237 "mistralai/codestral",
238 "mistralai/mixtral",
239 "mistral/ministral",
240 "mistral/devstral",
241 "mistralai/pixtral",
242 "meta-llama/llama-3.3",
243 "amazon/nova",
244 "deepseek/deepseek-r1",
245 "deepseek/deepseek-chat",
246 "meta-llama/llama-4",
247 "all-hands/openhands-lm-32b",
248 ];
249 for (const prefix of supportedPrefixes) {
250 if (model.toLowerCase().startsWith(prefix)) {
251 return true;
252 }
253 }
254
255 const specificModels = [
256 "qwen/qwq-32b",
257 "qwen/qwen-2.5-72b-instruct",
258 "meta-llama/llama-3.2-3b-instruct",
259 "meta-llama/llama-3-8b-instruct",
260 "meta-llama/llama-3-70b-instruct",
261 "arcee-ai/caller-large",
262 "nousresearch/hermes-3-llama-3.1-70b",
263 ];
264 for (const model of specificModels) {
265 if (model.toLowerCase() === model) {
266 return true;
267 }
268 }
269
270 const supportedContains = ["llama-3.1"];
271 for (const model of supportedContains) {
272 if (model.toLowerCase().includes(model)) {
273 return true;
274 }
275 }
276
277 return false;
278 },
279 };