Merge pull request #2987 from SillyTavern/remove-legacy-api TextGenWebUI: remove legacy API mode
Signed| @@ -2573,10 +2573,6 @@ | ||
| 2573 | 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 | 2574 | <div class="api_loading menu_button menu_button_icon" data-i18n="Cancel">Cancel</div> |
| 2575 | 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 | 2576 | <label data-tg-type="ooba" class="checkbox_label margin-bot-10px" for="bypass_status_check_textgenerationwebui"> |
| 2581 | 2577 | <input type="checkbox" id="bypass_status_check_textgenerationwebui" /> |
| 2582 | 2578 | <span data-i18n="Bypass status check">Bypass status check</span> |
| @@ -337,7 +337,6 @@ | ||
| 337 | 337 | "Example: 127.0.0.1:5001": "مثال: 127.0.0.1:5001", |
| 338 | 338 | "Authorize": "تفويض", |
| 339 | 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 | 340 | "Bypass status check": "تجاوز فحص الحالة", |
| 342 | 341 | "Chat Completion Source": "مصدر استكمال الدردشة", |
| 343 | 342 | "Reverse Proxy": "الوكيل العكسي", |
| @@ -337,7 +337,6 @@ | ||
| 337 | 337 | "Example: 127.0.0.1:5001": "Beispiel: 127.0.0.1:5001", |
| 338 | 338 | "Authorize": "Autorisieren", |
| 339 | 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 | 340 | "Bypass status check": "Umgehe Statusüberprüfung", |
| 342 | 341 | "Chat Completion Source": "Quelle für Chat-Vervollständigung", |
| 343 | 342 | "Reverse Proxy": "Reverse-Proxy", |
| @@ -337,7 +337,6 @@ | ||
| 337 | 337 | "Example: 127.0.0.1:5001": "Ejemplo: 127.0.0.1:5001", |
| 338 | 338 | "Authorize": "Autorizar", |
| 339 | 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 | 340 | "Bypass status check": "Saltar la verificación del estado", |
| 342 | 341 | "Chat Completion Source": "Fuente de Completado de Chat", |
| 343 | 342 | "Reverse Proxy": "Proxy inverso", |
| @@ -337,7 +337,6 @@ | ||
| 337 | 337 | "Example: 127.0.0.1:5001": "Exemple : 127.0.0.1:5001", |
| 338 | 338 | "Authorize": "Autoriser", |
| 339 | 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 | 340 | "Bypass status check": "Contourner la vérification de l'état", |
| 342 | 341 | "Chat Completion Source": "Source de complétion de la conversation", |
| 343 | 342 | "Reverse Proxy": "Proxy inverse", |
| @@ -337,7 +337,6 @@ | ||
| 337 | 337 | "Example: 127.0.0.1:5001": "Dæmi: 127.0.0.1:5001", |
| 338 | 338 | "Authorize": "Heimild", |
| 339 | 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 | 340 | "Bypass status check": "Hlaupa framhjá stöðutík", |
| 342 | 341 | "Chat Completion Source": "Heimild að fullvirkni spjalls", |
| 343 | 342 | "Reverse Proxy": "Reverse proxy", |
| @@ -337,7 +337,6 @@ | ||
| 337 | 337 | "Example: 127.0.0.1:5001": "Esempio: 127.0.0.1:5001", |
| 338 | 338 | "Authorize": "Autorizzare", |
| 339 | 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 | 340 | "Bypass status check": "Ignora controllo stato", |
| 342 | 341 | "Chat Completion Source": "Fonte di Completamento della Chat", |
| 343 | 342 | "Reverse Proxy": "Proxy inverso", |
| @@ -337,7 +337,6 @@ | ||
| 337 | 337 | "Example: 127.0.0.1:5001": "例: 127.0.0.1:5001", |
| 338 | 338 | "Authorize": "承認", |
| 339 | 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 | 340 | "Bypass status check": "ステータスのチェックをバイパスする", |
| 342 | 341 | "Chat Completion Source": "チャット補完ソース", |
| 343 | 342 | "Reverse Proxy": "リバースプロキシ", |
| @@ -337,7 +337,6 @@ | ||
| 337 | 337 | "Example: 127.0.0.1:5001": "예: 127.0.0.1:5001", |
| 338 | 338 | "Authorize": "승인하다", |
| 339 | 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 | 340 | "Bypass status check": "상태 확인 우회", |
| 342 | 341 | "Chat Completion Source": "채팅 완성 소스", |
| 343 | 342 | "Reverse Proxy": "역방향 프록시", |
| @@ -337,7 +337,6 @@ | ||
| 337 | 337 | "Example: 127.0.0.1:5001": "Voorbeeld: 127.0.0.1:5001", |
| 338 | 338 | "Authorize": "Toestemming geven", |
| 339 | 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 | 340 | "Bypass status check": "Omzeil statuscontrole", |
| 342 | 341 | "Chat Completion Source": "Bron voor Chatvoltooiing", |
| 343 | 342 | "Reverse Proxy": "Omgekeerde proxy", |
| @@ -337,7 +337,6 @@ | ||
| 337 | 337 | "Example: 127.0.0.1:5001": "Exemplo: 127.0.0.1:5001", |
| 338 | 338 | "Authorize": "Autorizar", |
| 339 | 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 | 340 | "Bypass status check": "Ignorar verificação de status", |
| 342 | 341 | "Chat Completion Source": "Fonte de conclusão de chat", |
| 343 | 342 | "Reverse Proxy": "Proxy reverso", |
| @@ -137,7 +137,6 @@ | ||
| 137 | 137 | "Custom model (optional)": "Пользовательская модель (необязательно)", |
| 138 | 138 | "Bypass API status check": "Обход проверки статуса API", |
| 139 | 139 | "Example: 127.0.0.1:5000": "Пример: http://127.0.0.1:5000", |
| 140 | - "Legacy API (pre-OAI, no streaming)": "Устаревший API (до OAI, без стриминга)", | |
| 141 | 140 | "Bypass status check": "Обход проверки статуса", |
| 142 | 141 | "Mancer API key": "Ключ от Mancer API", |
| 143 | 142 | "to get your OpenAI API key.": "для получения ключа от API OpenAI", |
| @@ -1808,7 +1807,6 @@ | ||
| 1808 | 1807 | "Your chat is still saving...": "Чат всё ещё сохраняется...", |
| 1809 | 1808 | "Character ${0} not found in the list": "Персонаж ${0} не найден в списке", |
| 1810 | 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 | 1810 | "Verify that the server is running and accessible.": "Убедитесь, что сервер запущен и доступен по сети.", |
| 1813 | 1811 | "ST Server cannot be reached": "Не удалось соединиться с сервером ST", |
| 1814 | 1812 | "You must first select a character to duplicate!": "Вы не выбрали персонажа, которого хотите клонировать!", |
| @@ -337,7 +337,6 @@ | ||
| 337 | 337 | "Example: 127.0.0.1:5001": "Приклад: 127.0.0.1:5001", |
| 338 | 338 | "Authorize": "Авторизувати", |
| 339 | 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 | 340 | "Bypass status check": "Обійти перевірку статусу", |
| 342 | 341 | "Chat Completion Source": "Джерело Chat Completion", |
| 343 | 342 | "Reverse Proxy": "Зворотний проксі", |
| @@ -337,7 +337,6 @@ | ||
| 337 | 337 | "Example: 127.0.0.1:5001": "Ví dụ: 127.0.0.1:5001", |
| 338 | 338 | "Cho phép": "Ủy quyền", |
| 339 | 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 | 340 | "Bypass status check": "Bỏ qua check trạng thái", |
| 342 | 341 | "Chat Completion Source": "Nguồn cho Chat Completion", |
| 343 | 342 | "Reverse Proxy": "Proxy", |
| @@ -351,7 +351,6 @@ | ||
| 351 | 351 | "Example: 127.0.0.1:5001": "示例:127.0.0.1:5001", |
| 352 | 352 | "Authorize": "授权", |
| 353 | 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 | 354 | "Bypass status check": "绕过状态检查", |
| 356 | 355 | "Chat Completion Source": "聊天补全来源", |
| 357 | 356 | "Custom (OpenAI-compatible)": "自定义(兼容 OpenAI)", |
| @@ -338,7 +338,6 @@ | ||
| 338 | 338 | "Example: 127.0.0.1:5001": "範例:127.0.0.1:5001", |
| 339 | 339 | "Authorize": "授權", |
| 340 | 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 | 341 | "Bypass status check": "繞過狀態檢查", |
| 343 | 342 | "Chat Completion Source": "聊天補充來源", |
| 344 | 343 | "Reverse Proxy": "反向代理伺服器", |
| @@ -1184,7 +1184,6 @@ async function getStatusTextgen() { | ||
| 1184 | 1184 | body: JSON.stringify({ |
| 1185 | 1185 | api_server: endpoint, |
| 1186 | 1186 | api_type: textgen_settings.type, |
| 1187 | - legacy_api: textgen_settings.legacy_api && textgen_settings.type === OOBA, | |
| 1188 | 1187 | }), |
| 1189 | 1188 | signal: abortStatusCheck.signal, |
| 1190 | 1189 | }); |
| @@ -3447,15 +3446,6 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro | ||
| 3447 | 3446 | return Promise.resolve(); |
| 3448 | 3447 | } |
| 3449 | 3448 | |
| 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 | 3449 | if (isHordeGenerationNotAllowed()) { |
| 3460 | 3450 | unblockGeneration(type); |
| 3461 | 3451 | return Promise.resolve(); |
| @@ -303,9 +303,6 @@ let movingUIPresets = []; | ||
| 303 | 303 | export let context_presets = []; |
| 304 | 304 | |
| 305 | 305 | const storage_keys = { |
| 306 | - auto_connect_legacy: 'AutoConnectEnabled', | |
| 307 | - auto_load_chat_legacy: 'AutoLoadChatEnabled', | |
| 308 | - | |
| 309 | 306 | storyStringValidationCache: 'StoryStringValidationCache', |
| 310 | 307 | }; |
| 311 | 308 | |
| @@ -1429,20 +1426,6 @@ async function loadPowerUserSettings(settings, data) { | ||
| 1429 | 1426 | context_presets = data.context; |
| 1430 | 1427 | } |
| 1431 | 1428 | |
| 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 | 1429 | if (power_user.chat_display === '') { |
| 1447 | 1430 | power_user.chat_display = chat_styles.DEFAULT; |
| 1448 | 1431 | } |
| @@ -183,7 +183,6 @@ const settings = { | ||
| 183 | 183 | aphrodite_model: '', |
| 184 | 184 | dreamgen_model: 'opus-v1-xl/text', |
| 185 | 185 | tabby_model: '', |
| 186 | - legacy_api: false, | |
| 187 | 186 | sampler_order: KOBOLDCPP_ORDER, |
| 188 | 187 | logit_bias: [], |
| 189 | 188 | n: 1, |
| @@ -252,7 +251,6 @@ export const setting_names = [ | ||
| 252 | 251 | 'grammar_string', |
| 253 | 252 | 'json_schema', |
| 254 | 253 | 'banned_tokens', |
| 255 | - 'legacy_api', | |
| 256 | 254 | 'ignore_eos_token', |
| 257 | 255 | 'spaces_between_special_tokens', |
| 258 | 256 | 'speculative_ngram', |
| @@ -329,22 +327,11 @@ async function selectPreset(name) { | ||
| 329 | 327 | function formatTextGenURL(value) { |
| 330 | 328 | try { |
| 331 | 329 | const noFormatTypes = [MANCER, TOGETHERAI, INFERMATICAI, DREAMGEN, OPENROUTER]; |
| 332 | - const legacyApiTypes = [OOBA]; | |
| 333 | 330 | if (noFormatTypes.includes(settings.type)) { |
| 334 | 331 | return value; |
| 335 | 332 | } |
| 336 | 333 | |
| 337 | 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 | 335 | return url.toString(); |
| 349 | 336 | } catch { |
| 350 | 337 | // Just using URL as a validation check |
| @@ -1185,7 +1172,6 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate, | ||
| 1185 | 1172 | 'banned_strings': banned_strings, |
| 1186 | 1173 | 'api_type': settings.type, |
| 1187 | 1174 | 'api_server': getTextGenServer(), |
| 1188 | - 'legacy_api': settings.legacy_api && settings.type === OOBA, | |
| 1189 | 1175 | 'sampler_order': settings.type === textgen_types.KOBOLDCPP ? settings.sampler_order : undefined, |
| 1190 | 1176 | 'xtc_threshold': settings.xtc_threshold, |
| 1191 | 1177 | 'xtc_probability': settings.xtc_probability, |
| @@ -889,7 +889,6 @@ function getTextgenAPITokenizationParams(str) { | ||
| 889 | 889 | text: str, |
| 890 | 890 | api_type: textgen_settings.type, |
| 891 | 891 | url: getTextGenServer(), |
| 892 | - legacy_api: textgen_settings.legacy_api && textgen_settings.type === OOBA, | |
| 893 | 892 | vllm_model: textgen_settings.vllm_model, |
| 894 | 893 | aphrodite_model: textgen_settings.aphrodite_model, |
| 895 | 894 | }; |
| @@ -112,9 +112,7 @@ router.post('/status', jsonParser, async function (request, response) { | ||
| 112 | 112 | let url = baseUrl; |
| 113 | 113 | let result = ''; |
| 114 | 114 | |
| 115 | - if (request.body.legacy_api) { | |
| 115 | + | |
| 116 | - url += '/v1/model'; | |
| 117 | - } else { | |
| 118 | 116 | switch (apiType) { |
| 119 | 117 | case TEXTGEN_TYPES.OOBA: |
| 120 | 118 | case TEXTGEN_TYPES.VLLM: |
| @@ -147,7 +145,6 @@ router.post('/status', jsonParser, async function (request, response) { | ||
| 147 | 145 | url += '/info'; |
| 148 | 146 | break; |
| 149 | 147 | } |
| 150 | - } | |
| 151 | 148 | |
| 152 | 149 | const modelsReply = await fetch(url, args); |
| 153 | 150 | const isPossiblyLmStudio = modelsReply.headers.get('x-powered-by') === 'Express'; |
| @@ -160,11 +157,6 @@ router.post('/status', jsonParser, async function (request, response) { | ||
| 160 | 157 | /** @type {any} */ |
| 161 | 158 | let data = await modelsReply.json(); |
| 162 | 159 | |
| 163 | - if (request.body.legacy_api) { | |
| 164 | - console.log('Legacy API response:', data); | |
| 165 | - return response.send({ result: data?.result }); | |
| 166 | - } | |
| 167 | - | |
| 168 | 160 | // Rewrap to OAI-like response |
| 169 | 161 | if (apiType === TEXTGEN_TYPES.TOGETHERAI && Array.isArray(data)) { |
| 170 | 162 | data = { data: data.map(x => ({ id: x.name, ...x })) }; |
| @@ -259,9 +251,6 @@ router.post('/generate', jsonParser, async function (request, response) { | ||
| 259 | 251 | |
| 260 | 252 | let url = trimV1(baseUrl); |
| 261 | 253 | |
| 262 | - if (request.body.legacy_api) { | |
| 263 | - url += '/v1/generate'; | |
| 264 | - } else { | |
| 265 | 254 | switch (request.body.api_type) { |
| 266 | 255 | case TEXTGEN_TYPES.VLLM: |
| 267 | 256 | case TEXTGEN_TYPES.FEATHERLESS: |
| @@ -290,7 +279,6 @@ router.post('/generate', jsonParser, async function (request, response) { | ||
| 290 | 279 | url += '/v1/chat/completions'; |
| 291 | 280 | break; |
| 292 | 281 | } |
| 293 | - } | |
| 294 | 282 | |
| 295 | 283 | const args = { |
| 296 | 284 | method: 'POST', |
| @@ -370,12 +358,6 @@ router.post('/generate', jsonParser, async function (request, response) { | ||
| 370 | 358 | const data = await completionsReply.json(); |
| 371 | 359 | console.log('Endpoint response:', data); |
| 372 | 360 | |
| 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 | 361 | // Map InfermaticAI response to OAI completions format |
| 380 | 362 | if (apiType === TEXTGEN_TYPES.INFERMATICAI) { |
| 381 | 363 | data['choices'] = (data?.choices || []).map(choice => ({ text: choice?.message?.content || choice.text, logprobs: choice?.logprobs, index: choice?.index })); |
| @@ -942,7 +942,6 @@ router.post('/remote/textgenerationwebui/encode', jsonParser, async function (re | ||
| 942 | 942 | } |
| 943 | 943 | const text = String(request.body.text) || ''; |
| 944 | 944 | const baseUrl = String(request.body.url); |
| 945 | - const legacyApi = Boolean(request.body.legacy_api); | |
| 946 | 945 | const vllmModel = String(request.body.vllm_model) || ''; |
| 947 | 946 | const aphroditeModel = String(request.body.aphrodite_model) || ''; |
| 948 | 947 | |
| @@ -957,10 +956,6 @@ router.post('/remote/textgenerationwebui/encode', jsonParser, async function (re | ||
| 957 | 956 | // Convert to string + remove trailing slash + /v1 suffix |
| 958 | 957 | let url = String(baseUrl).replace(/\/$/, '').replace(/\/v1$/, ''); |
| 959 | 958 | |
| 960 | - if (legacyApi) { | |
| 961 | - url += '/v1/token-count'; | |
| 962 | - args.body = JSON.stringify({ 'prompt': text }); | |
| 963 | - } else { | |
| 964 | 959 | switch (request.body.api_type) { |
| 965 | 960 | case TEXTGEN_TYPES.TABBY: |
| 966 | 961 | url += '/v1/token/encode'; |
| @@ -987,7 +982,6 @@ router.post('/remote/textgenerationwebui/encode', jsonParser, async function (re | ||
| 987 | 982 | args.body = JSON.stringify({ 'text': text }); |
| 988 | 983 | break; |
| 989 | 984 | } |
| 990 | - } | |
| 991 | 985 | |
| 992 | 986 | const result = await fetch(url, args); |
| 993 | 987 | |
| @@ -997,8 +991,8 @@ router.post('/remote/textgenerationwebui/encode', jsonParser, async function (re | ||
| 997 | 991 | } |
| 998 | 992 | |
| 999 | 993 | const data = await result.json(); |
| 1000 | 994 | const count = legacyApi ? data?.results[0]?.tokens : (data?.length ?? data?.count ?? data?.value ?? data?.tokens?.length); |
| 1001 | 995 | const ids = legacyApi ? [] : (data?.tokens ?? data?.ids ?? []); |
| 1002 | 996 | |
| 1003 | 997 | return response.send({ count, ids }); |
| 1004 | 998 | } catch (error) { |