Shut tokenization errors if not using ooba Closes #2849
| @@ -211,7 +211,7 @@ import { | ||
| 211 | 211 | selectContextPreset, |
| 212 | 212 | } from './scripts/instruct-mode.js'; |
| 213 | 213 | import { initLocales, t, translate } from './scripts/i18n.js'; |
| 214 | 214 | import { getFriendlyTokenizerName, getTokenCount, getTokenCountAsync, getTokenizerModel, initTokenizers, saveTokenCache, TOKENIZER_SUPPORTED_KEY } from './scripts/tokenizers.js'; |
| 215 | 215 | import { |
| 216 | 216 | user_avatar, |
| 217 | 217 | getUserAvatars, |
| @@ -1216,6 +1216,9 @@ async function getStatusTextgen() { | ||
| 1216 | 1216 | // Determine instruct mode preset |
| 1217 | 1217 | autoSelectInstructPreset(online_status); |
| 1218 | 1218 | |
| 1219 | + const supportsTokenization = response.headers.get('x-supports-tokenization') === 'true'; | |
| 1220 | + supportsTokenization ? sessionStorage.setItem(TOKENIZER_SUPPORTED_KEY, 'true') : sessionStorage.removeItem(TOKENIZER_SUPPORTED_KEY); | |
| 1221 | + | |
| 1219 | 1222 | // We didn't get a 200 status code, but the endpoint has an explanation. Which means it DID connect, but I digress. |
| 1220 | 1223 | if (online_status === 'no_connection' && data.response) { |
| 1221 | 1224 | toastr.error(data.response, 'API Error', { timeOut: 5000, preventDuplicates: true }); |
| @@ -10,7 +10,8 @@ import { getCurrentDreamGenModelTokenizer, getCurrentOpenRouterModelTokenizer, o | ||
| 10 | 10 | const { OOBA, TABBY, KOBOLDCPP, VLLM, APHRODITE, LLAMACPP, OPENROUTER, DREAMGEN } = textgen_types; |
| 11 | 11 | |
| 12 | 12 | export const CHARACTERS_PER_TOKEN_RATIO = 3.35; |
| 13 | 13 | export const TOKENIZER_WARNING_KEY = 'tokenizationWarningShown'; |
| 14 | +export const TOKENIZER_SUPPORTED_KEY = 'tokenizationSupported'; | |
| 14 | 15 | |
| 15 | 16 | export const tokenizers = { |
| 16 | 17 | NONE: 0, |
| @@ -280,8 +281,9 @@ export function getTokenizerBestMatch(forApi) { | ||
| 280 | 281 | // - Kobold must pass a version check |
| 281 | 282 | // - Tokenizer haven't reported an error previously |
| 282 | 283 | const hasTokenizerError = sessionStorage.getItem(TOKENIZER_WARNING_KEY); |
| 284 | + const hasValidEndpoint = sessionStorage.getItem(TOKENIZER_SUPPORTED_KEY); | |
| 283 | 285 | const isConnected = online_status !== 'no_connection'; |
| 284 | 286 | const isTokenizerSupported = TEXTGEN_TOKENIZERS.includes(textgen_settings.type) && (textgen_settings.type !== OOBA || hasValidEndpoint); |
| 285 | 287 | |
| 286 | 288 | if (!hasTokenizerError && isConnected) { |
| 287 | 289 | if (forApi === 'kobold' && kai_flags.can_use_tokenization) { |
| @@ -186,6 +186,7 @@ router.post('/status', jsonParser, async function (request, response) { | ||
| 186 | 186 | |
| 187 | 187 | const modelName = modelInfo?.model_name; |
| 188 | 188 | result = modelName || result; |
| 189 | + response.setHeader('x-supports-tokenization', 'true'); | |
| 189 | 190 | } |
| 190 | 191 | } catch (error) { |
| 191 | 192 | console.error(`Failed to get Ooba model info: ${error}`); |