Remove is[API] functions

Just use an equality comparison. It's a bit longer, but only because
"textgenerationwebui_settings" is a long identifier.
This commit is contained in:
valadaptive
2023-12-03 02:55:38 -05:00
parent ba54e3dea0
commit 047c897ead
4 changed files with 39 additions and 45 deletions

View File

@@ -4,7 +4,7 @@ import { chat_completion_sources, model_list, oai_settings } from './openai.js';
import { groups, selected_group } from './group-chats.js';
import { getStringHash } from './utils.js';
import { kai_flags } from './kai-settings.js';
import { isKoboldCpp, isMancer, isOoba, isTabby, textgenerationwebui_settings } from './textgen-settings.js';
import { textgen_types, textgenerationwebui_settings } from './textgen-settings.js';
export const CHARACTERS_PER_TOKEN_RATIO = 3.35;
const TOKENIZER_WARNING_KEY = 'tokenizationWarningShown';
@@ -129,7 +129,10 @@ export function getTokenizerBestMatch(forApi) {
// - Tokenizer haven't reported an error previously
const hasTokenizerError = sessionStorage.getItem(TOKENIZER_WARNING_KEY);
const isConnected = online_status !== 'no_connection';
const isTokenizerSupported = isOoba() || isTabby() || isKoboldCpp();
const isTokenizerSupported =
textgenerationwebui_settings.type === textgen_types.OOBA ||
textgenerationwebui_settings.type === textgen_types.TABBY ||
textgenerationwebui_settings.type === textgen_types.KOBOLDCPP;
if (!hasTokenizerError && isConnected) {
if (forApi === 'kobold' && kai_flags.can_use_tokenization) {
@@ -395,7 +398,9 @@ function getRemoteTokenizationParams(str) {
main_api,
api_type: textgenerationwebui_settings.type,
url: getAPIServerUrl(),
legacy_api: main_api === 'textgenerationwebui' && textgenerationwebui_settings.legacy_api && !isMancer(),
legacy_api: main_api === 'textgenerationwebui' &&
textgenerationwebui_settings.legacy_api &&
textgenerationwebui_settings.type !== textgen_types.MANCER,
};
}