Elffuss BraidHub

kikocis/continue public

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