Fix logit bias with best match tokenizer Fixes #5017
| @@ -24,7 +24,7 @@ import { getActiveManualApiSamplers, loadApiSelectedSamplers, isSamplerManualPri | ||
| 24 | 24 | import { SECRET_KEYS, writeSecret } from './secrets.js'; |
| 25 | 25 | import { getEventSourceStream } from './sse-stream.js'; |
| 26 | 26 | import { getCurrentDreamGenModelTokenizer, getCurrentOpenRouterModelTokenizer, loadAphroditeModels, loadDreamGenModels, loadFeatherlessModels, loadGenericModels, loadInfermaticAIModels, loadLlamaCppModels, loadMancerModels, loadOllamaModels, loadOpenRouterModels, loadTabbyModels, loadTogetherAIModels, loadVllmModels } from './textgen-models.js'; |
| 27 | 27 | import { ENCODE_TOKENIZERS, TEXTGEN_TOKENIZERS, TOKENIZER_SUPPORTED_KEY, getTextTokens, getTokenizerBestMatch, tokenizers } from './tokenizers.js'; |
| 28 | 28 | import { AbortReason } from './util/AbortReason.js'; |
| 29 | 29 | import { getSortableDelay, onlyUnique, arraysEqual, isObject } from './utils.js'; |
| 30 | 30 | |
| @@ -403,6 +403,11 @@ function convertPresets(presets) { | ||
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | function getTokenizerForTokenIds() { |
| 406 | + const bestMatchTokenizer = getTokenizerBestMatch('textgenerationwebui'); | |
| 407 | + if (bestMatchTokenizer === tokenizers.API_TEXTGENERATIONWEBUI) { | |
| 408 | + return tokenizers.API_CURRENT; | |
| 409 | + } | |
| 410 | + | |
| 406 | 411 | if (power_user.tokenizer === tokenizers.API_CURRENT && TEXTGEN_TOKENIZERS.includes(textgenerationwebui_settings.type)) { |
| 407 | 412 | return tokenizers.API_CURRENT; |
| 408 | 413 | } |
| @@ -658,6 +663,9 @@ async function getStatusTextgen() { | ||
| 658 | 663 | return resultCheckStatus(); |
| 659 | 664 | } |
| 660 | 665 | |
| 666 | + // Clear logit bias cache | |
| 667 | + BIAS_CACHE.delete(BIAS_KEY); | |
| 668 | + | |
| 661 | 669 | if ([textgen_types.GENERIC, textgen_types.OOBA].includes(textgenerationwebui_settings.type) && textgenerationwebui_settings.bypass_status_check) { |
| 662 | 670 | setOnlineStatus(t`Status check bypassed`); |
| 663 | 671 | return resultCheckStatus(); |