Claude model deprecations (#4306) * Claude: deprecate Claude 2 models * Claude: flatten tool call schema * Remove deprecated Sonnet 3 from captioning list
Signed| @@ -3021,10 +3021,7 @@ | |||
| 3021 | <option value="claude-3-5-haiku-latest">claude-3-5-haiku-latest</option> | 3021 | <option value="claude-3-5-haiku-latest">claude-3-5-haiku-latest</option> |
| 3022 | <option value="claude-3-5-haiku-20241022">claude-3-5-haiku-20241022</option> | 3022 | <option value="claude-3-5-haiku-20241022">claude-3-5-haiku-20241022</option> |
| 3023 | <option value="claude-3-opus-20240229">claude-3-opus-20240229</option> | 3023 | <option value="claude-3-opus-20240229">claude-3-opus-20240229</option> |
| 3024 | <option value="claude-3-sonnet-20240229">claude-3-sonnet-20240229</option> | ||
| 3025 | <option value="claude-3-haiku-20240307">claude-3-haiku-20240307</option> | 3024 | <option value="claude-3-haiku-20240307">claude-3-haiku-20240307</option> |
| 3026 | <option value="claude-2.1">claude-2.1</option> | ||
| 3027 | <option value="claude-2.0">claude-2.0</option> | ||
| 3028 | </optgroup> | 3025 | </optgroup> |
| 3029 | </select> | 3026 | </select> |
| 3030 | </div> | 3027 | </div> |
| @@ -85,7 +85,6 @@ | |||
| 85 | <option data-type="anthropic" value="claude-3-5-haiku-latest">claude-3-5-haiku-latest</option> | 85 | <option data-type="anthropic" value="claude-3-5-haiku-latest">claude-3-5-haiku-latest</option> |
| 86 | <option data-type="anthropic" value="claude-3-5-haiku-20241022">claude-3-5-haiku-20241022</option> | 86 | <option data-type="anthropic" value="claude-3-5-haiku-20241022">claude-3-5-haiku-20241022</option> |
| 87 | <option data-type="anthropic" value="claude-3-opus-20240229">claude-3-opus-20240229</option> | 87 | <option data-type="anthropic" value="claude-3-opus-20240229">claude-3-opus-20240229</option> |
| 88 | <option data-type="anthropic" value="claude-3-sonnet-20240229">claude-3-sonnet-20240229</option> | ||
| 89 | <option data-type="anthropic" value="claude-3-haiku-20240307">claude-3-haiku-20240307</option> | 88 | <option data-type="anthropic" value="claude-3-haiku-20240307">claude-3-haiku-20240307</option> |
| 90 | <option data-type="google" value="gemini-2.5-pro">gemini-2.5-pro</option> | 89 | <option data-type="google" value="gemini-2.5-pro">gemini-2.5-pro</option> |
| 91 | <option data-type="google" value="gemini-2.5-pro-preview-06-05">gemini-2.5-pro-preview-06-05</option> | 90 | <option data-type="google" value="gemini-2.5-pro-preview-06-05">gemini-2.5-pro-preview-06-05</option> |
| @@ -107,11 +107,10 @@ async function sendClaudeRequest(request, response) { | |||
| 107 | const apiUrl = new URL(request.body.reverse_proxy || API_CLAUDE).toString(); | 107 | const apiUrl = new URL(request.body.reverse_proxy || API_CLAUDE).toString(); |
| 108 | const apiKey = request.body.reverse_proxy ? request.body.proxy_password : readSecret(request.user.directories, SECRET_KEYS.CLAUDE); | 108 | const apiKey = request.body.reverse_proxy ? request.body.proxy_password : readSecret(request.user.directories, SECRET_KEYS.CLAUDE); |
| 109 | const divider = '-'.repeat(process.stdout.columns); | 109 | const divider = '-'.repeat(process.stdout.columns); |
| 110 | const isClaude3or4 = /^claude-(3|opus-4|sonnet-4)/.test(request.body.model); | 110 | const enableSystemPromptCache = getConfigValue('claude.enableSystemPromptCache', false, 'boolean'); |
| 111 | const enableSystemPromptCache = getConfigValue('claude.enableSystemPromptCache', false, 'boolean') && isClaude3or4; | ||
| 112 | let cachingAtDepth = getConfigValue('claude.cachingAtDepth', -1, 'number'); | 111 | let cachingAtDepth = getConfigValue('claude.cachingAtDepth', -1, 'number'); |
| 113 | // Disabled if not an integer or negative, or if the model doesn't support it | 112 | // Disabled if not an integer or negative |
| 114 | if (!Number.isInteger(cachingAtDepth) || cachingAtDepth < 0 || !isClaude3or4) { | 113 | if (!Number.isInteger(cachingAtDepth) || cachingAtDepth < 0) { |
| 115 | cachingAtDepth = -1; | 114 | cachingAtDepth = -1; |
| 116 | } | 115 | } |
| 117 | 116 | ||
| @@ -128,7 +127,7 @@ async function sendClaudeRequest(request, response) { | |||
| 128 | }); | 127 | }); |
| 129 | const additionalHeaders = {}; | 128 | const additionalHeaders = {}; |
| 130 | const betaHeaders = ['output-128k-2025-02-19']; | 129 | const betaHeaders = ['output-128k-2025-02-19']; |
| 131 | const useTools = isClaude3or4 && Array.isArray(request.body.tools) && request.body.tools.length > 0; | 130 | const useTools = Array.isArray(request.body.tools) && request.body.tools.length > 0; |
| 132 | const useSystemPrompt = Boolean(request.body.claude_use_sysprompt); | 131 | const useSystemPrompt = Boolean(request.body.claude_use_sysprompt); |
| 133 | const convertedPrompt = convertClaudeMessages(request.body.messages, request.body.assistant_prefill, useSystemPrompt, useTools, getPromptNames(request)); | 132 | const convertedPrompt = convertClaudeMessages(request.body.messages, request.body.assistant_prefill, useSystemPrompt, useTools, getPromptNames(request)); |
| 134 | const useThinking = /^claude-(3-7|opus-4|sonnet-4)/.test(request.body.model); | 133 | const useThinking = /^claude-(3-7|opus-4|sonnet-4)/.test(request.body.model); |
| @@ -167,7 +166,7 @@ async function sendClaudeRequest(request, response) { | |||
| 167 | requestBody.tools = request.body.tools | 166 | requestBody.tools = request.body.tools |
| 168 | .filter(tool => tool.type === 'function') | 167 | .filter(tool => tool.type === 'function') |
| 169 | .map(tool => tool.function) | 168 | .map(tool => tool.function) |
| 170 | .map(fn => ({ name: fn.name, description: fn.description, input_schema: fn.parameters })); | 169 | .map(fn => ({ name: fn.name, description: fn.description, input_schema: flattenSchema(fn.parameters, request.body.chat_completion_source) })); |
| 171 | 170 | ||
| 172 | if (enableSystemPromptCache && requestBody.tools.length) { | 171 | if (enableSystemPromptCache && requestBody.tools.length) { |
| 173 | requestBody.tools[requestBody.tools.length - 1]['cache_control'] = { type: 'ephemeral', ttl: cacheTTL }; | 172 | requestBody.tools[requestBody.tools.length - 1]['cache_control'] = { type: 'ephemeral', ttl: cacheTTL }; |