claude 4
| @@ -2097,9 +2097,7 @@ | ||
| 2097 | 2097 | </div> |
| 2098 | 2098 | <label for="claude_use_sysprompt" class="checkbox_label widthFreeExpand"> |
| 2099 | 2099 | <input id="claude_use_sysprompt" type="checkbox" /> |
| 2100 | 2100 | <span data-i18n="Use system prompt (Claude">Use 2.1+system only)"prompt</span> |
| 2101 | - Use system prompt (Claude 2.1+ only) | |
| 2102 | - </span> | |
| 2103 | 2101 | </label> |
| 2104 | 2102 | <div class="toggle-description justifyLeft marginBot5"> |
| 2105 | 2103 | <span data-i18n="Send the system prompt for supported models. If disabled, the user message is added to the beginning of the prompt."> |
| @@ -2985,6 +2983,10 @@ | ||
| 2985 | 2983 | <h4 data-i18n="Claude Model">Claude Model</h4> |
| 2986 | 2984 | <select id="model_claude_select"> |
| 2987 | 2985 | <optgroup label="Versions"> |
| 2986 | + <option value="claude-opus-4-0">claude-opus-4-0</option> | |
| 2987 | + <option value="claude-opus-4-20250514">claude-opus-4-20250514</option> | |
| 2988 | + <option value="claude-sonnet-4-0">claude-sonnet-4-0</option> | |
| 2989 | + <option value="claude-sonnet-4-20250514">claude-sonnet-4-20250514</option> | |
| 2988 | 2990 | <option value="claude-3-7-sonnet-latest">claude-3-7-sonnet-latest</option> |
| 2989 | 2991 | <option value="claude-3-7-sonnet-20250219">claude-3-7-sonnet-20250219</option> |
| 2990 | 2992 | <option value="claude-3-5-sonnet-latest">claude-3-5-sonnet-latest</option> |
| @@ -253,7 +253,6 @@ | ||
| 253 | 253 | "Assistant Prefill": "تعبئة مسبقة للمساعد", |
| 254 | 254 | "Start Claude's answer with...": "ابدأ إجابة كلود بـ...", |
| 255 | 255 | "Assistant Impersonation Prefill": "مساعد انتحال الشخصية المسبقة", |
| 256 | - "Use system prompt (Claude 2.1+ only)": "استخدام التعليمة النظامية (فقط كلود 2.1+)", | |
| 257 | 256 | "Send the system prompt for supported models. If disabled, the user message is added to the beginning of the prompt.": "إرسال التعليمة النظامية للنماذج المدعومة. إذا تم تعطيلها، يتم إضافة رسالة المستخدم إلى بداية التعليمة.", |
| 258 | 257 | "User first message": "الرسالة الأولى للمستخدم", |
| 259 | 258 | "Restore User first message": "استعادة الرسالة الأولى للمستخدم", |
| @@ -253,7 +253,6 @@ | ||
| 253 | 253 | "Assistant Prefill": "Assistenten-Vorausfüllung", |
| 254 | 254 | "Start Claude's answer with...": "Beginne Claudes Antwort mit...", |
| 255 | 255 | "Assistant Impersonation Prefill": "Identitätswechsel des Assistenten vorab ausfüllen", |
| 256 | - "Use system prompt (Claude 2.1+ only)": "Systemprompt verwenden (nur Claude 2.1+)", | |
| 257 | 256 | "Send the system prompt for supported models. If disabled, the user message is added to the beginning of the prompt.": "Senden Sie die Systemaufforderung für unterstützte Modelle. Wenn deaktiviert, wird die Benutzernachricht am Anfang der Aufforderung hinzugefügt.", |
| 258 | 257 | "User first message": "Erste Nachricht des Benutzers", |
| 259 | 258 | "Restore User first message": "Erste Nachricht des Benutzers wiederherstellen", |
| @@ -253,7 +253,6 @@ | ||
| 253 | 253 | "Assistant Prefill": "Prellenado de Asistente", |
| 254 | 254 | "Start Claude's answer with...": "Iniciar la respuesta de Claude con...", |
| 255 | 255 | "Assistant Impersonation Prefill": "Precarga de suplantación de asistente", |
| 256 | - "Use system prompt (Claude 2.1+ only)": "Usar indicación del sistema (solo para Claude 2.1+)", | |
| 257 | 256 | "Send the system prompt for supported models. If disabled, the user message is added to the beginning of the prompt.": "Enviar la indicación del sistema para los modelos admitidos. Si está desactivado, el mensaje del usuario se agrega al principio de las indicaciónes.", |
| 258 | 257 | "User first message": "Primer mensaje del usuario", |
| 259 | 258 | "Restore User first message": "Restaurar el primer mensaje del usuario", |
| @@ -240,7 +240,6 @@ | ||
| 240 | 240 | "Assistant Prefill": "Pré-remplissage de l'assistant", |
| 241 | 241 | "Start Claude's answer with...": "Commencer la réponse de Claude par...", |
| 242 | 242 | "Assistant Impersonation Prefill": "Pré-remplir l'usurpation d'identité de l'assistant", |
| 243 | - "Use system prompt (Claude 2.1+ only)": "Utiliser le prompt système (uniquement Claude 2.1+)", | |
| 244 | 243 | "Send the system prompt for supported models. If disabled, the user message is added to the beginning of the prompt.": "Envoyer le prompt système pour les modèles pris en charge. Si désactivé, le message de l'utilisateur est ajouté au début du prompt.", |
| 245 | 244 | "New preset": "Nouveau preset", |
| 246 | 245 | "Delete preset": "Supprimer le preset", |
| @@ -2043,7 +2042,6 @@ | ||
| 2043 | 2042 | "Trigger %": "Déclencheur %", |
| 2044 | 2043 | "Only chunk on custom boundary": "Only chunk on custom boundary", |
| 2045 | 2044 | "Generate Caption": "Générer une légende", |
| 2046 | - "Use System Prompt": "Utiliser le prompt système:", | |
| 2047 | 2045 | "Settings Preset": "Preset de réglages:", |
| 2048 | 2046 | "System Prompt Name": "Nom du prompt système:", |
| 2049 | 2047 | "Instruct Mode": "Mode Instruction:", |
| @@ -253,7 +253,6 @@ | ||
| 253 | 253 | "Assistant Prefill": "Fyrirfram fylla viðstoðarmanns", |
| 254 | 254 | "Start Claude's answer with...": "Byrjaðu svör Claude með...", |
| 255 | 255 | "Assistant Impersonation Prefill": "Forfylling aðstoðarmanns eftirlíkingar", |
| 256 | - "Use system prompt (Claude 2.1+ only)": "Nota kerfisflug (einungis Claude 2.1+)", | |
| 257 | 256 | "Send the system prompt for supported models. If disabled, the user message is added to the beginning of the prompt.": "Senda kerfisflug fyrir styðjandi módel. Ef óvirk, er notendaskilaboð bætt við byrjun flugs.", |
| 258 | 257 | "User first message": "Fyrstu skilaboð notanda", |
| 259 | 258 | "Restore User first message": "Endurheimta fyrstu skilaboð notanda", |
| @@ -253,7 +253,6 @@ | ||
| 253 | 253 | "Assistant Prefill": "Prefill assistente", |
| 254 | 254 | "Start Claude's answer with...": "Inizia la risposta di Claude con...", |
| 255 | 255 | "Assistant Impersonation Prefill": "Precompilazione imitazione assistente", |
| 256 | - "Use system prompt (Claude 2.1+ only)": "Usa prompt di sistema (solo Claude 2.1+)", | |
| 257 | 256 | "Send the system prompt for supported models. If disabled, the user message is added to the beginning of the prompt.": "Invia il prompt di sistema per i modelli supportati. Se disabilitato, il messaggio dell'utente viene aggiunto all'inizio del prompt.", |
| 258 | 257 | "User first message": "Primo messaggio dell'utente", |
| 259 | 258 | "Restore User first message": "Ripristina il primo messaggio dell'utente", |
| @@ -253,7 +253,6 @@ | ||
| 253 | 253 | "Assistant Prefill": "アシスタントプリフィル", |
| 254 | 254 | "Start Claude's answer with...": "クロードの回答を...で始める", |
| 255 | 255 | "Assistant Impersonation Prefill": "アシスタントのなりすまし事前入力", |
| 256 | - "Use system prompt (Claude 2.1+ only)": "システムプロンプトを使用します(クロード2.1以降のみ)", | |
| 257 | 256 | "Send the system prompt for supported models. If disabled, the user message is added to the beginning of the prompt.": "サポートされているモデルのシステムプロンプトを送信します。無効にすると、ユーザーメッセージがプロンプトの先頭に追加されます。", |
| 258 | 257 | "User first message": "ユーザーの最初のメッセージ", |
| 259 | 258 | "Restore User first message": "ユーザーの最初のメッセージを復元する", |
| @@ -255,7 +255,6 @@ | ||
| 255 | 255 | "Assistant Prefill": "어시스턴트 프리필", |
| 256 | 256 | "Start Claude's answer with...": "클로드의 답변 시작하기...", |
| 257 | 257 | "Assistant Impersonation Prefill": "어시스턴트 사칭 프리필", |
| 258 | - "Use system prompt (Claude 2.1+ only)": "시스템 프롬프트 사용 (클로드 2.1+ 전용)", | |
| 259 | 258 | "Send the system prompt for supported models. If disabled, the user message is added to the beginning of the prompt.": "지원되는 모델에 대한 시스템 프롬프트를 보냅니다. 비활성화된 경우 사용자 메시지가 프롬프트의 처음에 추가됩니다.", |
| 260 | 259 | "User first message": "사용자 첫 번째 메시지", |
| 261 | 260 | "Restore User first message": "사용자의 첫 번째 메시지 복원", |
| @@ -253,7 +253,6 @@ | ||
| 253 | 253 | "Assistant Prefill": "Assistent Voorvullen", |
| 254 | 254 | "Start Claude's answer with...": "Start het antwoord van Claude met...", |
| 255 | 255 | "Assistant Impersonation Prefill": "Vooraf invullen van assistent-imitatie", |
| 256 | - "Use system prompt (Claude 2.1+ only)": "Gebruik systeemprompt (alleen Claude 2.1+)", | |
| 257 | 256 | "Send the system prompt for supported models. If disabled, the user message is added to the beginning of the prompt.": "Verzend de systeemprompt voor ondersteunde modellen. Als dit is uitgeschakeld, wordt het gebruikersbericht toegevoegd aan het begin van de prompt.", |
| 258 | 257 | "User first message": "Bericht van de gebruiker eerst", |
| 259 | 258 | "Restore User first message": "Herstel gebruiker eerste bericht", |
| @@ -253,7 +253,6 @@ | ||
| 253 | 253 | "Assistant Prefill": "Preenchimento prévio do assistente", |
| 254 | 254 | "Start Claude's answer with...": "Iniciar resposta de Claude com...", |
| 255 | 255 | "Assistant Impersonation Prefill": "Pré-preenchimento de representação do assistente", |
| 256 | - "Use system prompt (Claude 2.1+ only)": "Usar prompt do sistema (apenas Claude 2.1+)", | |
| 257 | 256 | "Send the system prompt for supported models. If disabled, the user message is added to the beginning of the prompt.": "Enviar o prompt do sistema para modelos suportados. Se desativado, a mensagem do usuário é adicionada ao início do prompt.", |
| 258 | 257 | "User first message": "Primeira mensagem do usuário", |
| 259 | 258 | "Restore User first message": "Restaurar a primeira mensagem do usuário", |
| @@ -661,7 +661,6 @@ | ||
| 661 | 661 | "Send inline images": "Отправлять inline-картинки", |
| 662 | 662 | "Assistant Prefill": "Префилл для ассистента", |
| 663 | 663 | "Start Claude's answer with...": "Начать ответ Клода с...", |
| 664 | - "Use system prompt (Claude 2.1+ only)": "Использовать системный промпт (только Claude 2.1+)", | |
| 665 | 664 | "Send the system prompt for supported models. If disabled, the user message is added to the beginning of the prompt.": "Отправлять системный промпт для поддерживаемых моделей. Если отключено, в начало промпта добавляется сообщение пользователя.", |
| 666 | 665 | "Prompts": "Промпты", |
| 667 | 666 | "Total Tokens:": "Всего токенов:", |
| @@ -1236,7 +1235,6 @@ | ||
| 1236 | 1235 | "Completion": "Completion Object", |
| 1237 | 1236 | "character_names_completion": "Только латинские буквы, цифры и знак подчёркивания. Работает не для всех бэкендов, в частности для Claude, MistralAI, Google.", |
| 1238 | 1237 | "Use AI21 Tokenizer": "Использовать токенайзер AI21", |
| 1239 | - "Use system prompt": "Использовать системный промпт", | |
| 1240 | 1238 | "(Gemini 1.5 Pro/Flash only)": "(только Gemini 1.5 Pro/Flash)", |
| 1241 | 1239 | "Merges_all_system_messages_desc_1": "Объединяет все системные сообщения до первого не-системного, и отсылает их в поле", |
| 1242 | 1240 | "Merges_all_system_messages_desc_2": ".", |
| @@ -253,7 +253,6 @@ | ||
| 253 | 253 | "Assistant Prefill": "Асистент автозаповнення", |
| 254 | 254 | "Start Claude's answer with...": "Почати відповідь Клода з...", |
| 255 | 255 | "Assistant Impersonation Prefill": "Попереднє заповнення уособлення помічника", |
| 256 | - "Use system prompt (Claude 2.1+ only)": "Використовувати системний промпт (тільки Claude 2.1+)", | |
| 257 | 256 | "Send the system prompt for supported models. If disabled, the user message is added to the beginning of the prompt.": "Надсилати системний промпт для підтримуваних моделей. Якщо відключено, повідомлення користувача додається в початок промпта.", |
| 258 | 257 | "User first message": "Перше повідомлення користувача", |
| 259 | 258 | "Restore User first message": "Відновити перше повідомлення користувача", |
| @@ -253,7 +253,6 @@ | ||
| 253 | 253 | "Assistant Prefill": "Prefill trợ lý", |
| 254 | 254 | "Start Claude's answer with...": "Claude trả lời bắt đầu bằng...", |
| 255 | 255 | "Assistant Impersonation Prefill": "Prefill cho mạo danh trợ lý", |
| 256 | - "Use system prompt (Claude 2.1+ only)": "Sử dụng prompt hệ thống (Chỉ áp dụng từ Claude 2.1+)", | |
| 257 | 256 | "Send the system prompt for supported models. If disabled, the user message is added to the beginning of the prompt.": "Gửi yêu cầu hệ thống cho các model được hỗ trợ. Nếu bị vô hiệu hóa, tin nhắn của người dùng sẽ được thêm vào đầu yêu cầu.", |
| 258 | 257 | "User first message": "Tin nhắn đầu tiên của người dùng", |
| 259 | 258 | "Restore User first message": "Khôi phục tin nhắn đầu tiên của người dùng", |
| @@ -280,7 +280,6 @@ | ||
| 280 | 280 | "Expand the editor": "展开编辑器", |
| 281 | 281 | "Start Claude's answer with...": "以如下内容开始Claude的回答...", |
| 282 | 282 | "Assistant Impersonation Prefill": "AI帮答预填", |
| 283 | - "Use system prompt (Claude 2.1+ only)": "使用系统提示词(仅适用于Claude 2.1+)", | |
| 284 | 283 | "Send the system prompt for supported models. If disabled, the user message is added to the beginning of the prompt.": "为支持的模型发送系统提示词。如果禁用,则用户消息将添加到提示词的开头。", |
| 285 | 284 | "Confirm token parsing with": "确认使用以下工具进行词符解析", |
| 286 | 285 | "Tokenizer": "词符化器", |
| @@ -254,7 +254,6 @@ | ||
| 254 | 254 | "Assistant Prefill": "預先填充助理訊息", |
| 255 | 255 | "Start Claude's answer with...": "開始 Claude 的回答⋯", |
| 256 | 256 | "Assistant Impersonation Prefill": "助理扮演時的預先填充", |
| 257 | - "Use system prompt (Claude 2.1+ only)": "使用系統提示詞(僅限 Claude 2.1+)", | |
| 258 | 257 | "Send the system prompt for supported models. If disabled, the user message is added to the beginning of the prompt.": "為支援的模型傳送系統提示詞。停用時,使用者訊息將新增到提示詞的開頭。", |
| 259 | 258 | "User first message": "使用者第一則訊息", |
| 260 | 259 | "Restore User first message": "還原使用者第一則訊息", |
| @@ -4659,7 +4659,7 @@ async function onModelChange() { | ||
| 4659 | 4659 | if (oai_settings.max_context_unlocked) { |
| 4660 | 4660 | $('#openai_max_context').attr('max', max_200k); |
| 4661 | 4661 | } |
| 4662 | 4662 | else if (value == 'claude-2.1' || value.startsWith('claude-3') || value.startsWith('claude-opus') || value.startsWith('claude-sonnet')) { |
| 4663 | 4663 | $('#openai_max_context').attr('max', max_200k); |
| 4664 | 4664 | } |
| 4665 | 4665 | else if (value.endsWith('100k') || value.startsWith('claude-2') || value === 'claude-instant-1.2') { |
| @@ -128,10 +128,11 @@ async function sendClaudeRequest(request, response) { | ||
| 128 | 128 | const apiUrl = new URL(request.body.reverse_proxy || API_CLAUDE).toString(); |
| 129 | 129 | const apiKey = request.body.reverse_proxy ? request.body.proxy_password : readSecret(request.user.directories, SECRET_KEYS.CLAUDE); |
| 130 | 130 | const divider = '-'.repeat(process.stdout.columns); |
| 131 | - const enableSystemPromptCache = getConfigValue('claude.enableSystemPromptCache', false, 'boolean') && request.body.model.startsWith('claude-3'); | |
| 131 | + const isClaude3or4 = /^claude-(3|opus-4|sonnet-4)/.test(request.body.model); | |
| 132 | + const enableSystemPromptCache = getConfigValue('claude.enableSystemPromptCache', false, 'boolean') && isClaude3or4; | |
| 132 | 133 | let cachingAtDepth = getConfigValue('claude.cachingAtDepth', -1, 'number'); |
| 133 | 134 | // Disabled if not an integer or negative, or if the model doesn't support it |
| 134 | 135 | if (!Number.isInteger(cachingAtDepth) || cachingAtDepth < 0 || !request.body.model.startsWith('claude-3')isClaude3or4) { |
| 135 | 136 | cachingAtDepth = -1; |
| 136 | 137 | } |
| 137 | 138 | |
| @@ -148,11 +149,11 @@ async function sendClaudeRequest(request, response) { | ||
| 148 | 149 | }); |
| 149 | 150 | const additionalHeaders = {}; |
| 150 | 151 | const betaHeaders = ['output-128k-2025-02-19']; |
| 151 | 152 | const useTools = request.body.model.startsWith('claude-3')isClaude3or4 && Array.isArray(request.body.tools) && request.body.tools.length > 0; |
| 152 | - const useSystemPrompt = (request.body.model.startsWith('claude-2') || request.body.model.startsWith('claude-3')) && request.body.claude_use_sysprompt; | |
| 153 | + const useSystemPrompt = Boolean(request.body.claude_use_sysprompt); | |
| 153 | 154 | const convertedPrompt = convertClaudeMessages(request.body.messages, request.body.assistant_prefill, useSystemPrompt, useTools, getPromptNames(request)); |
| 154 | 155 | const useThinking = request.body.model.startsWith('/^claude-(3-7'|opus-4|sonnet-4)/.test(request.body.model) && Boolean(request.body.include_reasoning); |
| 155 | 156 | const useWebSearch = /^claude-(3-(5|3-7|opus-4|sonnet-4)/.test(request.body.model) && Boolean(request.body.enable_web_search); |
| 156 | 157 | let fixThinkingPrefill = false; |
| 157 | 158 | // Add custom stop sequences |
| 158 | 159 | const stopSequences = []; |
| @@ -1292,7 +1293,8 @@ router.post('/generate', function (request, response) { | ||
| 1292 | 1293 | } |
| 1293 | 1294 | |
| 1294 | 1295 | let cachingAtDepth = getConfigValue('claude.cachingAtDepth', -1, 'number'); |
| 1295 | - if (Number.isInteger(cachingAtDepth) && cachingAtDepth >= 0 && request.body.model?.startsWith('anthropic/claude-3')) { | |
| 1296 | + const isClaude3or4 = /anthropic\/claude-(3|opus-4|sonnet-4)/.test(request.body.model); | |
| 1297 | + if (Number.isInteger(cachingAtDepth) && cachingAtDepth >= 0 && isClaude3or4) { | |
| 1296 | 1298 | cachingAtDepthForOpenRouterClaude(request.body.messages, cachingAtDepth); |
| 1297 | 1299 | } |
| 1298 | 1300 | } else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.CUSTOM) { |