#924 Replace Novel Kayra subtier context

This commit is contained in:
Cohee1207 2023-08-12 14:21:05 +03:00
parent 82f6d11795
commit 092846e0bc
2 changed files with 21 additions and 13 deletions

View File

@ -96,7 +96,7 @@ import {
import {
generateNovelWithStreaming,
getNovelGenerationData,
getNovelMaxContextTokens,
getKayraMaxContextTokens,
getNovelTier,
loadNovelPreset,
loadNovelSettings,
@ -3180,20 +3180,19 @@ function getMaxContextSize() {
if (main_api == 'novel') {
this_max_context = Number(max_context);
if (nai_settings.model_novel == 'krake-v2' || nai_settings.model_novel == 'euterpe-v2') {
// Krake and Euterpe have a max context of 2048
// Should be used with classic gpt tokenizer for best results
this_max_context = Math.min(max_context, 2048);
}
if (nai_settings.model_novel == 'clio-v1' || nai_settings.model_novel == 'kayra-v1') {
// Clio and Kayra have a max context of 8192
// Should be used with nerdstash / nerdstash_v2 tokenizer for best results
if (nai_settings.model_novel == 'clio-v1') {
this_max_context = Math.min(max_context, 8192);
}
if (nai_settings.model_novel == 'kayra-v1') {
this_max_context = Math.min(max_context, 8192);
const subscriptionLimit = getNovelMaxContextTokens();
if (typeof subscriptionLimit === "number" && this_max_context > subscriptionLimit) {
this_max_context = subscriptionLimit;
console.log(`NovelAI subscription limit reached. Max context size is now ${this_max_context}`);
const subscriptionLimit = getKayraMaxContextTokens();
if (typeof subscriptionLimit === "number" && this_max_context > subscriptionLimit) {
this_max_context = subscriptionLimit;
console.log(`NovelAI subscription limit reached. Max context size is now ${this_max_context}`);
}
}
this_max_context = this_max_context - amount_gen;
@ -5483,7 +5482,7 @@ async function getStatusNovel() {
success: function (data) {
if (data.error != true) {
setNovelData(data);
online_status = `${getNovelTier(data.tier)} (${getNovelMaxContextTokens()} context tokens)`;
online_status = `${getNovelTier(data.tier)}`;
}
resultCheckStatusNovel();
},

View File

@ -47,8 +47,17 @@ export function setNovelData(data) {
novel_data = data;
}
export function getNovelMaxContextTokens() {
return novel_data?.perks?.contextTokens;
export function getKayraMaxContextTokens() {
switch (novel_data?.tier) {
case 1:
return 3072;
case 2:
return 6144;
case 3:
return 8192;
}
return null;
}
function getNovelTier(tier) {