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

View File

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