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