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:
parent
ba54e3dea0
commit
047c897ead
|
@ -17,14 +17,9 @@ import {
|
|||
getTextGenGenerationData,
|
||||
formatTextGenURL,
|
||||
getTextGenUrlSourceId,
|
||||
isMancer,
|
||||
isAphrodite,
|
||||
isTabby,
|
||||
textgen_types,
|
||||
textgenerationwebui_banned_in_macros,
|
||||
isOoba,
|
||||
MANCER_SERVER,
|
||||
isKoboldCpp,
|
||||
} from './scripts/textgen-settings.js';
|
||||
|
||||
import {
|
||||
|
@ -888,14 +883,17 @@ async function getStatus() {
|
|||
main_api,
|
||||
api_server: endpoint,
|
||||
api_type: textgenerationwebui_settings.type,
|
||||
legacy_api: main_api == 'textgenerationwebui' ? textgenerationwebui_settings.legacy_api && !isMancer() : false,
|
||||
legacy_api: main_api == 'textgenerationwebui' ?
|
||||
textgenerationwebui_settings.legacy_api &&
|
||||
textgenerationwebui_settings.type !== textgen_types.MANCER :
|
||||
false,
|
||||
}),
|
||||
signal: abortStatusCheck.signal,
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (main_api == 'textgenerationwebui' && isMancer()) {
|
||||
if (main_api == 'textgenerationwebui' && textgenerationwebui_settings.type === textgen_types.MANCER) {
|
||||
online_status = textgenerationwebui_settings.mancer_model;
|
||||
loadMancerModels(data?.data);
|
||||
} else {
|
||||
|
@ -943,7 +941,7 @@ export function resultCheckStatus() {
|
|||
|
||||
export function getAPIServerUrl() {
|
||||
if (main_api == 'textgenerationwebui') {
|
||||
if (isMancer()) {
|
||||
if (textgenerationwebui_settings.type === textgen_types.MANCER) {
|
||||
return MANCER_SERVER;
|
||||
}
|
||||
|
||||
|
@ -2847,7 +2845,10 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
|||
return;
|
||||
}
|
||||
|
||||
if (main_api === 'textgenerationwebui' && textgenerationwebui_settings.streaming && textgenerationwebui_settings.legacy_api && !isMancer()) {
|
||||
if (main_api === 'textgenerationwebui' &&
|
||||
textgenerationwebui_settings.streaming &&
|
||||
textgenerationwebui_settings.legacy_api &&
|
||||
textgenerationwebui_settings.type !== textgen_types.MANCER) {
|
||||
toastr.error('Streaming is not supported for the Legacy API. Update Ooba and use --extensions openai to enable streaming.', undefined, { timeOut: 10000, preventDuplicates: true });
|
||||
unblockGeneration();
|
||||
return;
|
||||
|
|
|
@ -34,7 +34,7 @@ import {
|
|||
import { debounce, delay, getStringHash, isValidUrl } from './utils.js';
|
||||
import { chat_completion_sources, oai_settings } from './openai.js';
|
||||
import { getTokenCount } from './tokenizers.js';
|
||||
import { isMancer } from './textgen-settings.js';
|
||||
import { textgen_types, textgenerationwebui_settings } from './textgen-settings.js';
|
||||
|
||||
|
||||
var RPanelPin = document.getElementById('rm_button_panel_pin');
|
||||
|
@ -401,7 +401,7 @@ function RA_autoconnect(PrevApi) {
|
|||
}
|
||||
break;
|
||||
case 'textgenerationwebui':
|
||||
if (isMancer() && secret_state[SECRET_KEYS.MANCER]) {
|
||||
if (textgenerationwebui_settings.type === textgen_types.MANCER && secret_state[SECRET_KEYS.MANCER]) {
|
||||
$('#api_button_textgenerationwebui').trigger('click');
|
||||
}
|
||||
else if (api_server_textgenerationwebui && isValidUrl(api_server_textgenerationwebui)) {
|
||||
|
|
|
@ -162,7 +162,7 @@ async function selectPreset(name) {
|
|||
function formatTextGenURL(value) {
|
||||
try {
|
||||
// Mancer doesn't need any formatting (it's hardcoded)
|
||||
if (isMancer()) {
|
||||
if (textgenerationwebui_settings.type === textgen_types.MANCER) {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -265,7 +265,7 @@ function loadTextGenSettings(data, settings) {
|
|||
$('#textgen_type').val(textgenerationwebui_settings.type);
|
||||
showTypeSpecificControls(textgenerationwebui_settings.type);
|
||||
//this is needed because showTypeSpecificControls() does not handle NOT declarations
|
||||
if (isAphrodite()) {
|
||||
if (textgenerationwebui_settings.type === textgen_types.APHRODITE) {
|
||||
$('[data-forAphro=False]').each(function () {
|
||||
$(this).hide();
|
||||
});
|
||||
|
@ -285,26 +285,6 @@ function loadTextGenSettings(data, settings) {
|
|||
});
|
||||
}
|
||||
|
||||
export function isMancer() {
|
||||
return textgenerationwebui_settings.type === textgen_types.MANCER;
|
||||
}
|
||||
|
||||
export function isAphrodite() {
|
||||
return textgenerationwebui_settings.type === textgen_types.APHRODITE;
|
||||
}
|
||||
|
||||
export function isTabby() {
|
||||
return textgenerationwebui_settings.type === textgen_types.TABBY;
|
||||
}
|
||||
|
||||
export function isOoba() {
|
||||
return textgenerationwebui_settings.type === textgen_types.OOBA;
|
||||
}
|
||||
|
||||
export function isKoboldCpp() {
|
||||
return textgenerationwebui_settings.type === textgen_types.KOBOLDCPP;
|
||||
}
|
||||
|
||||
export function getTextGenUrlSourceId() {
|
||||
switch (textgenerationwebui_settings.type) {
|
||||
case textgen_types.OOBA:
|
||||
|
@ -357,7 +337,7 @@ jQuery(function () {
|
|||
const type = String($(this).val());
|
||||
textgenerationwebui_settings.type = type;
|
||||
|
||||
if (isAphrodite()) {
|
||||
if (textgenerationwebui_settings.type === textgen_types.APHRODITE) {
|
||||
//this is needed because showTypeSpecificControls() does not handle NOT declarations
|
||||
$('[data-forAphro=False]').each(function () {
|
||||
$(this).hide();
|
||||
|
@ -419,7 +399,9 @@ jQuery(function () {
|
|||
$(`#${id}_counter_textgenerationwebui`).val(value);
|
||||
textgenerationwebui_settings[id] = value;
|
||||
//special handling for aphrodite using -1 as disabled instead of 0
|
||||
if ($(this).attr('id') === 'top_k_textgenerationwebui' && isAphrodite() && value === 0) {
|
||||
if ($(this).attr('id') === 'top_k_textgenerationwebui' &&
|
||||
textgenerationwebui_settings.type === textgen_types.APHRODITE &&
|
||||
value === 0) {
|
||||
textgenerationwebui_settings[id] = -1;
|
||||
$(this).val(-1);
|
||||
}
|
||||
|
@ -575,11 +557,11 @@ function toIntArray(string) {
|
|||
}
|
||||
|
||||
function getModel() {
|
||||
if (isMancer()) {
|
||||
if (textgenerationwebui_settings.type === textgen_types.MANCER) {
|
||||
return textgenerationwebui_settings.mancer_model;
|
||||
}
|
||||
|
||||
if (isAphrodite()) {
|
||||
if (textgenerationwebui_settings.type === textgen_types.APHRODITE) {
|
||||
return online_status;
|
||||
}
|
||||
|
||||
|
@ -619,11 +601,17 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate,
|
|||
'mirostat_mode': textgenerationwebui_settings.mirostat_mode,
|
||||
'mirostat_tau': textgenerationwebui_settings.mirostat_tau,
|
||||
'mirostat_eta': textgenerationwebui_settings.mirostat_eta,
|
||||
'custom_token_bans': isAphrodite() ? toIntArray(getCustomTokenBans()) : getCustomTokenBans(),
|
||||
'custom_token_bans': textgenerationwebui_settings.type === textgen_types.APHRODITE ?
|
||||
toIntArray(getCustomTokenBans()) :
|
||||
getCustomTokenBans(),
|
||||
'api_type': textgenerationwebui_settings.type,
|
||||
'api_server': isMancer() ? MANCER_SERVER : api_server_textgenerationwebui,
|
||||
'legacy_api': textgenerationwebui_settings.legacy_api && !isMancer(),
|
||||
'sampler_order': isKoboldCpp() ? textgenerationwebui_settings.sampler_order : undefined,
|
||||
'api_server': textgenerationwebui_settings.type === textgen_types.MANCER ?
|
||||
MANCER_SERVER :
|
||||
api_server_textgenerationwebui,
|
||||
'legacy_api': textgenerationwebui_settings.legacy_api && textgenerationwebui_settings.type !== textgen_types.MANCER,
|
||||
'sampler_order': textgenerationwebui_settings.type === textgen_types.KOBOLDCPP ?
|
||||
textgenerationwebui_settings.sampler_order :
|
||||
undefined,
|
||||
};
|
||||
let aphroditeExclusionFlags = {
|
||||
'repetition_penalty_range': textgenerationwebui_settings.rep_pen_range,
|
||||
|
@ -646,7 +634,7 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate,
|
|||
//'logprobs': textgenerationwebui_settings.log_probs_aphrodite,
|
||||
//'prompt_logprobs': textgenerationwebui_settings.prompt_log_probs_aphrodite,
|
||||
};
|
||||
if (isAphrodite()) {
|
||||
if (textgenerationwebui_settings.type === textgen_types.APHRODITE) {
|
||||
APIflags = Object.assign(APIflags, aphroditeFlags);
|
||||
} else {
|
||||
APIflags = Object.assign(APIflags, aphroditeExclusionFlags);
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue