@@ -6,7 +6,7 @@ It requires no dependencies, installation or setup.
6
6
Just copy this single static HTML file anywhere and open it in a browser, or from a webserver.
7
7
Please go to https://github.com/LostRuins/lite.koboldai.net for updates on Kobold Lite.
8
8
Kobold Lite is under the AGPL v3.0 License unless otherwise exempted. Please do not remove this line.
9
- Current version: 101
9
+ Current version: 102
10
10
-Concedo
11
11
-->
12
12
@@ -316,6 +316,11 @@ Current version: 101
316
316
width: 94px;
317
317
padding: 6px 3px;
318
318
}
319
+ .stopseqbox
320
+ {
321
+ display: inline;
322
+ width: calc(100% - 110px);
323
+ }
319
324
320
325
#popuptitlebar {
321
326
padding: 10px;
@@ -3294,6 +3299,7 @@ Current version: 101
3294
3299
var globalabortcontroller = null;
3295
3300
var passed_ai_warning_local = false;
3296
3301
var welcome = "";
3302
+ var logitbiasdict = {};
3297
3303
3298
3304
var localsettings = {
3299
3305
my_api_key: "0000000000", //put here so it can be saved and loaded in persistent mode
@@ -4531,6 +4537,7 @@ Current version: 101
4531
4537
new_save_storyobj.anotestr = anote_strength;
4532
4538
new_save_storyobj.wisearchdepth = wi_searchdepth;
4533
4539
new_save_storyobj.wiinsertlocation = wi_insertlocation;
4540
+ new_save_storyobj.logitbiasdict = JSON.parse(JSON.stringify(logitbiasdict));
4534
4541
4535
4542
if (export_settings) {
4536
4543
new_save_storyobj.savedsettings = JSON.parse(JSON.stringify(localsettings));
@@ -4746,6 +4753,9 @@ Current version: 101
4746
4753
if (storyobj.anotestr) {
4747
4754
anote_strength = storyobj.anotestr;
4748
4755
}
4756
+ if (storyobj.logitbiasdict) {
4757
+ logitbiasdict = storyobj.logitbiasdict;
4758
+ }
4749
4759
if (storyobj.wisearchdepth) {
4750
4760
wi_searchdepth = storyobj.wisearchdepth;
4751
4761
}
@@ -5885,6 +5895,27 @@ Current version: 101
5885
5895
},false,true);
5886
5896
}
5887
5897
5898
+ var pendinglogitbias = {};
5899
+ function set_logit_bias()
5900
+ {
5901
+ inputBox("Enter OpenAI-formatted logit bias dictionary. Each key is the integer token IDs and their values are the biases (-100.0 to 100.0)<br><a href='https://platform.openai.com/docs/api-reference/chat/create#chat-create-logit_bias' class='color_blueurl'>Input is a JSON object, reference here.</a><br>Leave blank to disable.<br>","Set Logit Biases",JSON.stringify(pendinglogitbias),"Enter JSON Object",()=>{
5902
+ let userinput = getInputBoxValue().trim();
5903
+ if(userinput=="")
5904
+ {
5905
+ pendinglogitbias = {};
5906
+ }
5907
+ else
5908
+ {
5909
+ try {
5910
+ pendinglogitbias = JSON.parse(userinput);
5911
+ } catch (e) {
5912
+ msgbox("Your logit bias JSON dictionary was not correctly formatted!");
5913
+ }
5914
+ }
5915
+
5916
+ },true,true);
5917
+ }
5918
+
5888
5919
var msgboxOnDone = hide_msgbox;
5889
5920
function hide_msgbox() {
5890
5921
//hide msgbox ONLY
@@ -7660,6 +7691,7 @@ Current version: 101
7660
7691
anote_strength = document.getElementById("anote_strength").value;
7661
7692
extrastopseq = document.getElementById("extrastopseq").value;
7662
7693
newlineaftermemory = (document.getElementById("newlineaftermemory").checked?true:false);
7694
+ logitbiasdict = pendinglogitbias;
7663
7695
hide_popups();
7664
7696
render_gametext();
7665
7697
}
@@ -7714,20 +7746,6 @@ Current version: 101
7714
7746
submit_payload.params.sampler_seed = localsettings.sampler_seed;
7715
7747
}
7716
7748
7717
- if((custom_kobold_endpoint != "" && is_using_kcpp_with_mirostat()))
7718
- {
7719
- if(localsettings.miro_type>0)
7720
- {
7721
- submit_payload.params.mirostat = localsettings.miro_type;
7722
- submit_payload.params.mirostat_tau = localsettings.miro_tau;
7723
- submit_payload.params.mirostat_eta = localsettings.miro_eta;
7724
- }
7725
-
7726
- //also supports min_p, in that it wont crash, so add it on. it will be ignored if not found
7727
- submit_payload.params.min_p = localsettings.min_p;
7728
- submit_payload.params.presence_penalty = localsettings.presence_penalty;
7729
- }
7730
-
7731
7749
//v2 api specific fields
7732
7750
submit_payload.workers = selected_workers.map((m) => { return m.id });
7733
7751
@@ -7835,6 +7853,7 @@ Current version: 101
7835
7853
current_wi = [];
7836
7854
extrastopseq = "";
7837
7855
anote_strength = 320;
7856
+ logitbiasdict = {};
7838
7857
wi_searchdepth = 0;
7839
7858
wi_insertlocation = 0;
7840
7859
current_anotetemplate = "[Author's note: <|>]";
@@ -8581,20 +8600,6 @@ Current version: 101
8581
8600
submit_payload.params.sampler_seed = localsettings.sampler_seed;
8582
8601
}
8583
8602
8584
- if((custom_kobold_endpoint != "" && is_using_kcpp_with_mirostat()))
8585
- {
8586
- if(localsettings.miro_type>0)
8587
- {
8588
- submit_payload.params.mirostat = localsettings.miro_type;
8589
- submit_payload.params.mirostat_tau = localsettings.miro_tau;
8590
- submit_payload.params.mirostat_eta = localsettings.miro_eta;
8591
- }
8592
-
8593
- //also supports min_p, in that it wont crash, so add it on. it will be ignored if not found
8594
- submit_payload.params.min_p = localsettings.min_p;
8595
- submit_payload.params.presence_penalty = localsettings.presence_penalty;
8596
- }
8597
-
8598
8603
if((custom_kobold_endpoint != "" && is_using_kcpp_with_grammar()))
8599
8604
{
8600
8605
if(localsettings.grammar && localsettings.grammar!="")
@@ -8682,6 +8687,26 @@ Current version: 101
8682
8687
{
8683
8688
console.log(submit_payload);
8684
8689
8690
+ //preprocess to add extra fields
8691
+ if((custom_kobold_endpoint != "" && is_using_kcpp_with_mirostat()))
8692
+ {
8693
+ if(localsettings.miro_type>0)
8694
+ {
8695
+ submit_payload.params.mirostat = localsettings.miro_type;
8696
+ submit_payload.params.mirostat_tau = localsettings.miro_tau;
8697
+ submit_payload.params.mirostat_eta = localsettings.miro_eta;
8698
+ }
8699
+
8700
+ //also supports min_p, in that it wont crash, so add it on. it will be ignored if not found
8701
+ submit_payload.params.min_p = localsettings.min_p;
8702
+ }
8703
+ //presence pen and logit bias for OAI and newer kcpp
8704
+ if((custom_kobold_endpoint != "" && is_using_kcpp_with_mirostat()) || custom_oai_endpoint!="")
8705
+ {
8706
+ submit_payload.params.presence_penalty = localsettings.presence_penalty;
8707
+ submit_payload.params.logit_bias = JSON.parse(JSON.stringify(logitbiasdict));
8708
+ }
8709
+
8685
8710
startTimeTaken(); //timestamp start request
8686
8711
8687
8712
if (is_using_custom_ep()) {
@@ -8736,8 +8761,14 @@ Current version: 101
8736
8761
8737
8762
let targetep = (custom_oai_endpoint + oai_submit_endpoint);
8738
8763
8739
- //original range between 1 and 3, scale to 0 and 2
8740
- let scaled_rep_pen = (submit_payload.params.rep_pen - 1.0);
8764
+ let scaled_rep_pen = 0;
8765
+ if(submit_payload.params.presence_penalty > 0)
8766
+ {
8767
+ scaled_rep_pen = submit_payload.params.presence_penalty;
8768
+ }else{
8769
+ //original range between 1 and 3, scale to 0 and 2
8770
+ scaled_rep_pen = (submit_payload.params.rep_pen - 1.0);
8771
+ }
8741
8772
//logit bias prevents <|endoftext|>
8742
8773
let oai_payload =
8743
8774
{
@@ -8747,6 +8778,10 @@ Current version: 101
8747
8778
"temperature": submit_payload.params.temperature,
8748
8779
"top_p": submit_payload.params.top_p,
8749
8780
}
8781
+ if(submit_payload.params.logit_bias && JSON.stringify(submit_payload.params.logit_bias) != '{}')
8782
+ {
8783
+ oai_payload.logit_bias = submit_payload.params.logit_bias;
8784
+ }
8750
8785
8751
8786
if (document.getElementById("useoaichatcompl").checked) {
8752
8787
targetep = (custom_oai_endpoint + oai_submit_endpoint_turbo);
@@ -8763,7 +8798,12 @@ Current version: 101
8763
8798
}
8764
8799
}
8765
8800
else {
8766
- oai_payload.logit_bias = { "50256": -100 };
8801
+ if(oai_payload.logit_bias)
8802
+ {
8803
+ oai_payload.logit_bias["50256"] = -100;
8804
+ }else{
8805
+ oai_payload.logit_bias = { "50256": -100 };
8806
+ }
8767
8807
oai_payload.prompt = submit_payload.prompt;
8768
8808
}
8769
8809
@@ -10760,6 +10800,7 @@ Current version: 101
10760
10800
document.getElementById("anote_strength").value = anote_strength;
10761
10801
document.getElementById("extrastopseq").value = extrastopseq;
10762
10802
document.getElementById("newlineaftermemory").checked = (newlineaftermemory?true:false);
10803
+ pendinglogitbias = logitbiasdict;
10763
10804
if(custom_kobold_endpoint!="" || !is_using_custom_ep() )
10764
10805
{
10765
10806
document.getElementById("noextrastopseq").classList.add("hidden");
@@ -12612,8 +12653,8 @@ Current version: 101
12612
12653
<div class="justifyleft settinglabel">Extra Stopping Sequences <span class="helpicon">?<span
12613
12654
class="helptext">Triggers the text generator to stop generating early if this sequence appears, in addition to default stop sequences. If you want multiple sequences, separate them with the following delimiter: ||$||</span></span></div>
12614
12655
<div class="color_red hidden" id="noextrastopseq">Stop Sequences may be unavailable.</div>
12615
- <input class="form-control" type="text" placeholder="None" value="" id="extrastopseq">
12616
-
12656
+ <input class="form-control stopseqbox " type="text" placeholder="None" value="" id="extrastopseq">
12657
+ <button type="button" class="btn btn-primary" style="width:104px;padding:6px 6px;margin-bottom: 4px;" id="btnlogitbias" onclick="set_logit_bias()">Logit Biases</button>
12617
12658
<br>
12618
12659
<div class="popupfooter">
12619
12660
<button type="button" class="btn btn-primary" onclick="confirm_memory()">OK</button>
0 commit comments