This commit is contained in:
Concedo 2025-11-18 18:56:31 +08:00
parent 7aea1d7c02
commit 8631bbcee3
5 changed files with 55 additions and 55 deletions

View file

@ -8976,7 +8976,7 @@ Current version indicated by LITEVER below.
}
});
}
function kai_scenario_load(storyobj) //retain all current settings, but overwrite story and a few key items
{
temp_scenario = {
@ -9009,9 +9009,9 @@ Current version indicated by LITEVER below.
temp_scenario.opmode = storyobj.savedsettings.opmode;
}
if(temp_scenario.opmode==1) //story
{
{
temp_scenario.gui_type = storyobj.savedsettings.gui_type_story?storyobj.savedsettings.gui_type_story:0;
}
}
else if(temp_scenario.opmode==2) //adventure
{
temp_scenario.adventure_context_mod = storyobj.savedsettings.adventure_context_mod?true:false;
@ -9019,11 +9019,11 @@ Current version indicated by LITEVER below.
temp_scenario.gui_type = storyobj.savedsettings.gui_type_adventure?storyobj.savedsettings.gui_type_adventure:0;
}
else if(temp_scenario.opmode==3) //chat
{
temp_scenario.gui_type = storyobj.savedsettings.gui_type_chat?storyobj.savedsettings.gui_type_chat:0;
{
temp_scenario.gui_type = storyobj.savedsettings.gui_type_chat?storyobj.savedsettings.gui_type_chat:0;
}
else if(temp_scenario.opmode==4) //instruct
{
{
temp_scenario.gui_type = storyobj.savedsettings.gui_type_instruct?storyobj.savedsettings.gui_type_instruct:0;
}
@ -10429,7 +10429,7 @@ Current version indicated by LITEVER below.
scenarios += `<button type="button" name="" class="scenarioitem purple btn btn-primary" onclick="hide_popups();document.getElementById('loadfileinput').click()">Load Character Card or JSON File</button>`;
scenarios += `<button type="button" name="" class="scenarioitem purple btn btn-primary" onclick="hide_popups();display_scenariolibrary();">Load or Save Custom Scenario</button>`;
scenarios += `<button type="button" name="" class="scenarioitem purple btn btn-primary" onclick="character_creator()">New Character Creator</button>`;
for(let i=0;i<scenario_sources.length;++i) {
scenarios += `<button type="button" name="" class="scenarioitem purple btn btn-primary" onclick="import_scenario(scenario_sources[${i}])">${scenario_sources[i].name}</button>`
}
@ -11712,9 +11712,9 @@ Current version indicated by LITEVER below.
}
}
function fetch_openrouter_balance()
{
{
let desired_oai_key = document.getElementById("custom_oai_key").value.trim();
let oaiheaders = {};
if(desired_oai_key!="" && desired_oai_key!=dummy_api_key){
oaiheaders["Authorization"] = "Bearer " + desired_oai_key;
@ -12821,7 +12821,7 @@ Current version indicated by LITEVER below.
let slotname = (testslot?`Server Slot `+(lbl)+` - `+tsdesc+``:`Server Slot `+(lbl)+` - [ Empty ]`);
choices += `<option value=${i}${(selectedslot==i)?" selected":""}>${slotname}</option>`;
}
}
}
else if(selectedlocation=="3") //local scenario
{
locationdesc.innerText = "Local Scenario Library stores your story as a Custom Scenario, without any generation settings.\nData is saved to a temporary cache and can be deleted by your browser. To avoid losing data, use the download save button.";
@ -13090,10 +13090,10 @@ Current version indicated by LITEVER below.
}
else
{
import_compressed_story(loadedstorycompressed,false);
import_compressed_story(loadedstorycompressed,false);
last_used_saveslot = slot;
}
if(switch_to_corpo)
{
localsettings.gui_type_chat = 3;
@ -13301,7 +13301,7 @@ Current version indicated by LITEVER below.
let selectedslot = document.getElementById("saveslotselecteddropdown").value;
let selectedlocation = document.getElementById("saveslotlocationdropdown").value;
let islocal = (selectedlocation=="1");
let isscenario = (selectedlocation=="3");
let isscenario = (selectedlocation=="3");
download_from_slot(selectedslot,islocal,isscenario);
}
function delete_from_curr_slot()
@ -14308,7 +14308,7 @@ Current version indicated by LITEVER below.
{
document.body.classList.add(`theme-${i}`);
}
}
}
}
function update_genimg_button_visiblility()
@ -17612,7 +17612,7 @@ Current version indicated by LITEVER below.
pending_context_preinjection += endmatcher;
}
}
if (force_new_turn || ends_with_assistant_tag) {
if (localsettings.inject_timestamps) {
pending_context_preinjection += get_current_timestamp();
@ -18112,7 +18112,7 @@ Current version indicated by LITEVER below.
{
seqs.push(me + "\:");
}
if(localsettings.chatopponent!="")
if(localsettings.chatopponent!="")
{
//NOTE: we do not add our opponents name as a stop sequence IF thinking is forced
//the model just gets too confused and is likely to repeat the tag.
@ -22500,14 +22500,14 @@ Current version indicated by LITEVER below.
}
function classic_delete_turn(idx)
{
{
edit_chunk_save(idx,"",true);
}
function classic_edit_turn(idx)
{
let chatunits = []; //todo: eventually refactor
let currctx = concat_gametext(false, "", "", "", false);
currctx = replace_instruct_placeholders(currctx);
currctx = replace_instruct_placeholders(currctx);
if(localsettings.opmode==3)
{
chatunits = repack_chat_history(currctx);
@ -22527,20 +22527,20 @@ Current version indicated by LITEVER below.
let currmsg = chatunits[idx].msg;
currmsg = stash_image_placeholders(currmsg, false);
inputBoxOkCancel("Quickly edit a previous turn message","Quick Edit Turn",currmsg,"(Delete Turn)",()=>{
let userinput = getInputBoxValue();
edit_chunk_save(idx,userinput,true);
},()=>{
//do nothing on cancel
},true,true);
},true,true);
}
function classic_click_turn(button,idx,toggleopen = true)
{
let incomplete_resp = (synchro_pending_stream != "" || pending_response_id != "");
if (incomplete_resp) { return; }
function handleOutsideClickClassicTurn(event) {
popupMenu.style.display = 'none';
document.removeEventListener('click', handleOutsideClickClassicTurn);
@ -22548,7 +22548,7 @@ Current version indicated by LITEVER below.
const rect = button.getBoundingClientRect();
const popupMenu = document.getElementById('classicturnmenu');
let popcontent = `<button type="button" onclick="classic_edit_turn(${idx})">Edit Turn</button>`;
popcontent += `<button type="button" onclick="classic_delete_turn(${idx})">Delete Turn</button>`;
popcontent += `<button type="button" onclick="">Cancel</button>`;
@ -22843,7 +22843,7 @@ Current version indicated by LITEVER below.
let chatunits = [];
let currctx = concat_gametext(false, "", "", "", false);
currctx = replace_instruct_placeholders(currctx);
currctx = replace_instruct_placeholders(currctx);
if(localsettings.opmode==3)
{
chatunits = repack_chat_history(currctx);
@ -22960,7 +22960,7 @@ Current version indicated by LITEVER below.
let idx = modified_turn;
let chatunits = [];
let currctx = concat_gametext(false, "", "", "", false);
currctx = replace_instruct_placeholders(currctx);
currctx = replace_instruct_placeholders(currctx);
if(localsettings.opmode==3)
{
chatunits = repack_chat_history(currctx);
@ -22977,7 +22977,7 @@ Current version indicated by LITEVER below.
{
chatunits = repack_instruct_history(currctx, allow_blank);
}
let needsave = false;
let existing_msg_compare = stash_image_placeholders(chatunits[idx].msg,false);
@ -23077,7 +23077,7 @@ Current version indicated by LITEVER below.
let textarea = document.getElementById("corpo_edit_inp");
let modified_message = textarea.value;
edit_chunk_save(corpo_editing_turn, modified_message);
}
function corpo_edit_chunk_resend(idx)
{
@ -25052,7 +25052,7 @@ Current version indicated by LITEVER below.
//refactor - repack as turns
let chatunits = [];
input = replace_instruct_placeholders(input);
input = replace_instruct_placeholders(input);
if(localsettings.opmode==3) //chat mode
{
chatunits = repack_chat_history(input);
@ -27848,8 +27848,8 @@ Current version indicated by LITEVER below.
<button type="button" style="font-size:12px; margin:2px; padding-left:2px; padding-right:2px; width:33%" name="localsave" class="btn btn-primary" onclick="hide_popups();save_file_button()">💾<br>Download Save</button>
<button type="button" style="font-size:12px; margin:2px; padding-left:2px; padding-right:2px; width:33%" name="localload" class="btn btn-primary" onclick="hide_popups();load_file_button()">📁<br>Open File</button>
<button type="button" style="font-size:12px; margin:2px; padding-left:2px; padding-right:2px; width:34%" name="shareurl" class="btn btn-primary" onclick="hide_popups();share_story_button()">🌐<br>Share</button>
</div>
</div>
<div style="margin-top:3px; text-align: center; align-self: center; width: 100%">
<span style="font-weight:bold;text-decoration: underline;">Slot Storage Option</span>
<span style="float:right; text-align: right;">

View file

@ -208,7 +208,7 @@ static ggml_cuda_device_info ggml_cuda_init() {
//#else
// GGML_LOG_INFO("%s: GGML_CUDA_FORCE_CUBLAS: no\n", __func__);
//#endif // GGML_CUDA_FORCE_CUBLAS
GGML_LOG_INFO("%s: found %d " GGML_CUDA_NAME " devices:\n", __func__, info.device_count);
std::vector<std::pair<int, std::string>> turing_devices_without_mma;

View file

@ -1525,7 +1525,7 @@ void sample_entropy(llama_token_data_array * cur_p, float min_temp, float max_te
// Only apply smoothing if smoothing_factor is > 0. Do not change base implementation otherwise.
if (smoothing_factor > 0 && cur_p->size > 1) {
sample_softmax(cur_p);
float h = cur_p->data[0].logit; // Find the maximum logit for h to be added after the transformation
float h = cur_p->data[0].logit; // Find the maximum logit for h to be added after the transformation
// Apply the modified quadratic transformation using the smoothing_factor and smoothing_curve
for (size_t i = 0; i < cur_p->size; ++i) {
float logit_shifted = cur_p->data[i].logit - h;

View file

@ -2365,7 +2365,7 @@ def is_ipv6_supported():
except Exception:
return False
def format_jinja(messages, tools):
def format_jinja(messages, tools):
try:
def strftime_now(format='%Y-%m-%d %H:%M:%S'):
return datetime.now().strftime(format)
@ -2389,7 +2389,7 @@ def format_jinja(messages, tools):
def remove_outer_tags(inputstr):
try:
stripped = inputstr.strip()
stripped = inputstr.strip()
match = re.match(r'^<([^\s<>]+)>(.*?)</\1>\s*$', stripped, re.DOTALL) # Try angle brackets first
if match:
return match.group(2).strip()
@ -2399,10 +2399,10 @@ def remove_outer_tags(inputstr):
return stripped # If no match, return original string
except Exception:
return stripped
def normalize_tool_call(obj): # Normalize various tool call formats to OpenAI format
def normalize_tool_call(obj): # Normalize various tool call formats to OpenAI format
if "type" in obj and "function" in obj: # Already in OpenAI format
return obj
return obj
if "name" in obj and ("arguments" in obj or "parameters" in obj):
args = obj.get("arguments", obj.get("parameters", {}))
return {
@ -2422,13 +2422,13 @@ def normalize_tool_call(obj): # Normalize various tool call formats to OpenAI fo
"arguments": func.get("arguments", func.get("parameters", {}))
}
}
return obj
# Used to parse json for openai tool calls
def extract_json_from_string(input_string):
parsed_json = None
input_string = remove_outer_tags(input_string) #if we detected wrapper tags, remove them
input_string = remove_outer_tags(input_string) #if we detected wrapper tags, remove them
try: # First check if model exported perfect json
parsed_json = json.loads(input_string)
@ -2740,8 +2740,8 @@ ws ::= | " " | "\n" [ \t]{0,20}
attachedaudid = 0
jinja_output = None
jinjatools = genparams.get('tools', [])
if use_jinja and cached_chat_template:
jinja_output = format_jinja(messages_array,jinjatools)
if use_jinja and cached_chat_template:
jinja_output = format_jinja(messages_array,jinjatools)
if jinja_output:
messages_string = jinja_output
if jinjatools and len(jinjatools)>0:
@ -2825,7 +2825,7 @@ ws ::= | " " | "\n" [ \t]{0,20}
elif message['role'] == "tool":
messages_string += tools_message_end
messages_string += assistant_message_gen
genparams["prompt"] = messages_string
if len(images_added)>0:
genparams["images"] = images_added
@ -3499,7 +3499,7 @@ Change Mode<br>
response_body = embedded_kailite
else:
response_body = (f"Embedded KoboldAI Lite is not found.<br>You will have to connect via the main KoboldAI client, or <a href='https://lite.koboldai.net?local=1&port={self.port}'>use this URL</a> to connect.").encode()
elif self.path in ["/noscript", "/noscript?"] or self.path.startswith(('/noscript?','noscript?')): #it's possible for the root url to have ?params without /
self.noscript_webui()
@ -3702,7 +3702,7 @@ Change Mode<br>
elif self.path.endswith(('/.well-known/serviceinfo')):
response_body = (json.dumps({"version":"0.2","software":{"name":"KoboldCpp","version":KcppVersion,"repository":"https://github.com/LostRuins/koboldcpp","homepage":"https://github.com/LostRuins/koboldcpp","logo":"https://raw.githubusercontent.com/LostRuins/koboldcpp/refs/heads/concedo/niko.ico"},"api":{"koboldai":{"name":"KoboldAI API","rel_url":"/api","documentation":"https://lite.koboldai.net/koboldcpp_api","version":KcppVersion},"openai":{"name":"OpenAI API","rel_url ":"/v1","documentation":"https://openai.com/documentation/api","version":KcppVersion}}}).encode())
elif self.path=="/props":
elif self.path=="/props":
response_body = (json.dumps({
"chat_template": cached_chat_template,
"id": 0,
@ -3734,16 +3734,16 @@ Change Mode<br>
response_body = embedded_kcpp_docs
else:
response_body = ("KoboldCpp API is running!\n\nAPI usage reference can be found at the wiki: https://github.com/LostRuins/koboldcpp/wiki").encode()
elif self.path=="/lcpp":
content_type = 'text/html'
# IMPORTANT: svelte needs a patch to accept this as a non-redirect path. Search for `r.pathname === e + "/index.html"` and add desired path there.
if supports_gzip and embedded_lcpp_ui_gz is not None:
response_body = embedded_lcpp_ui_gz
content_encoding = 'gzip'
content_encoding = 'gzip'
else:
response_body = ("Llama.cpp UI is not available. Please use the KoboldAI Lite UI instead.").encode()
elif self.path.startswith(("/sdui")):
content_type = 'text/html'
if supports_gzip and embedded_kcpp_sdui_gz is not None:
@ -3752,7 +3752,7 @@ Change Mode<br>
elif embedded_kcpp_sdui is not None:
response_body = embedded_kcpp_sdui
else:
response_body = ("KoboldCpp API is running, but KCPP SDUI is not loaded").encode()
response_body = ("KoboldCpp API is running, but KCPP SDUI is not loaded").encode()
elif self.path=="/v1":
content_type = 'text/html'
@ -4389,14 +4389,14 @@ Change Mode<br>
try:
toolsdata_res = gendat['choices'][0]['message']['tool_calls']
if toolsdata_res and len(toolsdata_res)>0:
toolsdata_res[0]["index"] = 0 # need to add an index for OWUI
toolsdata_res[0]["index"] = 0 # need to add an index for OWUI
except Exception:
toolsdata_res = []
try:
content_text = gendat['choices'][0]['message'].get('content', None)
except Exception:
content_text = None
# Send role chunk first
chunk_role = json.dumps({
"id": "koboldcpp",
@ -5722,13 +5722,13 @@ def show_gui():
quantkv_var.trace_add("write", toggleflashattn)
makecheckbox(tokens_tab, "No BOS Token", nobostoken_var, 43, tooltiptxt="Prevents BOS token from being added at the start of any prompt. Usually NOT recommended for most models.")
makecheckbox(tokens_tab, "Enable Guidance", enableguidance_var, 43,padx=(200 if corrupt_scaler else 140), tooltiptxt="Enables the use of Classifier-Free-Guidance, which allows the use of negative prompts. Has performance and memory impact.")
def togglejinja(a,b,c):
def togglejinja(a,b,c):
if jinja_var.get()==1:
jinjatoolsbox.grid()
else:
jinja_tools_var.set(0)
jinjatoolsbox.grid_remove()
changed_gpulayers_estimate()
changed_gpulayers_estimate()
makecheckbox(tokens_tab, "Use Jinja", jinja_var, row=45, command=togglejinja, tooltiptxt="Enables using jinja chat template formatting for chat completions endpoint. Other endpoints are unaffected.")
jinjatoolsbox = makecheckbox(tokens_tab, "Jinja for Tools", jinja_tools_var, row=45 ,padx=(200 if corrupt_scaler else 140), tooltiptxt="Allows jinja even with tool calls. If unchecked, jinja will be disabled when tools are used.")
jinja_var.trace_add("write", togglejinja)
@ -5736,7 +5736,7 @@ def show_gui():
makelabelentry(tokens_tab, "MoE CPU Layers:", moecpu_var, row=55, padx=(490 if corrupt_scaler else 320), singleline=True, tooltip="Force Mixture of Experts (MoE) weights of the first N layers to the CPU.\nSetting it higher than GPU layers has no effect.", labelpadx=(300 if corrupt_scaler else 210))
makelabelentry(tokens_tab, "Override KV:", override_kv_var, row=57, padx=(220 if corrupt_scaler else 120), singleline=True, width=150, tooltip="Override metadata value by key. Separate multiple values with commas. Format is name=type:value. Types: int, float, bool, str")
makelabelentry(tokens_tab, "Override Tensors:", override_tensors_var, row=59, padx=(220 if corrupt_scaler else 120), singleline=True, width=150, tooltip="Override selected backend for specific tensors matching tensor_name_regex_pattern=buffer_type, same as in llama.cpp.")
# Model Tab
model_tab = tabcontent["Loaded Files"]
@ -7397,7 +7397,7 @@ def kcpp_main_process(launch_args, g_memory=None, gui_launcher=False):
if isinstance(args.chatcompletionsadapter, str) and os.path.exists(args.chatcompletionsadapter):
ccadapter_path = os.path.abspath(args.chatcompletionsadapter)
elif isinstance(args.chatcompletionsadapter, str) and adapt_dir:
filename = args.chatcompletionsadapter
filename = args.chatcompletionsadapter
if not filename.endswith(".json"):
filename += ".json"
#strip to just the filename
@ -7717,7 +7717,7 @@ def kcpp_main_process(launch_args, g_memory=None, gui_launcher=False):
if not loadok:
exitcounter = 999
exit_with_error(3,"Could not load text model: " + modelname)
# The chat completions adapter is a list that needs derivation from chat templates
# Try to derive chat completions adapter from chat template, now that we have the model loaded
if not args.nomodel and args.model_param:

View file

@ -268,7 +268,7 @@ std::string gguf_get_model_arch(const std::string & gguf_filename)
}
}
}
}
}
else if (vocabsiz>=51864 && vocabsiz<=51865)
{
printf("\nWhisper model detected - you should load it as a whisper model instead, not a text model!\n");