Merge pull request #2987 from SillyTavern/remove-legacy-api TextGenWebUI: remove legacy API mode

b6af986e582f9e635e904d7e49431afd18f7cd44

Cohee <18619528+Cohee1207@users.noreply.github.com>

Signed
22 files changed, +86 -172Ignore whitespace
public/index.html+0 -4
@@ -2573,10 +2573,6 @@
2573 <div data-tg-type="openrouter" class="menu_button menu_button_icon openrouter_authorize" title="Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai" data-i18n="Authorize;[title]Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai">Authorize</div>2573 <div data-tg-type="openrouter" class="menu_button menu_button_icon openrouter_authorize" title="Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai" data-i18n="Authorize;[title]Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai">Authorize</div>
2574 <div class="api_loading menu_button menu_button_icon" data-i18n="Cancel">Cancel</div>2574 <div class="api_loading menu_button menu_button_icon" data-i18n="Cancel">Cancel</div>
2575 </div>2575 </div>
2576 <label data-tg-type="ooba" class="checkbox_label margin-bot-10px" for="legacy_api_textgenerationwebui">
2577 <input type="checkbox" id="legacy_api_textgenerationwebui" />
2578 <span data-i18n="Legacy API (pre-OAI, no streaming)">Legacy API (pre-OAI, no streaming)</span>
2579 </label>
2580 <label data-tg-type="ooba" class="checkbox_label margin-bot-10px" for="bypass_status_check_textgenerationwebui">2576 <label data-tg-type="ooba" class="checkbox_label margin-bot-10px" for="bypass_status_check_textgenerationwebui">
2581 <input type="checkbox" id="bypass_status_check_textgenerationwebui" />2577 <input type="checkbox" id="bypass_status_check_textgenerationwebui" />
2582 <span data-i18n="Bypass status check">Bypass status check</span>2578 <span data-i18n="Bypass status check">Bypass status check</span>
public/locales/ar-sa.json+0 -1
@@ -337,7 +337,6 @@
337 "Example: 127.0.0.1:5001": "مثال: 127.0.0.1:5001",337 "Example: 127.0.0.1:5001": "مثال: 127.0.0.1:5001",
338 "Authorize": "تفويض",338 "Authorize": "تفويض",
339 "Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "احصل على رمز واجهة برمجة التطبيقات الخاص بك لموزع الاتصالات باستخدام تدفق OAuth. سيتم توجيهك إلى openrouter.ai",339 "Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "احصل على رمز واجهة برمجة التطبيقات الخاص بك لموزع الاتصالات باستخدام تدفق OAuth. سيتم توجيهك إلى openrouter.ai",
340 "Legacy API (pre-OAI, no streaming)": "واجهة برمجة التطبيقات القديمة (قبل OAI، بدون بث)",
341 "Bypass status check": "تجاوز فحص الحالة",340 "Bypass status check": "تجاوز فحص الحالة",
342 "Chat Completion Source": "مصدر استكمال الدردشة",341 "Chat Completion Source": "مصدر استكمال الدردشة",
343 "Reverse Proxy": "الوكيل العكسي",342 "Reverse Proxy": "الوكيل العكسي",
public/locales/de-de.json+0 -1
@@ -337,7 +337,6 @@
337 "Example: 127.0.0.1:5001": "Beispiel: 127.0.0.1:5001",337 "Example: 127.0.0.1:5001": "Beispiel: 127.0.0.1:5001",
338 "Authorize": "Autorisieren",338 "Authorize": "Autorisieren",
339 "Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "Hole dein OpenRouter-API-Token mit OAuth-Fluss. Du wirst zu openrouter.ai weitergeleitet",339 "Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "Hole dein OpenRouter-API-Token mit OAuth-Fluss. Du wirst zu openrouter.ai weitergeleitet",
340 "Legacy API (pre-OAI, no streaming)": "Legacy-API (vor OAI, kein Streaming)",
341 "Bypass status check": "Umgehe Statusüberprüfung",340 "Bypass status check": "Umgehe Statusüberprüfung",
342 "Chat Completion Source": "Quelle für Chat-Vervollständigung",341 "Chat Completion Source": "Quelle für Chat-Vervollständigung",
343 "Reverse Proxy": "Reverse-Proxy",342 "Reverse Proxy": "Reverse-Proxy",
public/locales/es-es.json+0 -1
@@ -337,7 +337,6 @@
337 "Example: 127.0.0.1:5001": "Ejemplo: 127.0.0.1:5001",337 "Example: 127.0.0.1:5001": "Ejemplo: 127.0.0.1:5001",
338 "Authorize": "Autorizar",338 "Authorize": "Autorizar",
339 "Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "Obtenga su token de API de OpenRouter utilizando el flujo OAuth. Será redirigido a openrouter.ai",339 "Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "Obtenga su token de API de OpenRouter utilizando el flujo OAuth. Será redirigido a openrouter.ai",
340 "Legacy API (pre-OAI, no streaming)": "API heredada (pre-OAI, sin streaming)",
341 "Bypass status check": "Saltar la verificación del estado",340 "Bypass status check": "Saltar la verificación del estado",
342 "Chat Completion Source": "Fuente de Completado de Chat",341 "Chat Completion Source": "Fuente de Completado de Chat",
343 "Reverse Proxy": "Proxy inverso",342 "Reverse Proxy": "Proxy inverso",
public/locales/fr-fr.json+0 -1
@@ -337,7 +337,6 @@
337 "Example: 127.0.0.1:5001": "Exemple : 127.0.0.1:5001",337 "Example: 127.0.0.1:5001": "Exemple : 127.0.0.1:5001",
338 "Authorize": "Autoriser",338 "Authorize": "Autoriser",
339 "Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "Obtenez votre jeton API OpenRouter en utilisant le flux OAuth. Vous serez redirigé vers openrouter.ai",339 "Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "Obtenez votre jeton API OpenRouter en utilisant le flux OAuth. Vous serez redirigé vers openrouter.ai",
340 "Legacy API (pre-OAI, no streaming)": "API héritée (pré-OAI, pas de streaming)",
341 "Bypass status check": "Contourner la vérification de l'état",340 "Bypass status check": "Contourner la vérification de l'état",
342 "Chat Completion Source": "Source de complétion de la conversation",341 "Chat Completion Source": "Source de complétion de la conversation",
343 "Reverse Proxy": "Proxy inverse",342 "Reverse Proxy": "Proxy inverse",
public/locales/is-is.json+0 -1
@@ -337,7 +337,6 @@
337 "Example: 127.0.0.1:5001": "Dæmi: 127.0.0.1:5001",337 "Example: 127.0.0.1:5001": "Dæmi: 127.0.0.1:5001",
338 "Authorize": "Heimild",338 "Authorize": "Heimild",
339 "Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "Fáðu API lykilinn þinn fyrir OpenRouter með því að nota OAuth strauminn. Þú verður endurvísað(ð/ur) á openrouter.ai",339 "Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "Fáðu API lykilinn þinn fyrir OpenRouter með því að nota OAuth strauminn. Þú verður endurvísað(ð/ur) á openrouter.ai",
340 "Legacy API (pre-OAI, no streaming)": "Eldri API (fyrir OAI, engin flæði)",
341 "Bypass status check": "Hlaupa framhjá stöðutík",340 "Bypass status check": "Hlaupa framhjá stöðutík",
342 "Chat Completion Source": "Heimild að fullvirkni spjalls",341 "Chat Completion Source": "Heimild að fullvirkni spjalls",
343 "Reverse Proxy": "Reverse proxy",342 "Reverse Proxy": "Reverse proxy",
public/locales/it-it.json+0 -1
@@ -337,7 +337,6 @@
337 "Example: 127.0.0.1:5001": "Esempio: 127.0.0.1:5001",337 "Example: 127.0.0.1:5001": "Esempio: 127.0.0.1:5001",
338 "Authorize": "Autorizzare",338 "Authorize": "Autorizzare",
339 "Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "Ottieni il tuo token API di OpenRouter utilizzando il flusso OAuth. Sarai reindirizzato su openrouter.ai",339 "Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "Ottieni il tuo token API di OpenRouter utilizzando il flusso OAuth. Sarai reindirizzato su openrouter.ai",
340 "Legacy API (pre-OAI, no streaming)": "API legacy (prima di OAI, senza streaming)",
341 "Bypass status check": "Ignora controllo stato",340 "Bypass status check": "Ignora controllo stato",
342 "Chat Completion Source": "Fonte di Completamento della Chat",341 "Chat Completion Source": "Fonte di Completamento della Chat",
343 "Reverse Proxy": "Proxy inverso",342 "Reverse Proxy": "Proxy inverso",
public/locales/ja-jp.json+0 -1
@@ -337,7 +337,6 @@
337 "Example: 127.0.0.1:5001": "例: 127.0.0.1:5001",337 "Example: 127.0.0.1:5001": "例: 127.0.0.1:5001",
338 "Authorize": "承認",338 "Authorize": "承認",
339 "Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "OAuthフローを使用してOpenRouter APIトークンを取得します。 openrouter.aiにリダイレクトされます",339 "Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "OAuthフローを使用してOpenRouter APIトークンを取得します。 openrouter.aiにリダイレクトされます",
340 "Legacy API (pre-OAI, no streaming)": "レガシーAPI(OAI以前のもの、ストリーミングなし)",
341 "Bypass status check": "ステータスのチェックをバイパスする",340 "Bypass status check": "ステータスのチェックをバイパスする",
342 "Chat Completion Source": "チャット補完ソース",341 "Chat Completion Source": "チャット補完ソース",
343 "Reverse Proxy": "リバースプロキシ",342 "Reverse Proxy": "リバースプロキシ",
public/locales/ko-kr.json+0 -1
@@ -337,7 +337,6 @@
337 "Example: 127.0.0.1:5001": "예: 127.0.0.1:5001",337 "Example: 127.0.0.1:5001": "예: 127.0.0.1:5001",
338 "Authorize": "승인하다",338 "Authorize": "승인하다",
339 "Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "OAuth 플로우를 사용하여 OpenRouter API 토큰을 가져옵니다. openrouter.ai로 리디렉션됩니다.",339 "Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "OAuth 플로우를 사용하여 OpenRouter API 토큰을 가져옵니다. openrouter.ai로 리디렉션됩니다.",
340 "Legacy API (pre-OAI, no streaming)": "레거시 API (OAI 이전, 스트리밍 없음)",
341 "Bypass status check": "상태 확인 우회",340 "Bypass status check": "상태 확인 우회",
342 "Chat Completion Source": "채팅 완성 소스",341 "Chat Completion Source": "채팅 완성 소스",
343 "Reverse Proxy": "역방향 프록시",342 "Reverse Proxy": "역방향 프록시",
public/locales/nl-nl.json+0 -1
@@ -337,7 +337,6 @@
337 "Example: 127.0.0.1:5001": "Voorbeeld: 127.0.0.1:5001",337 "Example: 127.0.0.1:5001": "Voorbeeld: 127.0.0.1:5001",
338 "Authorize": "Toestemming geven",338 "Authorize": "Toestemming geven",
339 "Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "Haal uw OpenRouter API-token op met behulp van OAuth-flow. U wordt doorgestuurd naar openrouter.ai",339 "Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "Haal uw OpenRouter API-token op met behulp van OAuth-flow. U wordt doorgestuurd naar openrouter.ai",
340 "Legacy API (pre-OAI, no streaming)": "Legacy API (vóór OAI, geen streaming)",
341 "Bypass status check": "Omzeil statuscontrole",340 "Bypass status check": "Omzeil statuscontrole",
342 "Chat Completion Source": "Bron voor Chatvoltooiing",341 "Chat Completion Source": "Bron voor Chatvoltooiing",
343 "Reverse Proxy": "Omgekeerde proxy",342 "Reverse Proxy": "Omgekeerde proxy",
public/locales/pt-pt.json+0 -1
@@ -337,7 +337,6 @@
337 "Example: 127.0.0.1:5001": "Exemplo: 127.0.0.1:5001",337 "Example: 127.0.0.1:5001": "Exemplo: 127.0.0.1:5001",
338 "Authorize": "Autorizar",338 "Authorize": "Autorizar",
339 "Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "Obtenha seu token da API do OpenRouter usando o fluxo OAuth. Você será redirecionado para openrouter.ai",339 "Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "Obtenha seu token da API do OpenRouter usando o fluxo OAuth. Você será redirecionado para openrouter.ai",
340 "Legacy API (pre-OAI, no streaming)": "API legada (pré-OAI, sem streaming)",
341 "Bypass status check": "Ignorar verificação de status",340 "Bypass status check": "Ignorar verificação de status",
342 "Chat Completion Source": "Fonte de conclusão de chat",341 "Chat Completion Source": "Fonte de conclusão de chat",
343 "Reverse Proxy": "Proxy reverso",342 "Reverse Proxy": "Proxy reverso",
public/locales/ru-ru.json+0 -2
@@ -137,7 +137,6 @@
137 "Custom model (optional)": "Пользовательская модель (необязательно)",137 "Custom model (optional)": "Пользовательская модель (необязательно)",
138 "Bypass API status check": "Обход проверки статуса API",138 "Bypass API status check": "Обход проверки статуса API",
139 "Example: 127.0.0.1:5000": "Пример: http://127.0.0.1:5000",139 "Example: 127.0.0.1:5000": "Пример: http://127.0.0.1:5000",
140 "Legacy API (pre-OAI, no streaming)": "Устаревший API (до OAI, без стриминга)",
141 "Bypass status check": "Обход проверки статуса",140 "Bypass status check": "Обход проверки статуса",
142 "Mancer API key": "Ключ от Mancer API",141 "Mancer API key": "Ключ от Mancer API",
143 "to get your OpenAI API key.": "для получения ключа от API OpenAI",142 "to get your OpenAI API key.": "для получения ключа от API OpenAI",
@@ -1808,7 +1807,6 @@
1808 "Your chat is still saving...": "Чат всё ещё сохраняется...",1807 "Your chat is still saving...": "Чат всё ещё сохраняется...",
1809 "Character ${0} not found in the list": "Персонаж ${0} не найден в списке",1808 "Character ${0} not found in the list": "Персонаж ${0} не найден в списке",
1810 "Streaming is enabled, but the version of Kobold used does not support token streaming.": "Включён стриминг текста, но ваша версия Kobold не поддерживает стриминг токенов.",1809 "Streaming is enabled, but the version of Kobold used does not support token streaming.": "Включён стриминг текста, но ваша версия Kobold не поддерживает стриминг токенов.",
1811 "Streaming is not supported for the Legacy API. Update Ooba and use new API to enable streaming.": "Для устаревшего API стриминг недоступен. Обновите oobaboga и используйте новый API, чтобы включить стриминг.",
1812 "Verify that the server is running and accessible.": "Убедитесь, что сервер запущен и доступен по сети.",1810 "Verify that the server is running and accessible.": "Убедитесь, что сервер запущен и доступен по сети.",
1813 "ST Server cannot be reached": "Не удалось соединиться с сервером ST",1811 "ST Server cannot be reached": "Не удалось соединиться с сервером ST",
1814 "You must first select a character to duplicate!": "Вы не выбрали персонажа, которого хотите клонировать!",1812 "You must first select a character to duplicate!": "Вы не выбрали персонажа, которого хотите клонировать!",
public/locales/uk-ua.json+0 -1
@@ -337,7 +337,6 @@
337 "Example: 127.0.0.1:5001": "Приклад: 127.0.0.1:5001",337 "Example: 127.0.0.1:5001": "Приклад: 127.0.0.1:5001",
338 "Authorize": "Авторизувати",338 "Authorize": "Авторизувати",
339 "Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "Отримайте свій токен API OpenRouter за допомогою OAuth. Вас буде перенаправлено на openrouter.ai",339 "Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "Отримайте свій токен API OpenRouter за допомогою OAuth. Вас буде перенаправлено на openrouter.ai",
340 "Legacy API (pre-OAI, no streaming)": "Застарілий API (до OAI, без потокової передачі)",
341 "Bypass status check": "Обійти перевірку статусу",340 "Bypass status check": "Обійти перевірку статусу",
342 "Chat Completion Source": "Джерело Chat Completion",341 "Chat Completion Source": "Джерело Chat Completion",
343 "Reverse Proxy": "Зворотний проксі",342 "Reverse Proxy": "Зворотний проксі",
public/locales/vi-vn.json+0 -1
@@ -337,7 +337,6 @@
337 "Example: 127.0.0.1:5001": "Ví dụ: 127.0.0.1:5001",337 "Example: 127.0.0.1:5001": "Ví dụ: 127.0.0.1:5001",
338 "Cho phép": "Ủy quyền",338 "Cho phép": "Ủy quyền",
339 "Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "Nhận mã thông báo API OpenRouter của bạn bằng cách sử dụng luồng OAuth. Bạn sẽ được chuyển hướng đến openrouter.ai",339 "Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "Nhận mã thông báo API OpenRouter của bạn bằng cách sử dụng luồng OAuth. Bạn sẽ được chuyển hướng đến openrouter.ai",
340 "Legacy API (pre-OAI, no streaming)": "API cũ (trước OAI, không có streaming)",
341 "Bypass status check": "Bỏ qua check trạng thái",340 "Bypass status check": "Bỏ qua check trạng thái",
342 "Chat Completion Source": "Nguồn cho Chat Completion",341 "Chat Completion Source": "Nguồn cho Chat Completion",
343 "Reverse Proxy": "Proxy",342 "Reverse Proxy": "Proxy",
public/locales/zh-cn.json+0 -1
@@ -351,7 +351,6 @@
351 "Example: 127.0.0.1:5001": "示例:127.0.0.1:5001",351 "Example: 127.0.0.1:5001": "示例:127.0.0.1:5001",
352 "Authorize": "授权",352 "Authorize": "授权",
353 "Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "使用OAuth流程获取您的OpenRouter API令牌。您将被重定向到openrouter.ai",353 "Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "使用OAuth流程获取您的OpenRouter API令牌。您将被重定向到openrouter.ai",
354 "Legacy API (pre-OAI, no streaming)": "旧版API(OAI之前,无流式传输)",
355 "Bypass status check": "绕过状态检查",354 "Bypass status check": "绕过状态检查",
356 "Chat Completion Source": "聊天补全来源",355 "Chat Completion Source": "聊天补全来源",
357 "Custom (OpenAI-compatible)": "自定义(兼容 OpenAI)",356 "Custom (OpenAI-compatible)": "自定义(兼容 OpenAI)",
public/locales/zh-tw.json+0 -1
@@ -338,7 +338,6 @@
338 "Example: 127.0.0.1:5001": "範例:127.0.0.1:5001",338 "Example: 127.0.0.1:5001": "範例:127.0.0.1:5001",
339 "Authorize": "授權",339 "Authorize": "授權",
340 "Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "使用 OAuth 流程取得您的 OpenRouter API 符記。您將被重新導向到 openrouter.ai",340 "Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "使用 OAuth 流程取得您的 OpenRouter API 符記。您將被重新導向到 openrouter.ai",
341 "Legacy API (pre-OAI, no streaming)": "傳統 API(OAI之前,無串流)",
342 "Bypass status check": "繞過狀態檢查",341 "Bypass status check": "繞過狀態檢查",
343 "Chat Completion Source": "聊天補充來源",342 "Chat Completion Source": "聊天補充來源",
344 "Reverse Proxy": "反向代理伺服器",343 "Reverse Proxy": "反向代理伺服器",
public/script.js+0 -10
@@ -1184,7 +1184,6 @@ async function getStatusTextgen() {
1184 body: JSON.stringify({1184 body: JSON.stringify({
1185 api_server: endpoint,1185 api_server: endpoint,
1186 api_type: textgen_settings.type,1186 api_type: textgen_settings.type,
1187 legacy_api: textgen_settings.legacy_api && textgen_settings.type === OOBA,
1188 }),1187 }),
1189 signal: abortStatusCheck.signal,1188 signal: abortStatusCheck.signal,
1190 });1189 });
@@ -3447,15 +3446,6 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
3447 return Promise.resolve();3446 return Promise.resolve();
3448 }3447 }
34493448
3450 if (main_api === 'textgenerationwebui' &&
3451 textgen_settings.streaming &&
3452 textgen_settings.legacy_api &&
3453 textgen_settings.type === OOBA) {
3454 toastr.error(t`Streaming is not supported for the Legacy API. Update Ooba and use new API to enable streaming.`, undefined, { timeOut: 10000, preventDuplicates: true });
3455 unblockGeneration(type);
3456 return Promise.resolve();
3457 }
3458
3459 if (isHordeGenerationNotAllowed()) {3449 if (isHordeGenerationNotAllowed()) {
3460 unblockGeneration(type);3450 unblockGeneration(type);
3461 return Promise.resolve();3451 return Promise.resolve();
public/scripts/power-user.js+0 -17
@@ -303,9 +303,6 @@ let movingUIPresets = [];
303export let context_presets = [];303export let context_presets = [];
304304
305const storage_keys = {305const storage_keys = {
306 auto_connect_legacy: 'AutoConnectEnabled',
307 auto_load_chat_legacy: 'AutoLoadChatEnabled',
308
309 storyStringValidationCache: 'StoryStringValidationCache',306 storyStringValidationCache: 'StoryStringValidationCache',
310};307};
311308
@@ -1429,20 +1426,6 @@ async function loadPowerUserSettings(settings, data) {
1429 context_presets = data.context;1426 context_presets = data.context;
1430 }1427 }
14311428
1432 // These are still local storage. Delete in 1.12.7
1433 const autoLoadChat = localStorage.getItem(storage_keys.auto_load_chat_legacy);
1434 const autoConnect = localStorage.getItem(storage_keys.auto_connect_legacy);
1435
1436 if (autoLoadChat) {
1437 power_user.auto_load_chat = autoLoadChat === 'true';
1438 localStorage.removeItem(storage_keys.auto_load_chat_legacy);
1439 }
1440
1441 if (autoConnect) {
1442 power_user.auto_connect = autoConnect === 'true';
1443 localStorage.removeItem(storage_keys.auto_connect_legacy);
1444 }
1445
1446 if (power_user.chat_display === '') {1429 if (power_user.chat_display === '') {
1447 power_user.chat_display = chat_styles.DEFAULT;1430 power_user.chat_display = chat_styles.DEFAULT;
1448 }1431 }
public/scripts/textgen-settings.js+0 -14
@@ -183,7 +183,6 @@ const settings = {
183 aphrodite_model: '',183 aphrodite_model: '',
184 dreamgen_model: 'opus-v1-xl/text',184 dreamgen_model: 'opus-v1-xl/text',
185 tabby_model: '',185 tabby_model: '',
186 legacy_api: false,
187 sampler_order: KOBOLDCPP_ORDER,186 sampler_order: KOBOLDCPP_ORDER,
188 logit_bias: [],187 logit_bias: [],
189 n: 1,188 n: 1,
@@ -252,7 +251,6 @@ export const setting_names = [
252 'grammar_string',251 'grammar_string',
253 'json_schema',252 'json_schema',
254 'banned_tokens',253 'banned_tokens',
255 'legacy_api',
256 'ignore_eos_token',254 'ignore_eos_token',
257 'spaces_between_special_tokens',255 'spaces_between_special_tokens',
258 'speculative_ngram',256 'speculative_ngram',
@@ -329,22 +327,11 @@ async function selectPreset(name) {
329function formatTextGenURL(value) {327function formatTextGenURL(value) {
330 try {328 try {
331 const noFormatTypes = [MANCER, TOGETHERAI, INFERMATICAI, DREAMGEN, OPENROUTER];329 const noFormatTypes = [MANCER, TOGETHERAI, INFERMATICAI, DREAMGEN, OPENROUTER];
332 const legacyApiTypes = [OOBA];
333 if (noFormatTypes.includes(settings.type)) {330 if (noFormatTypes.includes(settings.type)) {
334 return value;331 return value;
335 }332 }
336333
337 const url = new URL(value);334 const url = new URL(value);
338 if (legacyApiTypes.includes(settings.type)) {
339 if (url.pathname === '/api' && !settings.legacy_api) {
340 toastr.info('Enable Legacy API or start Ooba with the OpenAI extension enabled.', 'Legacy API URL detected. Generation may fail.', { preventDuplicates: true, timeOut: 10000, extendedTimeOut: 20000 });
341 url.pathname = '';
342 }
343
344 if (!power_user.relaxed_api_urls && settings.legacy_api) {
345 url.pathname = '/api';
346 }
347 }
348 return url.toString();335 return url.toString();
349 } catch {336 } catch {
350 // Just using URL as a validation check337 // Just using URL as a validation check
@@ -1185,7 +1172,6 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate,
1185 'banned_strings': banned_strings,1172 'banned_strings': banned_strings,
1186 'api_type': settings.type,1173 'api_type': settings.type,
1187 'api_server': getTextGenServer(),1174 'api_server': getTextGenServer(),
1188 'legacy_api': settings.legacy_api && settings.type === OOBA,
1189 'sampler_order': settings.type === textgen_types.KOBOLDCPP ? settings.sampler_order : undefined,1175 'sampler_order': settings.type === textgen_types.KOBOLDCPP ? settings.sampler_order : undefined,
1190 'xtc_threshold': settings.xtc_threshold,1176 'xtc_threshold': settings.xtc_threshold,
1191 'xtc_probability': settings.xtc_probability,1177 'xtc_probability': settings.xtc_probability,
public/scripts/tokenizers.js+0 -1
@@ -889,7 +889,6 @@ function getTextgenAPITokenizationParams(str) {
889 text: str,889 text: str,
890 api_type: textgen_settings.type,890 api_type: textgen_settings.type,
891 url: getTextGenServer(),891 url: getTextGenServer(),
892 legacy_api: textgen_settings.legacy_api && textgen_settings.type === OOBA,
893 vllm_model: textgen_settings.vllm_model,892 vllm_model: textgen_settings.vllm_model,
894 aphrodite_model: textgen_settings.aphrodite_model,893 aphrodite_model: textgen_settings.aphrodite_model,
895 };894 };
src/endpoints/backends/text-completions.js+59 -77
@@ -112,41 +112,38 @@ router.post('/status', jsonParser, async function (request, response) {
112 let url = baseUrl;112 let url = baseUrl;
113 let result = '';113 let result = '';
114114
115 if (request.body.legacy_api) {115
116 url += '/v1/model';116 switch (apiType) {
117 } else {117 case TEXTGEN_TYPES.OOBA:
118 switch (apiType) {118 case TEXTGEN_TYPES.VLLM:
119 case TEXTGEN_TYPES.OOBA:119 case TEXTGEN_TYPES.APHRODITE:
120 case TEXTGEN_TYPES.VLLM:120 case TEXTGEN_TYPES.KOBOLDCPP:
121 case TEXTGEN_TYPES.APHRODITE:121 case TEXTGEN_TYPES.LLAMACPP:
122 case TEXTGEN_TYPES.KOBOLDCPP:122 case TEXTGEN_TYPES.INFERMATICAI:
123 case TEXTGEN_TYPES.LLAMACPP:123 case TEXTGEN_TYPES.OPENROUTER:
124 case TEXTGEN_TYPES.INFERMATICAI:124 url += '/v1/models';
125 case TEXTGEN_TYPES.OPENROUTER:125 break;
126 url += '/v1/models';126 case TEXTGEN_TYPES.DREAMGEN:
127 break;127 url += '/api/openai/v1/models';
128 case TEXTGEN_TYPES.DREAMGEN:128 break;
129 url += '/api/openai/v1/models';129 case TEXTGEN_TYPES.MANCER:
130 break;130 url += '/oai/v1/models';
131 case TEXTGEN_TYPES.MANCER:131 break;
132 url += '/oai/v1/models';132 case TEXTGEN_TYPES.TABBY:
133 break;133 url += '/v1/model/list';
134 case TEXTGEN_TYPES.TABBY:134 break;
135 url += '/v1/model/list';135 case TEXTGEN_TYPES.TOGETHERAI:
136 break;136 url += '/api/models?&info';
137 case TEXTGEN_TYPES.TOGETHERAI:137 break;
138 url += '/api/models?&info';138 case TEXTGEN_TYPES.OLLAMA:
139 break;139 url += '/api/tags';
140 case TEXTGEN_TYPES.OLLAMA:140 break;
141 url += '/api/tags';141 case TEXTGEN_TYPES.FEATHERLESS:
142 break;142 url += '/v1/models';
143 case TEXTGEN_TYPES.FEATHERLESS:143 break;
144 url += '/v1/models';144 case TEXTGEN_TYPES.HUGGINGFACE:
145 break;145 url += '/info';
146 case TEXTGEN_TYPES.HUGGINGFACE:146 break;
147 url += '/info';
148 break;
149 }
150 }147 }
151148
152 const modelsReply = await fetch(url, args);149 const modelsReply = await fetch(url, args);
@@ -160,11 +157,6 @@ router.post('/status', jsonParser, async function (request, response) {
160 /** @type {any} */157 /** @type {any} */
161 let data = await modelsReply.json();158 let data = await modelsReply.json();
162159
163 if (request.body.legacy_api) {
164 console.log('Legacy API response:', data);
165 return response.send({ result: data?.result });
166 }
167
168 // Rewrap to OAI-like response160 // Rewrap to OAI-like response
169 if (apiType === TEXTGEN_TYPES.TOGETHERAI && Array.isArray(data)) {161 if (apiType === TEXTGEN_TYPES.TOGETHERAI && Array.isArray(data)) {
170 data = { data: data.map(x => ({ id: x.name, ...x })) };162 data = { data: data.map(x => ({ id: x.name, ...x })) };
@@ -259,37 +251,33 @@ router.post('/generate', jsonParser, async function (request, response) {
259251
260 let url = trimV1(baseUrl);252 let url = trimV1(baseUrl);
261253
262 if (request.body.legacy_api) {254 switch (request.body.api_type) {
263 url += '/v1/generate';255 case TEXTGEN_TYPES.VLLM:
264 } else {256 case TEXTGEN_TYPES.FEATHERLESS:
265 switch (request.body.api_type) {257 case TEXTGEN_TYPES.APHRODITE:
266 case TEXTGEN_TYPES.VLLM:258 case TEXTGEN_TYPES.OOBA:
267 case TEXTGEN_TYPES.FEATHERLESS:259 case TEXTGEN_TYPES.TABBY:
268 case TEXTGEN_TYPES.APHRODITE:260 case TEXTGEN_TYPES.KOBOLDCPP:
269 case TEXTGEN_TYPES.OOBA:261 case TEXTGEN_TYPES.TOGETHERAI:
270 case TEXTGEN_TYPES.TABBY:262 case TEXTGEN_TYPES.INFERMATICAI:
271 case TEXTGEN_TYPES.KOBOLDCPP:263 case TEXTGEN_TYPES.HUGGINGFACE:
272 case TEXTGEN_TYPES.TOGETHERAI:264 url += '/v1/completions';
273 case TEXTGEN_TYPES.INFERMATICAI:265 break;
274 case TEXTGEN_TYPES.HUGGINGFACE:266 case TEXTGEN_TYPES.DREAMGEN:
275 url += '/v1/completions';267 url += '/api/openai/v1/completions';
276 break;268 break;
277 case TEXTGEN_TYPES.DREAMGEN:269 case TEXTGEN_TYPES.MANCER:
278 url += '/api/openai/v1/completions';270 url += '/oai/v1/completions';
279 break;271 break;
280 case TEXTGEN_TYPES.MANCER:272 case TEXTGEN_TYPES.LLAMACPP:
281 url += '/oai/v1/completions';273 url += '/completion';
282 break;274 break;
283 case TEXTGEN_TYPES.LLAMACPP:275 case TEXTGEN_TYPES.OLLAMA:
284 url += '/completion';276 url += '/api/generate';
285 break;277 break;
286 case TEXTGEN_TYPES.OLLAMA:278 case TEXTGEN_TYPES.OPENROUTER:
287 url += '/api/generate';279 url += '/v1/chat/completions';
288 break;280 break;
289 case TEXTGEN_TYPES.OPENROUTER:
290 url += '/v1/chat/completions';
291 break;
292 }
293 }281 }
294282
295 const args = {283 const args = {
@@ -370,12 +358,6 @@ router.post('/generate', jsonParser, async function (request, response) {
370 const data = await completionsReply.json();358 const data = await completionsReply.json();
371 console.log('Endpoint response:', data);359 console.log('Endpoint response:', data);
372360
373 // Wrap legacy response to OAI completions format
374 if (request.body.legacy_api) {
375 const text = data?.results[0]?.text;
376 data['choices'] = [{ text }];
377 }
378
379 // Map InfermaticAI response to OAI completions format361 // Map InfermaticAI response to OAI completions format
380 if (apiType === TEXTGEN_TYPES.INFERMATICAI) {362 if (apiType === TEXTGEN_TYPES.INFERMATICAI) {
381 data['choices'] = (data?.choices || []).map(choice => ({ text: choice?.message?.content || choice.text, logprobs: choice?.logprobs, index: choice?.index }));363 data['choices'] = (data?.choices || []).map(choice => ({ text: choice?.message?.content || choice.text, logprobs: choice?.logprobs, index: choice?.index }));
src/endpoints/tokenizers.js+27 -33
@@ -942,7 +942,6 @@ router.post('/remote/textgenerationwebui/encode', jsonParser, async function (re
942 }942 }
943 const text = String(request.body.text) || '';943 const text = String(request.body.text) || '';
944 const baseUrl = String(request.body.url);944 const baseUrl = String(request.body.url);
945 const legacyApi = Boolean(request.body.legacy_api);
946 const vllmModel = String(request.body.vllm_model) || '';945 const vllmModel = String(request.body.vllm_model) || '';
947 const aphroditeModel = String(request.body.aphrodite_model) || '';946 const aphroditeModel = String(request.body.aphrodite_model) || '';
948947
@@ -957,36 +956,31 @@ router.post('/remote/textgenerationwebui/encode', jsonParser, async function (re
957 // Convert to string + remove trailing slash + /v1 suffix956 // Convert to string + remove trailing slash + /v1 suffix
958 let url = String(baseUrl).replace(/\/$/, '').replace(/\/v1$/, '');957 let url = String(baseUrl).replace(/\/$/, '').replace(/\/v1$/, '');
959958
960 if (legacyApi) {959 switch (request.body.api_type) {
961 url += '/v1/token-count';960 case TEXTGEN_TYPES.TABBY:
962 args.body = JSON.stringify({ 'prompt': text });961 url += '/v1/token/encode';
963 } else {962 args.body = JSON.stringify({ 'text': text });
964 switch (request.body.api_type) {963 break;
965 case TEXTGEN_TYPES.TABBY:964 case TEXTGEN_TYPES.KOBOLDCPP:
966 url += '/v1/token/encode';965 url += '/api/extra/tokencount';
967 args.body = JSON.stringify({ 'text': text });966 args.body = JSON.stringify({ 'prompt': text });
968 break;967 break;
969 case TEXTGEN_TYPES.KOBOLDCPP:968 case TEXTGEN_TYPES.LLAMACPP:
970 url += '/api/extra/tokencount';969 url += '/tokenize';
971 args.body = JSON.stringify({ 'prompt': text });970 args.body = JSON.stringify({ 'content': text });
972 break;971 break;
973 case TEXTGEN_TYPES.LLAMACPP:972 case TEXTGEN_TYPES.VLLM:
974 url += '/tokenize';973 url += '/tokenize';
975 args.body = JSON.stringify({ 'content': text });974 args.body = JSON.stringify({ 'model': vllmModel, 'prompt': text });
976 break;975 break;
977 case TEXTGEN_TYPES.VLLM:976 case TEXTGEN_TYPES.APHRODITE:
978 url += '/tokenize';977 url += '/v1/tokenize';
979 args.body = JSON.stringify({ 'model': vllmModel, 'prompt': text });978 args.body = JSON.stringify({ 'model': aphroditeModel, 'prompt': text });
980 break;979 break;
981 case TEXTGEN_TYPES.APHRODITE:980 default:
982 url += '/v1/tokenize';981 url += '/v1/internal/encode';
983 args.body = JSON.stringify({ 'model': aphroditeModel, 'prompt': text });982 args.body = JSON.stringify({ 'text': text });
984 break;983 break;
985 default:
986 url += '/v1/internal/encode';
987 args.body = JSON.stringify({ 'text': text });
988 break;
989 }
990 }984 }
991985
992 const result = await fetch(url, args);986 const result = await fetch(url, args);
@@ -997,8 +991,8 @@ router.post('/remote/textgenerationwebui/encode', jsonParser, async function (re
997 }991 }
998992
999 const data = await result.json();993 const data = await result.json();
1000 const count = legacyApi ? data?.results[0]?.tokens : (data?.length ?? data?.count ?? data?.value ?? data?.tokens?.length);994 const count = (data?.length ?? data?.count ?? data?.value ?? data?.tokens?.length);
1001 const ids = legacyApi ? [] : (data?.tokens ?? data?.ids ?? []);995 const ids = (data?.tokens ?? data?.ids ?? []);
1002996
1003 return response.send({ count, ids });997 return response.send({ count, ids });
1004 } catch (error) {998 } catch (error) {