This commit is contained in:
Cohee
2025-05-22 21:14:13 +03:00
parent ade45b6cd1
commit edf307aa9c
18 changed files with 15 additions and 28 deletions

View File

@ -2097,9 +2097,7 @@
</div>
<label for="claude_use_sysprompt" class="checkbox_label widthFreeExpand">
<input id="claude_use_sysprompt" type="checkbox" />
<span data-i18n="Use system prompt (Claude 2.1+ only)">
Use system prompt (Claude 2.1+ only)
</span>
<span data-i18n="Use system prompt">Use system prompt</span>
</label>
<div class="toggle-description justifyLeft marginBot5">
<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 @@
<h4 data-i18n="Claude Model">Claude Model</h4>
<select id="model_claude_select">
<optgroup label="Versions">
<option value="claude-opus-4-0">claude-opus-4-0</option>
<option value="claude-opus-4-20250514">claude-opus-4-20250514</option>
<option value="claude-sonnet-4-0">claude-sonnet-4-0</option>
<option value="claude-sonnet-4-20250514">claude-sonnet-4-20250514</option>
<option value="claude-3-7-sonnet-latest">claude-3-7-sonnet-latest</option>
<option value="claude-3-7-sonnet-20250219">claude-3-7-sonnet-20250219</option>
<option value="claude-3-5-sonnet-latest">claude-3-5-sonnet-latest</option>

View File

@ -253,7 +253,6 @@
"Assistant Prefill": "تعبئة مسبقة للمساعد",
"Start Claude's answer with...": "ابدأ إجابة كلود بـ...",
"Assistant Impersonation Prefill": "مساعد انتحال الشخصية المسبقة",
"Use system prompt (Claude 2.1+ only)": "استخدام التعليمة النظامية (فقط كلود 2.1+)",
"Send the system prompt for supported models. If disabled, the user message is added to the beginning of the prompt.": "إرسال التعليمة النظامية للنماذج المدعومة. إذا تم تعطيلها، يتم إضافة رسالة المستخدم إلى بداية التعليمة.",
"User first message": "الرسالة الأولى للمستخدم",
"Restore User first message": "استعادة الرسالة الأولى للمستخدم",

View File

@ -253,7 +253,6 @@
"Assistant Prefill": "Assistenten-Vorausfüllung",
"Start Claude's answer with...": "Beginne Claudes Antwort mit...",
"Assistant Impersonation Prefill": "Identitätswechsel des Assistenten vorab ausfüllen",
"Use system prompt (Claude 2.1+ only)": "Systemprompt verwenden (nur Claude 2.1+)",
"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.",
"User first message": "Erste Nachricht des Benutzers",
"Restore User first message": "Erste Nachricht des Benutzers wiederherstellen",

View File

@ -253,7 +253,6 @@
"Assistant Prefill": "Prellenado de Asistente",
"Start Claude's answer with...": "Iniciar la respuesta de Claude con...",
"Assistant Impersonation Prefill": "Precarga de suplantación de asistente",
"Use system prompt (Claude 2.1+ only)": "Usar indicación del sistema (solo para Claude 2.1+)",
"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.",
"User first message": "Primer mensaje del usuario",
"Restore User first message": "Restaurar el primer mensaje del usuario",

View File

@ -240,7 +240,6 @@
"Assistant Prefill": "Pré-remplissage de l'assistant",
"Start Claude's answer with...": "Commencer la réponse de Claude par...",
"Assistant Impersonation Prefill": "Pré-remplir l'usurpation d'identité de l'assistant",
"Use system prompt (Claude 2.1+ only)": "Utiliser le prompt système (uniquement Claude 2.1+)",
"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.",
"New preset": "Nouveau preset",
"Delete preset": "Supprimer le preset",
@ -2043,7 +2042,6 @@
"Trigger %": "Déclencheur %",
"Only chunk on custom boundary": "Only chunk on custom boundary",
"Generate Caption": "Générer une légende",
"Use System Prompt": "Utiliser le prompt système:",
"Settings Preset": "Preset de réglages:",
"System Prompt Name": "Nom du prompt système:",
"Instruct Mode": "Mode Instruction:",

View File

@ -253,7 +253,6 @@
"Assistant Prefill": "Fyrirfram fylla viðstoðarmanns",
"Start Claude's answer with...": "Byrjaðu svör Claude með...",
"Assistant Impersonation Prefill": "Forfylling aðstoðarmanns eftirlíkingar",
"Use system prompt (Claude 2.1+ only)": "Nota kerfisflug (einungis Claude 2.1+)",
"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.",
"User first message": "Fyrstu skilaboð notanda",
"Restore User first message": "Endurheimta fyrstu skilaboð notanda",

View File

@ -253,7 +253,6 @@
"Assistant Prefill": "Prefill assistente",
"Start Claude's answer with...": "Inizia la risposta di Claude con...",
"Assistant Impersonation Prefill": "Precompilazione imitazione assistente",
"Use system prompt (Claude 2.1+ only)": "Usa prompt di sistema (solo Claude 2.1+)",
"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.",
"User first message": "Primo messaggio dell'utente",
"Restore User first message": "Ripristina il primo messaggio dell'utente",

View File

@ -253,7 +253,6 @@
"Assistant Prefill": "アシスタントプリフィル",
"Start Claude's answer with...": "クロードの回答を...で始める",
"Assistant Impersonation Prefill": "アシスタントのなりすまし事前入力",
"Use system prompt (Claude 2.1+ only)": "システムプロンプトを使用しますクロード2.1以降のみ)",
"Send the system prompt for supported models. If disabled, the user message is added to the beginning of the prompt.": "サポートされているモデルのシステムプロンプトを送信します。無効にすると、ユーザーメッセージがプロンプトの先頭に追加されます。",
"User first message": "ユーザーの最初のメッセージ",
"Restore User first message": "ユーザーの最初のメッセージを復元する",

View File

@ -255,7 +255,6 @@
"Assistant Prefill": "어시스턴트 프리필",
"Start Claude's answer with...": "클로드의 답변 시작하기...",
"Assistant Impersonation Prefill": "어시스턴트 사칭 프리필",
"Use system prompt (Claude 2.1+ only)": "시스템 프롬프트 사용 (클로드 2.1+ 전용)",
"Send the system prompt for supported models. If disabled, the user message is added to the beginning of the prompt.": "지원되는 모델에 대한 시스템 프롬프트를 보냅니다. 비활성화된 경우 사용자 메시지가 프롬프트의 처음에 추가됩니다.",
"User first message": "사용자 첫 번째 메시지",
"Restore User first message": "사용자의 첫 번째 메시지 복원",

View File

@ -253,7 +253,6 @@
"Assistant Prefill": "Assistent Voorvullen",
"Start Claude's answer with...": "Start het antwoord van Claude met...",
"Assistant Impersonation Prefill": "Vooraf invullen van assistent-imitatie",
"Use system prompt (Claude 2.1+ only)": "Gebruik systeemprompt (alleen Claude 2.1+)",
"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.",
"User first message": "Bericht van de gebruiker eerst",
"Restore User first message": "Herstel gebruiker eerste bericht",

View File

@ -253,7 +253,6 @@
"Assistant Prefill": "Preenchimento prévio do assistente",
"Start Claude's answer with...": "Iniciar resposta de Claude com...",
"Assistant Impersonation Prefill": "Pré-preenchimento de representação do assistente",
"Use system prompt (Claude 2.1+ only)": "Usar prompt do sistema (apenas Claude 2.1+)",
"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.",
"User first message": "Primeira mensagem do usuário",
"Restore User first message": "Restaurar a primeira mensagem do usuário",

View File

@ -661,7 +661,6 @@
"Send inline images": "Отправлять inline-картинки",
"Assistant Prefill": "Префилл для ассистента",
"Start Claude's answer with...": "Начать ответ Клода с...",
"Use system prompt (Claude 2.1+ only)": "Использовать системный промпт (только Claude 2.1+)",
"Send the system prompt for supported models. If disabled, the user message is added to the beginning of the prompt.": "Отправлять системный промпт для поддерживаемых моделей. Если отключено, в начало промпта добавляется сообщение пользователя.",
"Prompts": "Промпты",
"Total Tokens:": "Всего токенов:",
@ -1236,7 +1235,6 @@
"Completion": "Completion Object",
"character_names_completion": "Только латинские буквы, цифры и знак подчёркивания. Работает не для всех бэкендов, в частности для Claude, MistralAI, Google.",
"Use AI21 Tokenizer": "Использовать токенайзер AI21",
"Use system prompt": "Использовать системный промпт",
"(Gemini 1.5 Pro/Flash only)": "(только Gemini 1.5 Pro/Flash)",
"Merges_all_system_messages_desc_1": "Объединяет все системные сообщения до первого не-системного, и отсылает их в поле",
"Merges_all_system_messages_desc_2": ".",

View File

@ -253,7 +253,6 @@
"Assistant Prefill": "Асистент автозаповнення",
"Start Claude's answer with...": "Почати відповідь Клода з...",
"Assistant Impersonation Prefill": "Попереднє заповнення уособлення помічника",
"Use system prompt (Claude 2.1+ only)": "Використовувати системний промпт (тільки Claude 2.1+)",
"Send the system prompt for supported models. If disabled, the user message is added to the beginning of the prompt.": "Надсилати системний промпт для підтримуваних моделей. Якщо відключено, повідомлення користувача додається в початок промпта.",
"User first message": "Перше повідомлення користувача",
"Restore User first message": "Відновити перше повідомлення користувача",

View File

@ -253,7 +253,6 @@
"Assistant Prefill": "Prefill trợ lý",
"Start Claude's answer with...": "Claude trả lời bắt đầu bằng...",
"Assistant Impersonation Prefill": "Prefill cho mạo danh trợ lý",
"Use system prompt (Claude 2.1+ only)": "Sử dụng prompt hệ thống (Chỉ áp dụng từ Claude 2.1+)",
"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.",
"User first message": "Tin nhắn đầu tiên của người dùng",
"Restore User first message": "Khôi phục tin nhắn đầu tiên của người dùng",

View File

@ -280,7 +280,6 @@
"Expand the editor": "展开编辑器",
"Start Claude's answer with...": "以如下内容开始Claude的回答...",
"Assistant Impersonation Prefill": "AI帮答预填",
"Use system prompt (Claude 2.1+ only)": "使用系统提示词仅适用于Claude 2.1+",
"Send the system prompt for supported models. If disabled, the user message is added to the beginning of the prompt.": "为支持的模型发送系统提示词。如果禁用,则用户消息将添加到提示词的开头。",
"Confirm token parsing with": "确认使用以下工具进行词符解析",
"Tokenizer": "词符化器",

View File

@ -254,7 +254,6 @@
"Assistant Prefill": "預先填充助理訊息",
"Start Claude's answer with...": "開始 Claude 的回答⋯",
"Assistant Impersonation Prefill": "助理扮演時的預先填充",
"Use system prompt (Claude 2.1+ only)": "使用系統提示詞(僅限 Claude 2.1+",
"Send the system prompt for supported models. If disabled, the user message is added to the beginning of the prompt.": "為支援的模型傳送系統提示詞。停用時,使用者訊息將新增到提示詞的開頭。",
"User first message": "使用者第一則訊息",
"Restore User first message": "還原使用者第一則訊息",

View File

@ -4659,7 +4659,7 @@ async function onModelChange() {
if (oai_settings.max_context_unlocked) {
$('#openai_max_context').attr('max', max_200k);
}
else if (value == 'claude-2.1' || value.startsWith('claude-3')) {
else if (value == 'claude-2.1' || value.startsWith('claude-3') || value.startsWith('claude-opus') || value.startsWith('claude-sonnet')) {
$('#openai_max_context').attr('max', max_200k);
}
else if (value.endsWith('100k') || value.startsWith('claude-2') || value === 'claude-instant-1.2') {

View File

@ -128,10 +128,11 @@ async function sendClaudeRequest(request, response) {
const apiUrl = new URL(request.body.reverse_proxy || API_CLAUDE).toString();
const apiKey = request.body.reverse_proxy ? request.body.proxy_password : readSecret(request.user.directories, SECRET_KEYS.CLAUDE);
const divider = '-'.repeat(process.stdout.columns);
const enableSystemPromptCache = getConfigValue('claude.enableSystemPromptCache', false, 'boolean') && request.body.model.startsWith('claude-3');
const isClaude3or4 = /^claude-(3|opus-4|sonnet-4)/.test(request.body.model);
const enableSystemPromptCache = getConfigValue('claude.enableSystemPromptCache', false, 'boolean') && isClaude3or4;
let cachingAtDepth = getConfigValue('claude.cachingAtDepth', -1, 'number');
// Disabled if not an integer or negative, or if the model doesn't support it
if (!Number.isInteger(cachingAtDepth) || cachingAtDepth < 0 || !request.body.model.startsWith('claude-3')) {
if (!Number.isInteger(cachingAtDepth) || cachingAtDepth < 0 || !isClaude3or4) {
cachingAtDepth = -1;
}
@ -148,11 +149,11 @@ async function sendClaudeRequest(request, response) {
});
const additionalHeaders = {};
const betaHeaders = ['output-128k-2025-02-19'];
const useTools = request.body.model.startsWith('claude-3') && Array.isArray(request.body.tools) && request.body.tools.length > 0;
const useSystemPrompt = (request.body.model.startsWith('claude-2') || request.body.model.startsWith('claude-3')) && request.body.claude_use_sysprompt;
const useTools = isClaude3or4 && Array.isArray(request.body.tools) && request.body.tools.length > 0;
const useSystemPrompt = Boolean(request.body.claude_use_sysprompt);
const convertedPrompt = convertClaudeMessages(request.body.messages, request.body.assistant_prefill, useSystemPrompt, useTools, getPromptNames(request));
const useThinking = request.body.model.startsWith('claude-3-7') && Boolean(request.body.include_reasoning);
const useWebSearch = /^claude-3-(5|7)/.test(request.body.model) && Boolean(request.body.enable_web_search);
const useThinking = /^claude-(3-7|opus-4|sonnet-4)/.test(request.body.model) && Boolean(request.body.include_reasoning);
const useWebSearch = /^claude-(3-5|3-7|opus-4|sonnet-4)/.test(request.body.model) && Boolean(request.body.enable_web_search);
let fixThinkingPrefill = false;
// Add custom stop sequences
const stopSequences = [];
@ -1292,7 +1293,8 @@ router.post('/generate', function (request, response) {
}
let cachingAtDepth = getConfigValue('claude.cachingAtDepth', -1, 'number');
if (Number.isInteger(cachingAtDepth) && cachingAtDepth >= 0 && request.body.model?.startsWith('anthropic/claude-3')) {
const isClaude3or4 = /anthropic\/claude-(3|opus-4|sonnet-4)/.test(request.body.model);
if (Number.isInteger(cachingAtDepth) && cachingAtDepth >= 0 && isClaude3or4) {
cachingAtDepthForOpenRouterClaude(request.body.messages, cachingAtDepth);
}
} else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.CUSTOM) {