fixed dry loading seq when not in use, set kcppt to -1 layers by default

This commit is contained in:
Concedo 2024-07-22 15:44:34 +08:00
parent 0ecf13fc13
commit e2b36aa6cf
2 changed files with 44 additions and 28 deletions

View file

@ -2081,14 +2081,20 @@ generation_outputs gpttype_generate(const generation_inputs inputs)
// Parse dry sequence breakers / restart sequences // Parse dry sequence breakers / restart sequences
kcpp_params->dry_sequence_breakers.clear(); kcpp_params->dry_sequence_breakers.clear();
for(int x=0;x<dry_seq_break_max;++x) { dry_sequence_breakers.clear();
if (kcpp_params->dry_multiplier > 0)
{
for (int x = 0; x < dry_seq_break_max; ++x)
{
std::string word = inputs.dry_sequence_breakers[x]; std::string word = inputs.dry_sequence_breakers[x];
if(word!="") { if (word != "")
{
kcpp_params->dry_sequence_breakers.push_back(word); kcpp_params->dry_sequence_breakers.push_back(word);
} }
} }
dry_sequence_breakers.clear(); if (kcpp_params->dry_sequence_breakers.size() > 0)
if(kcpp_params->dry_sequence_breakers.size()>0) { {
// Restrict the maximum length of sequences used as sequence breakers. There are // Restrict the maximum length of sequences used as sequence breakers. There are
// very few use cases for a long sequence breaker, and limiting the max length // very few use cases for a long sequence breaker, and limiting the max length
// prevents a potential denial of service attack in which long repetitive sequence // prevents a potential denial of service attack in which long repetitive sequence
@ -2096,27 +2102,36 @@ generation_outputs gpttype_generate(const generation_inputs inputs)
const int MAX_CHAR_LEN = 40; const int MAX_CHAR_LEN = 40;
const int MAX_SEQ_LEN = 20; const int MAX_SEQ_LEN = 20;
if(debugmode==1) { if (debugmode == 1)
{
printf("\nProcessing %zu dry break strings...", kcpp_params->dry_sequence_breakers.size()); printf("\nProcessing %zu dry break strings...", kcpp_params->dry_sequence_breakers.size());
} }
for (auto sequence_break: kcpp_params->dry_sequence_breakers) { for (auto sequence_break : kcpp_params->dry_sequence_breakers)
if (sequence_break.size() > MAX_CHAR_LEN) { {
if (sequence_break.size() > MAX_CHAR_LEN)
{
sequence_break.resize(MAX_CHAR_LEN); sequence_break.resize(MAX_CHAR_LEN);
} }
GetOverlappingTokenSequences(sequence_break, dry_sequence_breakers, MAX_SEQ_LEN); GetOverlappingTokenSequences(sequence_break, dry_sequence_breakers, MAX_SEQ_LEN);
} }
if(debugmode==1) { if (debugmode == 1)
{
int trivial = 0, non_trivial = 0; int trivial = 0, non_trivial = 0;
for (const auto& seq: dry_sequence_breakers) { for (const auto &seq : dry_sequence_breakers)
if (seq.second.empty()) { {
if (seq.second.empty())
{
++trivial; ++trivial;
} else { }
else
{
++non_trivial; ++non_trivial;
} }
} }
printf("\nFound a total of %zu restart heads, %d trivial, %d non-trivial.\n", dry_sequence_breakers.size(), trivial, non_trivial); printf("\nFound a total of %zu restart heads, %d trivial, %d non-trivial.\n", dry_sequence_breakers.size(), trivial, non_trivial);
} }
} }
}
bool stream_sse = inputs.stream_sse; bool stream_sse = inputs.stream_sse;

View file

@ -2742,6 +2742,7 @@ def show_gui():
savdict = json.loads(json.dumps(args.__dict__)) savdict = json.loads(json.dumps(args.__dict__))
file_type = [("KoboldCpp LaunchTemplate", "*.kcppt")] file_type = [("KoboldCpp LaunchTemplate", "*.kcppt")]
savdict["istemplate"] = True savdict["istemplate"] = True
savdict["gpulayers"] = -1
filename = asksaveasfile(filetypes=file_type, defaultextension=file_type) filename = asksaveasfile(filetypes=file_type, defaultextension=file_type)
if filename == None: return if filename == None: return
file = open(str(filename.name), 'a') file = open(str(filename.name), 'a')