@@ -760,6 +760,10 @@ Current version indicated by LITEVER below.
760760 }
761761 }
762762
763+ #chat_msg_body {
764+ padding-bottom: 1.5rem;
765+ }
766+
763767
764768 /* Viewports */
765769 #maineditbody
@@ -4550,6 +4554,7 @@ Current version indicated by LITEVER below.
45504554 adaptivep_target: -1.0,
45514555 adaptivep_decay: 0.9,
45524556 sampler_order: [6, 0, 1, 3, 4, 2, 5],
4557+ custom_sampler_fields: {},
45534558 };
45544559
45554560 const defaultsettings = JSON.parse(JSON.stringify(localsettings));
@@ -12813,6 +12818,30 @@ Current version indicated by LITEVER below.
1281312818 document.getElementById("secondepsamplecontainer").classList.remove("hidden");
1281412819 }
1281512820
12821+ var pendingcustomfieldssampler = {};
12822+ function show_customfields_sampler()
12823+ {
12824+ inputBoxOkCancel("Insert JSON object containing custom fields to send. These values will be added to every generation payload.","Extra Custom Fields",JSON.stringify(pendingcustomfieldssampler),"Paste JSON Here",()=>{
12825+ let userinput = getInputBoxValue().trim();
12826+ try
12827+ {
12828+ pendingcustomfieldssampler = {};
12829+ if(userinput!="")
12830+ {
12831+ pendingcustomfieldssampler = JSON.parse(userinput);
12832+ }
12833+ document.getElementById("custom_field_overview").innerText = (pendingcustomfieldssampler && Object.keys(pendingcustomfieldssampler).length>0)?(`${Object.keys(pendingcustomfieldssampler).length} items`):"OFF";
12834+ sampler_setting_tweaked();
12835+ } catch (e) {
12836+ console.log("Custom fields incorrectly formatted: "+e);
12837+ }
12838+
12839+ },
12840+ ()=>{
12841+ //do nothing on cancel
12842+ },false,true);
12843+ }
12844+
1281612845 function explain_horde()
1281712846 {
1281812847 msgbox("The AI Horde generates text using crowdsourced GPUs by volunteer workers. By default your inputs are not logged, but as Horde workers are open source, they can be modified to do so. <br><br>In all cases, the sender will *always be anonymous*, however you are still advised to avoid sending privacy sensitive information.<br>","Disclaimer",true);
@@ -15797,6 +15826,7 @@ Current version indicated by LITEVER below.
1579715826 document.getElementById("nsigma").value = localsettings.nsigma;
1579815827 document.getElementById("dynatemp_overview").innerText = (localsettings.dynatemp_range!=0?"ON":"OFF");
1579915828 document.getElementById("second_ep_overview").innerText = (localsettings.second_ep_qty>0 && localsettings.second_ep_url?"ON":"OFF");
15829+ document.getElementById("custom_field_overview").innerText = (localsettings.custom_sampler_fields && Object.keys(localsettings.custom_sampler_fields).length>0)?(`${Object.keys(localsettings.custom_sampler_fields).length} items`):"OFF";
1580015830 document.getElementById("presence_penalty").value = localsettings.presence_penalty;
1580115831 document.getElementById("sampler_seed").value = localsettings.sampler_seed;
1580215832 document.getElementById("top_k").value = document.getElementById("top_k_slide").value = localsettings.top_k;
@@ -15934,6 +15964,7 @@ Current version indicated by LITEVER below.
1593415964 document.getElementById("imagestyleinput").value = localsettings.image_styles;
1593515965 document.getElementById("negpromptinput").value = localsettings.image_negprompt;
1593615966 pendinggrammar = localsettings.grammar;
15967+ pendingcustomfieldssampler = JSON.parse(JSON.stringify(localsettings.custom_sampler_fields));
1593715968
1593815969 //prepare the input for sampler order
1593915970 let samplerstr = localsettings.sampler_order.toString();
@@ -16138,13 +16169,15 @@ Current version indicated by LITEVER below.
1613816169 document.getElementById("miro_tau").value = found.miro_tau == null? defaultsettings.miro_tau : found.miro_tau;
1613916170 document.getElementById("miro_eta").value = found.miro_eta == null? defaultsettings.miro_eta : found.miro_eta;
1614016171 pendinggrammar = found.grammar == null? defaultsettings.grammar : found.grammar;
16172+ pendingcustomfieldssampler = found.custom_sampler_fields == null? defaultsettings.custom_sampler_fields : found.custom_sampler_fields;
1614116173 document.getElementById("dynatemp_range").value = found.dynatemp_range;
1614216174 document.getElementById("dynatemp_exponent").value = found.dynatemp_exponent;
1614316175 document.getElementById("dynatemp_overview").innerText = (document.getElementById("dynatemp_range").value!=0?"ON":"OFF");
1614416176 document.getElementById("second_ep_qty").value = found.second_ep_qty == null? defaultsettings.second_ep_qty : found.second_ep_qty;
1614516177 document.getElementById("second_ep_model").value = found.second_ep_model == null? defaultsettings.second_ep_model : found.second_ep_model;
1614616178 document.getElementById("second_ep_url").value = found.second_ep_url == null? defaultsettings.second_ep_url : found.second_ep_url;
1614716179 document.getElementById("second_ep_overview").innerText = (document.getElementById("second_ep_qty").value>0 && document.getElementById("second_ep_url").value!=""?"ON":"OFF");
16180+ document.getElementById("custom_field_overview").innerText = (pendingcustomfieldssampler && Object.keys(pendingcustomfieldssampler).length>0)?(`${Object.keys(pendingcustomfieldssampler).length} items`):"OFF";
1614816181 } else {
1614916182 document.getElementById("presetsdesc").innerText = "";
1615016183 }
@@ -16281,6 +16314,7 @@ Current version indicated by LITEVER below.
1628116314 miro_tau: parseFloat(document.getElementById("miro_tau").value),
1628216315 miro_eta: parseFloat(document.getElementById("miro_eta").value),
1628316316 grammar: pendinggrammar,
16317+ custom_sampler_fields: pendingcustomfieldssampler,
1628416318 dynatemp_range: parseFloat(document.getElementById("dynatemp_range").value),
1628516319 dynatemp_exponent: parseFloat(document.getElementById("dynatemp_exponent").value),
1628616320 second_ep_qty: document.getElementById("second_ep_qty").value,
@@ -16427,6 +16461,7 @@ Current version indicated by LITEVER below.
1642716461 document.getElementById("adaptivep_decay").value != (found.adaptivep_decay != null ? found.adaptivep_decay : defaultsettings.adaptivep_decay) ||
1642816462 document.getElementById("nsigma").value != found.nsigma ||
1642916463 pendinggrammar != (found.grammar ? found.grammar : defaultsettings.grammar) ||
16464+ JSON.stringify(pendingcustomfieldssampler) != (found.custom_sampler_fields ? JSON.stringify(found.custom_sampler_fields) : JSON.stringify(defaultsettings.custom_sampler_fields)) ||
1643016465 document.getElementById("dynatemp_range").value != found.dynatemp_range ||
1643116466 document.getElementById("dynatemp_exponent").value != found.dynatemp_exponent ||
1643216467 document.getElementById("second_ep_qty").value != (found.second_ep_qty != null ? found.second_ep_qty : defaultsettings.second_ep_qty) ||
@@ -16847,6 +16882,7 @@ Current version indicated by LITEVER below.
1684716882 localsettings.image_styles = document.getElementById("imagestyleinput").value;
1684816883 localsettings.image_negprompt = document.getElementById("negpromptinput").value;
1684916884 localsettings.grammar = pendinggrammar;
16885+ localsettings.custom_sampler_fields = pendingcustomfieldssampler;
1685016886 localsettings.tokenstreammode = document.getElementById("tokenstreammode").value;
1685116887 localsettings.img_autogen_type = document.getElementById("img_autogen_type").value;
1685216888 localsettings.img_crop = (document.getElementById("img_crop").checked ? true : false);
@@ -17446,6 +17482,8 @@ Current version indicated by LITEVER below.
1744617482 "models": selected_models.map((m) => { return m.name }),
1744717483 };
1744817484
17485+ Object.assign(submit_payload.params, localsettings.custom_sampler_fields);
17486+
1744917487 if (localsettings.sampler_seed >= 1) {
1745017488 submit_payload.params.sampler_seed = localsettings.sampler_seed;
1745117489 }
@@ -17522,6 +17560,8 @@ Current version indicated by LITEVER below.
1752217560 "models": selected_models.map((m) => { return m.name }),
1752317561 };
1752417562
17563+ Object.assign(submit_payload.params, localsettings.custom_sampler_fields);
17564+
1752517565 if(localsettings.sampler_seed>=1)
1752617566 {
1752717567 submit_payload.params.sampler_seed = localsettings.sampler_seed;
@@ -20515,6 +20555,8 @@ Current version indicated by LITEVER below.
2051520555 "models": selected_models.map((m) => { return m.name }),
2051620556 };
2051720557
20558+ Object.assign(submit_payload.params, localsettings.custom_sampler_fields);
20559+
2051820560 if(is_using_kcpp_with_added_memory())
2051920561 {
2052020562 submit_payload.params.memory = truncated_memory;
@@ -21008,6 +21050,16 @@ Current version indicated by LITEVER below.
2100821050 "temperature": submit_payload.params.temperature,
2100921051 "top_p": submit_payload.params.top_p
2101021052 }
21053+ if(document.getElementById("useoainonstandard").checked)
21054+ {
21055+ //send ALL non standard params
21056+ if(submit_payload.params.sampler_seed>=1)
21057+ {
21058+ oai_payload.seed = submit_payload.params.sampler_seed;
21059+ }
21060+ Object.assign(oai_payload, submit_payload.params);
21061+ }
21062+ Object.assign(oai_payload, localsettings.custom_sampler_fields);
2101121063 if(localsettings.request_logprobs && !targetep.toLowerCase().includes("api.x.ai") && !targetep.toLowerCase().includes("api.mistral.ai"))
2101221064 {
2101321065 if(document.getElementById("useoaichatcompl").checked || targetep.toLowerCase().includes("api.x.ai"))
@@ -21034,18 +21086,10 @@ Current version indicated by LITEVER below.
2103421086 if(!targetep.toLowerCase().includes("pollinations.ai") && !targetep.toLowerCase().includes("api.mistral.ai") && !targetep.toLowerCase().includes("api.x.ai"))
2103521087 {
2103621088 //mistral api does not support presence pen
21037- oai_payload.presence_penalty = scaled_rep_pen;
21038- }
21039- if(document.getElementById("useoainonstandard").checked)
21040- {
21041- //featherless api supports additional fields, include them
21042- oai_payload.top_k = (submit_payload.params.top_k<1?300:submit_payload.params.top_k);
21043- oai_payload.min_p = localsettings.min_p;
21044- if(submit_payload.params.sampler_seed>=1)
21089+ if(scaled_rep_pen>0)
2104521090 {
21046- oai_payload.seed = submit_payload.params.sampler_seed ;
21091+ oai_payload.presence_penalty = scaled_rep_pen ;
2104721092 }
21048- oai_payload.top_a = localsettings.top_a;
2104921093 }
2105021094 if(submit_payload.params.logit_bias && JSON.stringify(submit_payload.params.logit_bias) != '{}')
2105121095 {
@@ -21312,6 +21356,7 @@ Current version indicated by LITEVER below.
2131221356 "max_tokens": submit_payload.params.max_length,
2131321357 "temperature": submit_payload.params.temperature,
2131421358 };
21359+ Object.assign(claude_payload, localsettings.custom_sampler_fields);
2131521360 claude_payload.messages.push({"role": "user", "content": submit_payload.prompt})
2131621361 if(sysprompt)
2131721362 {
@@ -21528,6 +21573,8 @@ Current version indicated by LITEVER below.
2152821573 }
2152921574 };
2153021575
21576+ Object.assign(payload, localsettings.custom_sampler_fields);
21577+
2153121578 if(document.getElementById("usegeminiweb").checked)
2153221579 {
2153321580 payload["tools"] = [{"google_search": {}}];
@@ -21710,6 +21757,8 @@ Current version indicated by LITEVER below.
2171021757 submit_payload.params.smoothing_factor = localsettings.smoothing_factor;
2171121758 // submit_payload.params.smoothing_curve = localsettings.smoothing_curve; //no idea if horde supports this, dont care to check
2171221759 // submit_payload.params.nsigma = localsettings.nsigma;
21760+
21761+ Object.assign(submit_payload.params, localsettings.custom_sampler_fields);
2171321762 }
2171421763
2171521764 last_request_str = JSON.stringify(submit_payload);
@@ -30130,6 +30179,15 @@ Current version indicated by LITEVER below.
3013030179 </div>
3013130180 </div>
3013230181 </div>
30182+ <div style="display:flex;width:100%;">
30183+ <div class="settinglabel settingcell">
30184+ <div class="justifyleft" style="width:100%">Extra Custom Fields <span class="helpicon">?<span class="helptext">
30185+ Define custom parameters to send along with all generation payloads. Advanced users only.</span></span></div>
30186+ <div class="justifyleft" style="width:100%;">
30187+ <button title="Extra Custom Fields" type="button" class="btn btn-primary" style="padding:2px 4px;font-size:12px;" onclick="show_customfields_sampler()"><span id="custom_field_overview">OFF</span></button>
30188+ </div>
30189+ </div>
30190+ </div>
3013330191 </div>
3013430192 </div>
3013530193 </div>
@@ -31440,7 +31498,7 @@ Current version indicated by LITEVER below.
3144031498 <div><input type="checkbox" id="useoaichatcompl" title="Use ChatCompletions API" onchange="toggleoaichatcompl()">
3144131499 <div class="box-label">Chat-Completions API</div></div>
3144231500 <div><input type="checkbox" id="useoainonstandard" title="Send Non-Standard Fields">
31443- <div class="box-label">Non-Standard Fields <span class="helpicon">?<span class="helptext">Send extra non-standard samplers like Min-P, Top-K and Top-A.</span></span></div></div>
31501+ <div class="box-label">Non-Standard Fields <span class="helpicon">?<span class="helptext">Send all extra non-standard samplers (e.g Min-P, Top-K, Top-A, TFS). May be rejected by many endpoints .</span></span></div></div>
3144431502 </div>
3144531503 <div id="useoaichatcomplbox" class="hidden" onload="toggleoaichatcompl();">
3144631504 <div style="display: inline-block;">
0 commit comments