mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge branch 'staging' into DarokCx/release
This commit is contained in:
@ -39,9 +39,25 @@ export const textgen_types = {
|
||||
DREAMGEN: 'dreamgen',
|
||||
OPENROUTER: 'openrouter',
|
||||
FEATHERLESS: 'featherless',
|
||||
HUGGINGFACE: 'huggingface',
|
||||
};
|
||||
|
||||
const { MANCER, VLLM, APHRODITE, TABBY, TOGETHERAI, OOBA, OLLAMA, LLAMACPP, INFERMATICAI, DREAMGEN, OPENROUTER, KOBOLDCPP, FEATHERLESS } = textgen_types;
|
||||
const {
|
||||
MANCER,
|
||||
VLLM,
|
||||
APHRODITE,
|
||||
TABBY,
|
||||
TOGETHERAI,
|
||||
OOBA,
|
||||
OLLAMA,
|
||||
LLAMACPP,
|
||||
INFERMATICAI,
|
||||
DREAMGEN,
|
||||
OPENROUTER,
|
||||
KOBOLDCPP,
|
||||
HUGGINGFACE,
|
||||
FEATHERLESS,
|
||||
} = textgen_types;
|
||||
|
||||
const LLAMACPP_DEFAULT_ORDER = [
|
||||
'top_k',
|
||||
@ -86,7 +102,7 @@ const SERVER_INPUTS = {
|
||||
[textgen_types.KOBOLDCPP]: '#koboldcpp_api_url_text',
|
||||
[textgen_types.LLAMACPP]: '#llamacpp_api_url_text',
|
||||
[textgen_types.OLLAMA]: '#ollama_api_url_text',
|
||||
[textgen_types.FEATHERLESS]: '#featherless_api_url_text',
|
||||
[textgen_types.HUGGINGFACE]: '#huggingface_api_url_text',
|
||||
};
|
||||
|
||||
const KOBOLDCPP_ORDER = [6, 0, 1, 3, 4, 2, 5];
|
||||
@ -866,7 +882,7 @@ async function generateTextGenWithStreaming(generate_data, signal) {
|
||||
|
||||
return async function* streamData() {
|
||||
let text = '';
|
||||
/** @type {import('logprobs.js').TokenLogprobs | null} */
|
||||
/** @type {import('./logprobs.js').TokenLogprobs | null} */
|
||||
let logprobs = null;
|
||||
const swipes = [];
|
||||
while (true) {
|
||||
@ -898,7 +914,7 @@ async function generateTextGenWithStreaming(generate_data, signal) {
|
||||
* Probabilities feature.
|
||||
* @param {string} token - the text of the token that the logprobs are for
|
||||
* @param {Object} logprobs - logprobs object returned from the API
|
||||
* @returns {import('logprobs.js').TokenLogprobs | null} - converted logprobs
|
||||
* @returns {import('./logprobs.js').TokenLogprobs | null} - converted logprobs
|
||||
*/
|
||||
export function parseTextgenLogprobs(token, logprobs) {
|
||||
if (!logprobs) {
|
||||
@ -910,6 +926,7 @@ export function parseTextgenLogprobs(token, logprobs) {
|
||||
case VLLM:
|
||||
case APHRODITE:
|
||||
case MANCER:
|
||||
case INFERMATICAI:
|
||||
case OOBA: {
|
||||
/** @type {Record<string, number>[]} */
|
||||
const topLogprobs = logprobs.top_logprobs;
|
||||
@ -1015,6 +1032,8 @@ export function getTextGenModel() {
|
||||
return settings.ollama_model;
|
||||
case FEATHERLESS:
|
||||
return settings.featherless_model;
|
||||
case HUGGINGFACE:
|
||||
return 'tgi';
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
@ -1026,6 +1045,14 @@ export function isJsonSchemaSupported() {
|
||||
return [TABBY, LLAMACPP].includes(settings.type) && main_api === 'textgenerationwebui';
|
||||
}
|
||||
|
||||
function getLogprobsNumber() {
|
||||
if (settings.type === VLLM || settings.type === INFERMATICAI) {
|
||||
return 5;
|
||||
}
|
||||
|
||||
return 10;
|
||||
}
|
||||
|
||||
export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate, isContinue, cfgValues, type) {
|
||||
const canMultiSwipe = !isContinue && !isImpersonate && type !== 'quiet';
|
||||
const { banned_tokens, banned_strings } = getCustomTokenBans();
|
||||
@ -1035,7 +1062,7 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate,
|
||||
'model': getTextGenModel(),
|
||||
'max_new_tokens': maxTokens,
|
||||
'max_tokens': maxTokens,
|
||||
'logprobs': power_user.request_token_probabilities ? 10 : undefined,
|
||||
'logprobs': power_user.request_token_probabilities ? getLogprobsNumber() : undefined,
|
||||
'temperature': settings.dynatemp ? (settings.min_temp + settings.max_temp) / 2 : settings.temp,
|
||||
'top_p': settings.top_p,
|
||||
'typical_p': settings.typical_p,
|
||||
@ -1111,6 +1138,8 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate,
|
||||
'tfs_z': settings.tfs,
|
||||
'repeat_last_n': settings.rep_pen_range,
|
||||
'n_predict': maxTokens,
|
||||
'num_predict': maxTokens,
|
||||
'num_ctx': max_context,
|
||||
'mirostat': settings.mirostat_mode,
|
||||
'ignore_eos': settings.ban_eos_token,
|
||||
'n_probs': power_user.request_token_probabilities ? 10 : undefined,
|
||||
@ -1121,7 +1150,7 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate,
|
||||
'best_of': canMultiSwipe ? settings.n : 1,
|
||||
'ignore_eos': settings.ignore_eos_token,
|
||||
'spaces_between_special_tokens': settings.spaces_between_special_tokens,
|
||||
'seed': settings.seed,
|
||||
'seed': settings.seed >= 0 ? settings.seed : undefined,
|
||||
};
|
||||
const aphroditeParams = {
|
||||
'n': canMultiSwipe ? settings.n : 1,
|
||||
@ -1142,6 +1171,12 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate,
|
||||
params.grammar = settings.grammar_string;
|
||||
}
|
||||
|
||||
if (settings.type === HUGGINGFACE) {
|
||||
params.top_p = Math.min(Math.max(Number(params.top_p), 0.0), 0.999);
|
||||
params.stop = Array.isArray(params.stop) ? params.stop.slice(0, 4) : [];
|
||||
nonAphroditeParams.seed = settings.seed >= 0 ? settings.seed : undefined;
|
||||
}
|
||||
|
||||
if (settings.type === MANCER) {
|
||||
params.n = canMultiSwipe ? settings.n : 1;
|
||||
params.epsilon_cutoff /= 1000;
|
||||
@ -1159,6 +1194,7 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate,
|
||||
|
||||
switch (settings.type) {
|
||||
case VLLM:
|
||||
case INFERMATICAI:
|
||||
params = Object.assign(params, vllmParams);
|
||||
break;
|
||||
|
||||
|
Reference in New Issue
Block a user