| 1 | export 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 | }; |