TextGenWebUI: remove legacy API mode

This commit is contained in:
Cohee
2024-10-15 00:32:56 +03:00
parent 8986cb0039
commit 24884b3206
22 changed files with 86 additions and 172 deletions

View File

@ -2573,10 +2573,6 @@
<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> <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>
<div class="api_loading menu_button menu_button_icon" data-i18n="Cancel">Cancel</div> <div class="api_loading menu_button menu_button_icon" data-i18n="Cancel">Cancel</div>
</div> </div>
<label data-tg-type="ooba" class="checkbox_label margin-bot-10px" for="legacy_api_textgenerationwebui">
<input type="checkbox" id="legacy_api_textgenerationwebui" />
<span data-i18n="Legacy API (pre-OAI, no streaming)">Legacy API (pre-OAI, no streaming)</span>
</label>
<label data-tg-type="ooba" class="checkbox_label margin-bot-10px" for="bypass_status_check_textgenerationwebui"> <label data-tg-type="ooba" class="checkbox_label margin-bot-10px" for="bypass_status_check_textgenerationwebui">
<input type="checkbox" id="bypass_status_check_textgenerationwebui" /> <input type="checkbox" id="bypass_status_check_textgenerationwebui" />
<span data-i18n="Bypass status check">Bypass status check</span> <span data-i18n="Bypass status check">Bypass status check</span>

View File

@ -337,7 +337,6 @@
"Example: 127.0.0.1:5001": "مثال: 127.0.0.1:5001", "Example: 127.0.0.1:5001": "مثال: 127.0.0.1:5001",
"Authorize": "تفويض", "Authorize": "تفويض",
"Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "احصل على رمز واجهة برمجة التطبيقات الخاص بك لموزع الاتصالات باستخدام تدفق OAuth. سيتم توجيهك إلى openrouter.ai", "Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "احصل على رمز واجهة برمجة التطبيقات الخاص بك لموزع الاتصالات باستخدام تدفق OAuth. سيتم توجيهك إلى openrouter.ai",
"Legacy API (pre-OAI, no streaming)": "واجهة برمجة التطبيقات القديمة (قبل OAI، بدون بث)",
"Bypass status check": "تجاوز فحص الحالة", "Bypass status check": "تجاوز فحص الحالة",
"Chat Completion Source": "مصدر استكمال الدردشة", "Chat Completion Source": "مصدر استكمال الدردشة",
"Reverse Proxy": "الوكيل العكسي", "Reverse Proxy": "الوكيل العكسي",

View File

@ -337,7 +337,6 @@
"Example: 127.0.0.1:5001": "Beispiel: 127.0.0.1:5001", "Example: 127.0.0.1:5001": "Beispiel: 127.0.0.1:5001",
"Authorize": "Autorisieren", "Authorize": "Autorisieren",
"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", "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",
"Legacy API (pre-OAI, no streaming)": "Legacy-API (vor OAI, kein Streaming)",
"Bypass status check": "Umgehe Statusüberprüfung", "Bypass status check": "Umgehe Statusüberprüfung",
"Chat Completion Source": "Quelle für Chat-Vervollständigung", "Chat Completion Source": "Quelle für Chat-Vervollständigung",
"Reverse Proxy": "Reverse-Proxy", "Reverse Proxy": "Reverse-Proxy",

View File

@ -337,7 +337,6 @@
"Example: 127.0.0.1:5001": "Ejemplo: 127.0.0.1:5001", "Example: 127.0.0.1:5001": "Ejemplo: 127.0.0.1:5001",
"Authorize": "Autorizar", "Authorize": "Autorizar",
"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", "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",
"Legacy API (pre-OAI, no streaming)": "API heredada (pre-OAI, sin streaming)",
"Bypass status check": "Saltar la verificación del estado", "Bypass status check": "Saltar la verificación del estado",
"Chat Completion Source": "Fuente de Completado de Chat", "Chat Completion Source": "Fuente de Completado de Chat",
"Reverse Proxy": "Proxy inverso", "Reverse Proxy": "Proxy inverso",

View File

@ -337,7 +337,6 @@
"Example: 127.0.0.1:5001": "Exemple : 127.0.0.1:5001", "Example: 127.0.0.1:5001": "Exemple : 127.0.0.1:5001",
"Authorize": "Autoriser", "Authorize": "Autoriser",
"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", "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",
"Legacy API (pre-OAI, no streaming)": "API héritée (pré-OAI, pas de streaming)",
"Bypass status check": "Contourner la vérification de l'état", "Bypass status check": "Contourner la vérification de l'état",
"Chat Completion Source": "Source de complétion de la conversation", "Chat Completion Source": "Source de complétion de la conversation",
"Reverse Proxy": "Proxy inverse", "Reverse Proxy": "Proxy inverse",

View File

@ -337,7 +337,6 @@
"Example: 127.0.0.1:5001": "Dæmi: 127.0.0.1:5001", "Example: 127.0.0.1:5001": "Dæmi: 127.0.0.1:5001",
"Authorize": "Heimild", "Authorize": "Heimild",
"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", "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",
"Legacy API (pre-OAI, no streaming)": "Eldri API (fyrir OAI, engin flæði)",
"Bypass status check": "Hlaupa framhjá stöðutík", "Bypass status check": "Hlaupa framhjá stöðutík",
"Chat Completion Source": "Heimild að fullvirkni spjalls", "Chat Completion Source": "Heimild að fullvirkni spjalls",
"Reverse Proxy": "Reverse proxy", "Reverse Proxy": "Reverse proxy",

View File

@ -337,7 +337,6 @@
"Example: 127.0.0.1:5001": "Esempio: 127.0.0.1:5001", "Example: 127.0.0.1:5001": "Esempio: 127.0.0.1:5001",
"Authorize": "Autorizzare", "Authorize": "Autorizzare",
"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", "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",
"Legacy API (pre-OAI, no streaming)": "API legacy (prima di OAI, senza streaming)",
"Bypass status check": "Ignora controllo stato", "Bypass status check": "Ignora controllo stato",
"Chat Completion Source": "Fonte di Completamento della Chat", "Chat Completion Source": "Fonte di Completamento della Chat",
"Reverse Proxy": "Proxy inverso", "Reverse Proxy": "Proxy inverso",

View File

@ -337,7 +337,6 @@
"Example: 127.0.0.1:5001": "例: 127.0.0.1:5001", "Example: 127.0.0.1:5001": "例: 127.0.0.1:5001",
"Authorize": "承認", "Authorize": "承認",
"Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "OAuthフローを使用してOpenRouter APIトークンを取得します。 openrouter.aiにリダイレクトされます", "Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "OAuthフローを使用してOpenRouter APIトークンを取得します。 openrouter.aiにリダイレクトされます",
"Legacy API (pre-OAI, no streaming)": "レガシーAPIOAI以前のもの、ストリーミングなし",
"Bypass status check": "ステータスのチェックをバイパスする", "Bypass status check": "ステータスのチェックをバイパスする",
"Chat Completion Source": "チャット補完ソース", "Chat Completion Source": "チャット補完ソース",
"Reverse Proxy": "リバースプロキシ", "Reverse Proxy": "リバースプロキシ",

View File

@ -337,7 +337,6 @@
"Example: 127.0.0.1:5001": "예: 127.0.0.1:5001", "Example: 127.0.0.1:5001": "예: 127.0.0.1:5001",
"Authorize": "승인하다", "Authorize": "승인하다",
"Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "OAuth 플로우를 사용하여 OpenRouter API 토큰을 가져옵니다. openrouter.ai로 리디렉션됩니다.", "Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "OAuth 플로우를 사용하여 OpenRouter API 토큰을 가져옵니다. openrouter.ai로 리디렉션됩니다.",
"Legacy API (pre-OAI, no streaming)": "레거시 API (OAI 이전, 스트리밍 없음)",
"Bypass status check": "상태 확인 우회", "Bypass status check": "상태 확인 우회",
"Chat Completion Source": "채팅 완성 소스", "Chat Completion Source": "채팅 완성 소스",
"Reverse Proxy": "역방향 프록시", "Reverse Proxy": "역방향 프록시",

View File

@ -337,7 +337,6 @@
"Example: 127.0.0.1:5001": "Voorbeeld: 127.0.0.1:5001", "Example: 127.0.0.1:5001": "Voorbeeld: 127.0.0.1:5001",
"Authorize": "Toestemming geven", "Authorize": "Toestemming geven",
"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", "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",
"Legacy API (pre-OAI, no streaming)": "Legacy API (vóór OAI, geen streaming)",
"Bypass status check": "Omzeil statuscontrole", "Bypass status check": "Omzeil statuscontrole",
"Chat Completion Source": "Bron voor Chatvoltooiing", "Chat Completion Source": "Bron voor Chatvoltooiing",
"Reverse Proxy": "Omgekeerde proxy", "Reverse Proxy": "Omgekeerde proxy",

View File

@ -337,7 +337,6 @@
"Example: 127.0.0.1:5001": "Exemplo: 127.0.0.1:5001", "Example: 127.0.0.1:5001": "Exemplo: 127.0.0.1:5001",
"Authorize": "Autorizar", "Authorize": "Autorizar",
"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", "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",
"Legacy API (pre-OAI, no streaming)": "API legada (pré-OAI, sem streaming)",
"Bypass status check": "Ignorar verificação de status", "Bypass status check": "Ignorar verificação de status",
"Chat Completion Source": "Fonte de conclusão de chat", "Chat Completion Source": "Fonte de conclusão de chat",
"Reverse Proxy": "Proxy reverso", "Reverse Proxy": "Proxy reverso",

View File

@ -137,7 +137,6 @@
"Custom model (optional)": "Пользовательская модель (необязательно)", "Custom model (optional)": "Пользовательская модель (необязательно)",
"Bypass API status check": "Обход проверки статуса API", "Bypass API status check": "Обход проверки статуса API",
"Example: 127.0.0.1:5000": "Пример: http://127.0.0.1:5000", "Example: 127.0.0.1:5000": "Пример: http://127.0.0.1:5000",
"Legacy API (pre-OAI, no streaming)": "Устаревший API (до OAI, без стриминга)",
"Bypass status check": "Обход проверки статуса", "Bypass status check": "Обход проверки статуса",
"Mancer API key": "Ключ от Mancer API", "Mancer API key": "Ключ от Mancer API",
"to get your OpenAI API key.": "для получения ключа от API OpenAI", "to get your OpenAI API key.": "для получения ключа от API OpenAI",
@ -1808,7 +1807,6 @@
"Your chat is still saving...": "Чат всё ещё сохраняется...", "Your chat is still saving...": "Чат всё ещё сохраняется...",
"Character ${0} not found in the list": "Персонаж ${0} не найден в списке", "Character ${0} not found in the list": "Персонаж ${0} не найден в списке",
"Streaming is enabled, but the version of Kobold used does not support token streaming.": "Включён стриминг текста, но ваша версия Kobold не поддерживает стриминг токенов.", "Streaming is enabled, but the version of Kobold used does not support token streaming.": "Включён стриминг текста, но ваша версия Kobold не поддерживает стриминг токенов.",
"Streaming is not supported for the Legacy API. Update Ooba and use new API to enable streaming.": "Для устаревшего API стриминг недоступен. Обновите oobaboga и используйте новый API, чтобы включить стриминг.",
"Verify that the server is running and accessible.": "Убедитесь, что сервер запущен и доступен по сети.", "Verify that the server is running and accessible.": "Убедитесь, что сервер запущен и доступен по сети.",
"ST Server cannot be reached": "Не удалось соединиться с сервером ST", "ST Server cannot be reached": "Не удалось соединиться с сервером ST",
"You must first select a character to duplicate!": "Вы не выбрали персонажа, которого хотите клонировать!", "You must first select a character to duplicate!": "Вы не выбрали персонажа, которого хотите клонировать!",

View File

@ -337,7 +337,6 @@
"Example: 127.0.0.1:5001": "Приклад: 127.0.0.1:5001", "Example: 127.0.0.1:5001": "Приклад: 127.0.0.1:5001",
"Authorize": "Авторизувати", "Authorize": "Авторизувати",
"Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "Отримайте свій токен API OpenRouter за допомогою OAuth. Вас буде перенаправлено на openrouter.ai", "Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "Отримайте свій токен API OpenRouter за допомогою OAuth. Вас буде перенаправлено на openrouter.ai",
"Legacy API (pre-OAI, no streaming)": "Застарілий API (до OAI, без потокової передачі)",
"Bypass status check": "Обійти перевірку статусу", "Bypass status check": "Обійти перевірку статусу",
"Chat Completion Source": "Джерело Chat Completion", "Chat Completion Source": "Джерело Chat Completion",
"Reverse Proxy": "Зворотний проксі", "Reverse Proxy": "Зворотний проксі",

View File

@ -337,7 +337,6 @@
"Example: 127.0.0.1:5001": "Ví dụ: 127.0.0.1:5001", "Example: 127.0.0.1:5001": "Ví dụ: 127.0.0.1:5001",
"Cho phép": "Ủy quyền", "Cho phép": "Ủy quyền",
"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", "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",
"Legacy API (pre-OAI, no streaming)": "API cũ (trước OAI, không có streaming)",
"Bypass status check": "Bỏ qua check trạng thái", "Bypass status check": "Bỏ qua check trạng thái",
"Chat Completion Source": "Nguồn cho Chat Completion", "Chat Completion Source": "Nguồn cho Chat Completion",
"Reverse Proxy": "Proxy", "Reverse Proxy": "Proxy",

View File

@ -351,7 +351,6 @@
"Example: 127.0.0.1:5001": "示例127.0.0.1:5001", "Example: 127.0.0.1:5001": "示例127.0.0.1:5001",
"Authorize": "授权", "Authorize": "授权",
"Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "使用OAuth流程获取您的OpenRouter API令牌。您将被重定向到openrouter.ai", "Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "使用OAuth流程获取您的OpenRouter API令牌。您将被重定向到openrouter.ai",
"Legacy API (pre-OAI, no streaming)": "旧版APIOAI之前无流式传输",
"Bypass status check": "绕过状态检查", "Bypass status check": "绕过状态检查",
"Chat Completion Source": "聊天补全来源", "Chat Completion Source": "聊天补全来源",
"Custom (OpenAI-compatible)": "自定义(兼容 OpenAI", "Custom (OpenAI-compatible)": "自定义(兼容 OpenAI",

View File

@ -338,7 +338,6 @@
"Example: 127.0.0.1:5001": "範例127.0.0.1:5001", "Example: 127.0.0.1:5001": "範例127.0.0.1:5001",
"Authorize": "授權", "Authorize": "授權",
"Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "使用 OAuth 流程取得您的 OpenRouter API 符記。您將被重新導向到 openrouter.ai", "Get your OpenRouter API token using OAuth flow. You will be redirected to openrouter.ai": "使用 OAuth 流程取得您的 OpenRouter API 符記。您將被重新導向到 openrouter.ai",
"Legacy API (pre-OAI, no streaming)": "傳統 API(OAI之前無串流)",
"Bypass status check": "繞過狀態檢查", "Bypass status check": "繞過狀態檢查",
"Chat Completion Source": "聊天補充來源", "Chat Completion Source": "聊天補充來源",
"Reverse Proxy": "反向代理伺服器", "Reverse Proxy": "反向代理伺服器",

View File

@ -1184,7 +1184,6 @@ async function getStatusTextgen() {
body: JSON.stringify({ body: JSON.stringify({
api_server: endpoint, api_server: endpoint,
api_type: textgen_settings.type, api_type: textgen_settings.type,
legacy_api: textgen_settings.legacy_api && textgen_settings.type === OOBA,
}), }),
signal: abortStatusCheck.signal, signal: abortStatusCheck.signal,
}); });
@ -3447,15 +3446,6 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
return Promise.resolve(); return Promise.resolve();
} }
if (main_api === 'textgenerationwebui' &&
textgen_settings.streaming &&
textgen_settings.legacy_api &&
textgen_settings.type === OOBA) {
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 });
unblockGeneration(type);
return Promise.resolve();
}
if (isHordeGenerationNotAllowed()) { if (isHordeGenerationNotAllowed()) {
unblockGeneration(type); unblockGeneration(type);
return Promise.resolve(); return Promise.resolve();

View File

@ -303,9 +303,6 @@ let movingUIPresets = [];
export let context_presets = []; export let context_presets = [];
const storage_keys = { const storage_keys = {
auto_connect_legacy: 'AutoConnectEnabled',
auto_load_chat_legacy: 'AutoLoadChatEnabled',
storyStringValidationCache: 'StoryStringValidationCache', storyStringValidationCache: 'StoryStringValidationCache',
}; };
@ -1429,20 +1426,6 @@ async function loadPowerUserSettings(settings, data) {
context_presets = data.context; context_presets = data.context;
} }
// These are still local storage. Delete in 1.12.7
const autoLoadChat = localStorage.getItem(storage_keys.auto_load_chat_legacy);
const autoConnect = localStorage.getItem(storage_keys.auto_connect_legacy);
if (autoLoadChat) {
power_user.auto_load_chat = autoLoadChat === 'true';
localStorage.removeItem(storage_keys.auto_load_chat_legacy);
}
if (autoConnect) {
power_user.auto_connect = autoConnect === 'true';
localStorage.removeItem(storage_keys.auto_connect_legacy);
}
if (power_user.chat_display === '') { if (power_user.chat_display === '') {
power_user.chat_display = chat_styles.DEFAULT; power_user.chat_display = chat_styles.DEFAULT;
} }

View File

@ -183,7 +183,6 @@ const settings = {
aphrodite_model: '', aphrodite_model: '',
dreamgen_model: 'opus-v1-xl/text', dreamgen_model: 'opus-v1-xl/text',
tabby_model: '', tabby_model: '',
legacy_api: false,
sampler_order: KOBOLDCPP_ORDER, sampler_order: KOBOLDCPP_ORDER,
logit_bias: [], logit_bias: [],
n: 1, n: 1,
@ -252,7 +251,6 @@ export const setting_names = [
'grammar_string', 'grammar_string',
'json_schema', 'json_schema',
'banned_tokens', 'banned_tokens',
'legacy_api',
'ignore_eos_token', 'ignore_eos_token',
'spaces_between_special_tokens', 'spaces_between_special_tokens',
'speculative_ngram', 'speculative_ngram',
@ -329,22 +327,11 @@ async function selectPreset(name) {
function formatTextGenURL(value) { function formatTextGenURL(value) {
try { try {
const noFormatTypes = [MANCER, TOGETHERAI, INFERMATICAI, DREAMGEN, OPENROUTER]; const noFormatTypes = [MANCER, TOGETHERAI, INFERMATICAI, DREAMGEN, OPENROUTER];
const legacyApiTypes = [OOBA];
if (noFormatTypes.includes(settings.type)) { if (noFormatTypes.includes(settings.type)) {
return value; return value;
} }
const url = new URL(value); const url = new URL(value);
if (legacyApiTypes.includes(settings.type)) {
if (url.pathname === '/api' && !settings.legacy_api) {
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 });
url.pathname = '';
}
if (!power_user.relaxed_api_urls && settings.legacy_api) {
url.pathname = '/api';
}
}
return url.toString(); return url.toString();
} catch { } catch {
// Just using URL as a validation check // Just using URL as a validation check
@ -1185,7 +1172,6 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate,
'banned_strings': banned_strings, 'banned_strings': banned_strings,
'api_type': settings.type, 'api_type': settings.type,
'api_server': getTextGenServer(), 'api_server': getTextGenServer(),
'legacy_api': settings.legacy_api && settings.type === OOBA,
'sampler_order': settings.type === textgen_types.KOBOLDCPP ? settings.sampler_order : undefined, 'sampler_order': settings.type === textgen_types.KOBOLDCPP ? settings.sampler_order : undefined,
'xtc_threshold': settings.xtc_threshold, 'xtc_threshold': settings.xtc_threshold,
'xtc_probability': settings.xtc_probability, 'xtc_probability': settings.xtc_probability,

View File

@ -889,7 +889,6 @@ function getTextgenAPITokenizationParams(str) {
text: str, text: str,
api_type: textgen_settings.type, api_type: textgen_settings.type,
url: getTextGenServer(), url: getTextGenServer(),
legacy_api: textgen_settings.legacy_api && textgen_settings.type === OOBA,
vllm_model: textgen_settings.vllm_model, vllm_model: textgen_settings.vllm_model,
aphrodite_model: textgen_settings.aphrodite_model, aphrodite_model: textgen_settings.aphrodite_model,
}; };

View File

@ -112,41 +112,38 @@ router.post('/status', jsonParser, async function (request, response) {
let url = baseUrl; let url = baseUrl;
let result = ''; let result = '';
if (request.body.legacy_api) {
url += '/v1/model'; switch (apiType) {
} else { case TEXTGEN_TYPES.OOBA:
switch (apiType) { case TEXTGEN_TYPES.VLLM:
case TEXTGEN_TYPES.OOBA: case TEXTGEN_TYPES.APHRODITE:
case TEXTGEN_TYPES.VLLM: case TEXTGEN_TYPES.KOBOLDCPP:
case TEXTGEN_TYPES.APHRODITE: case TEXTGEN_TYPES.LLAMACPP:
case TEXTGEN_TYPES.KOBOLDCPP: case TEXTGEN_TYPES.INFERMATICAI:
case TEXTGEN_TYPES.LLAMACPP: case TEXTGEN_TYPES.OPENROUTER:
case TEXTGEN_TYPES.INFERMATICAI: url += '/v1/models';
case TEXTGEN_TYPES.OPENROUTER: break;
url += '/v1/models'; case TEXTGEN_TYPES.DREAMGEN:
break; url += '/api/openai/v1/models';
case TEXTGEN_TYPES.DREAMGEN: break;
url += '/api/openai/v1/models'; case TEXTGEN_TYPES.MANCER:
break; url += '/oai/v1/models';
case TEXTGEN_TYPES.MANCER: break;
url += '/oai/v1/models'; case TEXTGEN_TYPES.TABBY:
break; url += '/v1/model/list';
case TEXTGEN_TYPES.TABBY: break;
url += '/v1/model/list'; case TEXTGEN_TYPES.TOGETHERAI:
break; url += '/api/models?&info';
case TEXTGEN_TYPES.TOGETHERAI: break;
url += '/api/models?&info'; case TEXTGEN_TYPES.OLLAMA:
break; url += '/api/tags';
case TEXTGEN_TYPES.OLLAMA: break;
url += '/api/tags'; case TEXTGEN_TYPES.FEATHERLESS:
break; url += '/v1/models';
case TEXTGEN_TYPES.FEATHERLESS: break;
url += '/v1/models'; case TEXTGEN_TYPES.HUGGINGFACE:
break; url += '/info';
case TEXTGEN_TYPES.HUGGINGFACE: break;
url += '/info';
break;
}
} }
const modelsReply = await fetch(url, args); const modelsReply = await fetch(url, args);
@ -160,11 +157,6 @@ router.post('/status', jsonParser, async function (request, response) {
/** @type {any} */ /** @type {any} */
let data = await modelsReply.json(); let data = await modelsReply.json();
if (request.body.legacy_api) {
console.log('Legacy API response:', data);
return response.send({ result: data?.result });
}
// Rewrap to OAI-like response // Rewrap to OAI-like response
if (apiType === TEXTGEN_TYPES.TOGETHERAI && Array.isArray(data)) { if (apiType === TEXTGEN_TYPES.TOGETHERAI && Array.isArray(data)) {
data = { data: data.map(x => ({ id: x.name, ...x })) }; data = { data: data.map(x => ({ id: x.name, ...x })) };
@ -259,37 +251,33 @@ router.post('/generate', jsonParser, async function (request, response) {
let url = trimV1(baseUrl); let url = trimV1(baseUrl);
if (request.body.legacy_api) { switch (request.body.api_type) {
url += '/v1/generate'; case TEXTGEN_TYPES.VLLM:
} else { case TEXTGEN_TYPES.FEATHERLESS:
switch (request.body.api_type) { case TEXTGEN_TYPES.APHRODITE:
case TEXTGEN_TYPES.VLLM: case TEXTGEN_TYPES.OOBA:
case TEXTGEN_TYPES.FEATHERLESS: case TEXTGEN_TYPES.TABBY:
case TEXTGEN_TYPES.APHRODITE: case TEXTGEN_TYPES.KOBOLDCPP:
case TEXTGEN_TYPES.OOBA: case TEXTGEN_TYPES.TOGETHERAI:
case TEXTGEN_TYPES.TABBY: case TEXTGEN_TYPES.INFERMATICAI:
case TEXTGEN_TYPES.KOBOLDCPP: case TEXTGEN_TYPES.HUGGINGFACE:
case TEXTGEN_TYPES.TOGETHERAI: url += '/v1/completions';
case TEXTGEN_TYPES.INFERMATICAI: break;
case TEXTGEN_TYPES.HUGGINGFACE: case TEXTGEN_TYPES.DREAMGEN:
url += '/v1/completions'; url += '/api/openai/v1/completions';
break; break;
case TEXTGEN_TYPES.DREAMGEN: case TEXTGEN_TYPES.MANCER:
url += '/api/openai/v1/completions'; url += '/oai/v1/completions';
break; break;
case TEXTGEN_TYPES.MANCER: case TEXTGEN_TYPES.LLAMACPP:
url += '/oai/v1/completions'; url += '/completion';
break; break;
case TEXTGEN_TYPES.LLAMACPP: case TEXTGEN_TYPES.OLLAMA:
url += '/completion'; url += '/api/generate';
break; break;
case TEXTGEN_TYPES.OLLAMA: case TEXTGEN_TYPES.OPENROUTER:
url += '/api/generate'; url += '/v1/chat/completions';
break; break;
case TEXTGEN_TYPES.OPENROUTER:
url += '/v1/chat/completions';
break;
}
} }
const args = { const args = {
@ -370,12 +358,6 @@ router.post('/generate', jsonParser, async function (request, response) {
const data = await completionsReply.json(); const data = await completionsReply.json();
console.log('Endpoint response:', data); console.log('Endpoint response:', data);
// Wrap legacy response to OAI completions format
if (request.body.legacy_api) {
const text = data?.results[0]?.text;
data['choices'] = [{ text }];
}
// Map InfermaticAI response to OAI completions format // Map InfermaticAI response to OAI completions format
if (apiType === TEXTGEN_TYPES.INFERMATICAI) { if (apiType === TEXTGEN_TYPES.INFERMATICAI) {
data['choices'] = (data?.choices || []).map(choice => ({ text: choice?.message?.content || choice.text, logprobs: choice?.logprobs, index: choice?.index })); data['choices'] = (data?.choices || []).map(choice => ({ text: choice?.message?.content || choice.text, logprobs: choice?.logprobs, index: choice?.index }));

View File

@ -942,7 +942,6 @@ router.post('/remote/textgenerationwebui/encode', jsonParser, async function (re
} }
const text = String(request.body.text) || ''; const text = String(request.body.text) || '';
const baseUrl = String(request.body.url); const baseUrl = String(request.body.url);
const legacyApi = Boolean(request.body.legacy_api);
const vllmModel = String(request.body.vllm_model) || ''; const vllmModel = String(request.body.vllm_model) || '';
const aphroditeModel = String(request.body.aphrodite_model) || ''; const aphroditeModel = String(request.body.aphrodite_model) || '';
@ -957,36 +956,31 @@ router.post('/remote/textgenerationwebui/encode', jsonParser, async function (re
// Convert to string + remove trailing slash + /v1 suffix // Convert to string + remove trailing slash + /v1 suffix
let url = String(baseUrl).replace(/\/$/, '').replace(/\/v1$/, ''); let url = String(baseUrl).replace(/\/$/, '').replace(/\/v1$/, '');
if (legacyApi) { switch (request.body.api_type) {
url += '/v1/token-count'; case TEXTGEN_TYPES.TABBY:
args.body = JSON.stringify({ 'prompt': text }); url += '/v1/token/encode';
} else { args.body = JSON.stringify({ 'text': text });
switch (request.body.api_type) { break;
case TEXTGEN_TYPES.TABBY: case TEXTGEN_TYPES.KOBOLDCPP:
url += '/v1/token/encode'; url += '/api/extra/tokencount';
args.body = JSON.stringify({ 'text': text }); args.body = JSON.stringify({ 'prompt': text });
break; break;
case TEXTGEN_TYPES.KOBOLDCPP: case TEXTGEN_TYPES.LLAMACPP:
url += '/api/extra/tokencount'; url += '/tokenize';
args.body = JSON.stringify({ 'prompt': text }); args.body = JSON.stringify({ 'content': text });
break; break;
case TEXTGEN_TYPES.LLAMACPP: case TEXTGEN_TYPES.VLLM:
url += '/tokenize'; url += '/tokenize';
args.body = JSON.stringify({ 'content': text }); args.body = JSON.stringify({ 'model': vllmModel, 'prompt': text });
break; break;
case TEXTGEN_TYPES.VLLM: case TEXTGEN_TYPES.APHRODITE:
url += '/tokenize'; url += '/v1/tokenize';
args.body = JSON.stringify({ 'model': vllmModel, 'prompt': text }); args.body = JSON.stringify({ 'model': aphroditeModel, 'prompt': text });
break; break;
case TEXTGEN_TYPES.APHRODITE: default:
url += '/v1/tokenize'; url += '/v1/internal/encode';
args.body = JSON.stringify({ 'model': aphroditeModel, 'prompt': text }); args.body = JSON.stringify({ 'text': text });
break; break;
default:
url += '/v1/internal/encode';
args.body = JSON.stringify({ 'text': text });
break;
}
} }
const result = await fetch(url, args); const result = await fetch(url, args);
@ -997,8 +991,8 @@ router.post('/remote/textgenerationwebui/encode', jsonParser, async function (re
} }
const data = await result.json(); const data = await result.json();
const count = legacyApi ? data?.results[0]?.tokens : (data?.length ?? data?.count ?? data?.value ?? data?.tokens?.length); const count = (data?.length ?? data?.count ?? data?.value ?? data?.tokens?.length);
const ids = legacyApi ? [] : (data?.tokens ?? data?.ids ?? []); const ids = (data?.tokens ?? data?.ids ?? []);
return response.send({ count, ids }); return response.send({ count, ids });
} catch (error) { } catch (error) {