TextGenWebUI: remove legacy API mode

24884b3206625c1b5660a6582d774f27415e3953

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

22 files changed, +3 -89Showing whitespace changes
public/index.html+0 -4
@@ -2573,10 +2573,6 @@
25732573 <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>
25742574 <div class="api_loading menu_button menu_button_icon" data-i18n="Cancel">Cancel</div>
25752575 </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>
25802576 <label data-tg-type="ooba" class="checkbox_label margin-bot-10px" for="bypass_status_check_textgenerationwebui">
25812577 <input type="checkbox" id="bypass_status_check_textgenerationwebui" />
25822578 <span data-i18n="Bypass status check">Bypass status check</span>
public/locales/ar-sa.json+0 -1
@@ -337,7 +337,6 @@
337337 "Example: 127.0.0.1:5001": "مثال: 127.0.0.1:5001",
338338 "Authorize": "تفويض",
339339 "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، بدون بث)",
341340 "Bypass status check": "تجاوز فحص الحالة",
342341 "Chat Completion Source": "مصدر استكمال الدردشة",
343342 "Reverse Proxy": "الوكيل العكسي",
public/locales/de-de.json+0 -1
@@ -337,7 +337,6 @@
337337 "Example: 127.0.0.1:5001": "Beispiel: 127.0.0.1:5001",
338338 "Authorize": "Autorisieren",
339339 "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)",
341340 "Bypass status check": "Umgehe Statusüberprüfung",
342341 "Chat Completion Source": "Quelle für Chat-Vervollständigung",
343342 "Reverse Proxy": "Reverse-Proxy",
public/locales/es-es.json+0 -1
@@ -337,7 +337,6 @@
337337 "Example: 127.0.0.1:5001": "Ejemplo: 127.0.0.1:5001",
338338 "Authorize": "Autorizar",
339339 "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)",
341340 "Bypass status check": "Saltar la verificación del estado",
342341 "Chat Completion Source": "Fuente de Completado de Chat",
343342 "Reverse Proxy": "Proxy inverso",
public/locales/fr-fr.json+0 -1
@@ -337,7 +337,6 @@
337337 "Example: 127.0.0.1:5001": "Exemple : 127.0.0.1:5001",
338338 "Authorize": "Autoriser",
339339 "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)",
341340 "Bypass status check": "Contourner la vérification de l'état",
342341 "Chat Completion Source": "Source de complétion de la conversation",
343342 "Reverse Proxy": "Proxy inverse",
public/locales/is-is.json+0 -1
@@ -337,7 +337,6 @@
337337 "Example: 127.0.0.1:5001": "Dæmi: 127.0.0.1:5001",
338338 "Authorize": "Heimild",
339339 "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)",
341340 "Bypass status check": "Hlaupa framhjá stöðutík",
342341 "Chat Completion Source": "Heimild að fullvirkni spjalls",
343342 "Reverse Proxy": "Reverse proxy",
public/locales/it-it.json+0 -1
@@ -337,7 +337,6 @@
337337 "Example: 127.0.0.1:5001": "Esempio: 127.0.0.1:5001",
338338 "Authorize": "Autorizzare",
339339 "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)",
341340 "Bypass status check": "Ignora controllo stato",
342341 "Chat Completion Source": "Fonte di Completamento della Chat",
343342 "Reverse Proxy": "Proxy inverso",
public/locales/ja-jp.json+0 -1
@@ -337,7 +337,6 @@
337337 "Example: 127.0.0.1:5001": "例: 127.0.0.1:5001",
338338 "Authorize": "承認",
339339 "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以前のもの、ストリーミングなし)",
341340 "Bypass status check": "ステータスのチェックをバイパスする",
342341 "Chat Completion Source": "チャット補完ソース",
343342 "Reverse Proxy": "リバースプロキシ",
public/locales/ko-kr.json+0 -1
@@ -337,7 +337,6 @@
337337 "Example: 127.0.0.1:5001": "예: 127.0.0.1:5001",
338338 "Authorize": "승인하다",
339339 "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 이전, 스트리밍 없음)",
341340 "Bypass status check": "상태 확인 우회",
342341 "Chat Completion Source": "채팅 완성 소스",
343342 "Reverse Proxy": "역방향 프록시",
public/locales/nl-nl.json+0 -1
@@ -337,7 +337,6 @@
337337 "Example: 127.0.0.1:5001": "Voorbeeld: 127.0.0.1:5001",
338338 "Authorize": "Toestemming geven",
339339 "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)",
341340 "Bypass status check": "Omzeil statuscontrole",
342341 "Chat Completion Source": "Bron voor Chatvoltooiing",
343342 "Reverse Proxy": "Omgekeerde proxy",
public/locales/pt-pt.json+0 -1
@@ -337,7 +337,6 @@
337337 "Example: 127.0.0.1:5001": "Exemplo: 127.0.0.1:5001",
338338 "Authorize": "Autorizar",
339339 "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)",
341340 "Bypass status check": "Ignorar verificação de status",
342341 "Chat Completion Source": "Fonte de conclusão de chat",
343342 "Reverse Proxy": "Proxy reverso",
public/locales/ru-ru.json+0 -2
@@ -137,7 +137,6 @@
137137 "Custom model (optional)": "Пользовательская модель (необязательно)",
138138 "Bypass API status check": "Обход проверки статуса API",
139139 "Example: 127.0.0.1:5000": "Пример: http://127.0.0.1:5000",
140- "Legacy API (pre-OAI, no streaming)": "Устаревший API (до OAI, без стриминга)",
141140 "Bypass status check": "Обход проверки статуса",
142141 "Mancer API key": "Ключ от Mancer API",
143142 "to get your OpenAI API key.": "для получения ключа от API OpenAI",
@@ -1808,7 +1807,6 @@
18081807 "Your chat is still saving...": "Чат всё ещё сохраняется...",
18091808 "Character ${0} not found in the list": "Персонаж ${0} не найден в списке",
18101809 "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, чтобы включить стриминг.",
18121810 "Verify that the server is running and accessible.": "Убедитесь, что сервер запущен и доступен по сети.",
18131811 "ST Server cannot be reached": "Не удалось соединиться с сервером ST",
18141812 "You must first select a character to duplicate!": "Вы не выбрали персонажа, которого хотите клонировать!",
public/locales/uk-ua.json+0 -1
@@ -337,7 +337,6 @@
337337 "Example: 127.0.0.1:5001": "Приклад: 127.0.0.1:5001",
338338 "Authorize": "Авторизувати",
339339 "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, без потокової передачі)",
341340 "Bypass status check": "Обійти перевірку статусу",
342341 "Chat Completion Source": "Джерело Chat Completion",
343342 "Reverse Proxy": "Зворотний проксі",
public/locales/vi-vn.json+0 -1
@@ -337,7 +337,6 @@
337337 "Example: 127.0.0.1:5001": "Ví dụ: 127.0.0.1:5001",
338338 "Cho phép": "Ủy quyền",
339339 "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)",
341340 "Bypass status check": "Bỏ qua check trạng thái",
342341 "Chat Completion Source": "Nguồn cho Chat Completion",
343342 "Reverse Proxy": "Proxy",
public/locales/zh-cn.json+0 -1
@@ -351,7 +351,6 @@
351351 "Example: 127.0.0.1:5001": "示例:127.0.0.1:5001",
352352 "Authorize": "授权",
353353 "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之前,无流式传输)",
355354 "Bypass status check": "绕过状态检查",
356355 "Chat Completion Source": "聊天补全来源",
357356 "Custom (OpenAI-compatible)": "自定义(兼容 OpenAI)",
public/locales/zh-tw.json+0 -1
@@ -338,7 +338,6 @@
338338 "Example: 127.0.0.1:5001": "範例:127.0.0.1:5001",
339339 "Authorize": "授權",
340340 "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之前,無串流)",
342341 "Bypass status check": "繞過狀態檢查",
343342 "Chat Completion Source": "聊天補充來源",
344343 "Reverse Proxy": "反向代理伺服器",
public/script.js+0 -10
@@ -1184,7 +1184,6 @@ async function getStatusTextgen() {
11841184 body: JSON.stringify({
11851185 api_server: endpoint,
11861186 api_type: textgen_settings.type,
1187- legacy_api: textgen_settings.legacy_api && textgen_settings.type === OOBA,
11881187 }),
11891188 signal: abortStatusCheck.signal,
11901189 });
@@ -3447,15 +3446,6 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
34473446 return Promise.resolve();
34483447 }
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-
34593449 if (isHordeGenerationNotAllowed()) {
34603450 unblockGeneration(type);
34613451 return Promise.resolve();
public/scripts/power-user.js+0 -17
@@ -303,9 +303,6 @@ let movingUIPresets = [];
303303export let context_presets = [];
304304
305305const storage_keys = {
306- auto_connect_legacy: 'AutoConnectEnabled',
307- auto_load_chat_legacy: 'AutoLoadChatEnabled',
308-
309306 storyStringValidationCache: 'StoryStringValidationCache',
310307};
311308
@@ -1429,20 +1426,6 @@ async function loadPowerUserSettings(settings, data) {
14291426 context_presets = data.context;
14301427 }
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-
14461429 if (power_user.chat_display === '') {
14471430 power_user.chat_display = chat_styles.DEFAULT;
14481431 }
public/scripts/textgen-settings.js+0 -14
@@ -183,7 +183,6 @@ const settings = {
183183 aphrodite_model: '',
184184 dreamgen_model: 'opus-v1-xl/text',
185185 tabby_model: '',
186- legacy_api: false,
187186 sampler_order: KOBOLDCPP_ORDER,
188187 logit_bias: [],
189188 n: 1,
@@ -252,7 +251,6 @@ export const setting_names = [
252251 'grammar_string',
253252 'json_schema',
254253 'banned_tokens',
255- 'legacy_api',
256254 'ignore_eos_token',
257255 'spaces_between_special_tokens',
258256 'speculative_ngram',
@@ -329,22 +327,11 @@ async function selectPreset(name) {
329327function formatTextGenURL(value) {
330328 try {
331329 const noFormatTypes = [MANCER, TOGETHERAI, INFERMATICAI, DREAMGEN, OPENROUTER];
332- const legacyApiTypes = [OOBA];
333330 if (noFormatTypes.includes(settings.type)) {
334331 return value;
335332 }
336333
337334 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- }
348335 return url.toString();
349336 } catch {
350337 // Just using URL as a validation check
@@ -1185,7 +1172,6 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate,
11851172 'banned_strings': banned_strings,
11861173 'api_type': settings.type,
11871174 'api_server': getTextGenServer(),
1188- 'legacy_api': settings.legacy_api && settings.type === OOBA,
11891175 'sampler_order': settings.type === textgen_types.KOBOLDCPP ? settings.sampler_order : undefined,
11901176 'xtc_threshold': settings.xtc_threshold,
11911177 'xtc_probability': settings.xtc_probability,
public/scripts/tokenizers.js+0 -1
@@ -889,7 +889,6 @@ function getTextgenAPITokenizationParams(str) {
889889 text: str,
890890 api_type: textgen_settings.type,
891891 url: getTextGenServer(),
892- legacy_api: textgen_settings.legacy_api && textgen_settings.type === OOBA,
893892 vllm_model: textgen_settings.vllm_model,
894893 aphrodite_model: textgen_settings.aphrodite_model,
895894 };
src/endpoints/backends/text-completions.js+1 -19
@@ -112,9 +112,7 @@ router.post('/status', jsonParser, async function (request, response) {
112112 let url = baseUrl;
113113 let result = '';
114114
115- if (request.body.legacy_api) {
115+
116- url += '/v1/model';
117- } else {
118116 switch (apiType) {
119117 case TEXTGEN_TYPES.OOBA:
120118 case TEXTGEN_TYPES.VLLM:
@@ -147,7 +145,6 @@ router.post('/status', jsonParser, async function (request, response) {
147145 url += '/info';
148146 break;
149147 }
150- }
151148
152149 const modelsReply = await fetch(url, args);
153150 const isPossiblyLmStudio = modelsReply.headers.get('x-powered-by') === 'Express';
@@ -160,11 +157,6 @@ router.post('/status', jsonParser, async function (request, response) {
160157 /** @type {any} */
161158 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-
168160 // Rewrap to OAI-like response
169161 if (apiType === TEXTGEN_TYPES.TOGETHERAI && Array.isArray(data)) {
170162 data = { data: data.map(x => ({ id: x.name, ...x })) };
@@ -259,9 +251,6 @@ router.post('/generate', jsonParser, async function (request, response) {
259251
260252 let url = trimV1(baseUrl);
261253
262- if (request.body.legacy_api) {
263- url += '/v1/generate';
264- } else {
265254 switch (request.body.api_type) {
266255 case TEXTGEN_TYPES.VLLM:
267256 case TEXTGEN_TYPES.FEATHERLESS:
@@ -290,7 +279,6 @@ router.post('/generate', jsonParser, async function (request, response) {
290279 url += '/v1/chat/completions';
291280 break;
292281 }
293- }
294282
295283 const args = {
296284 method: 'POST',
@@ -370,12 +358,6 @@ router.post('/generate', jsonParser, async function (request, response) {
370358 const data = await completionsReply.json();
371359 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-
379361 // Map InfermaticAI response to OAI completions format
380362 if (apiType === TEXTGEN_TYPES.INFERMATICAI) {
381363 data['choices'] = (data?.choices || []).map(choice => ({ text: choice?.message?.content || choice.text, logprobs: choice?.logprobs, index: choice?.index }));
src/endpoints/tokenizers.js+2 -8
@@ -942,7 +942,6 @@ router.post('/remote/textgenerationwebui/encode', jsonParser, async function (re
942942 }
943943 const text = String(request.body.text) || '';
944944 const baseUrl = String(request.body.url);
945- const legacyApi = Boolean(request.body.legacy_api);
946945 const vllmModel = String(request.body.vllm_model) || '';
947946 const aphroditeModel = String(request.body.aphrodite_model) || '';
948947
@@ -957,10 +956,6 @@ router.post('/remote/textgenerationwebui/encode', jsonParser, async function (re
957956 // Convert to string + remove trailing slash + /v1 suffix
958957 let url = String(baseUrl).replace(/\/$/, '').replace(/\/v1$/, '');
959958
960- if (legacyApi) {
961- url += '/v1/token-count';
962- args.body = JSON.stringify({ 'prompt': text });
963- } else {
964959 switch (request.body.api_type) {
965960 case TEXTGEN_TYPES.TABBY:
966961 url += '/v1/token/encode';
@@ -987,7 +982,6 @@ router.post('/remote/textgenerationwebui/encode', jsonParser, async function (re
987982 args.body = JSON.stringify({ 'text': text });
988983 break;
989984 }
990- }
991985
992986 const result = await fetch(url, args);
993987
@@ -997,8 +991,8 @@ router.post('/remote/textgenerationwebui/encode', jsonParser, async function (re
997991 }
998992
999993 const data = await result.json();
1000994 const count = legacyApi ? data?.results[0]?.tokens : (data?.length ?? data?.count ?? data?.value ?? data?.tokens?.length);
1001995 const ids = legacyApi ? [] : (data?.tokens ?? data?.ids ?? []);
1002996
1003997 return response.send({ count, ids });
1004998 } catch (error) {