Elffuss BraidHub

kikocis/continue public

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