mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2025-09-10 17:14:36 +00:00
more bugfixes for admin mode
This commit is contained in:
parent
b246d83dca
commit
cf4d0085f6
2 changed files with 59 additions and 37 deletions
31
klite.embd
31
klite.embd
|
@ -12,7 +12,7 @@ Current version indicated by LITEVER below.
|
|||
-->
|
||||
|
||||
<script>
|
||||
const LITEVER = 211;
|
||||
const LITEVER = 212;
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
var localflag = true;
|
||||
const STORAGE_PREFIX = (localflag?"e_":"")+"kaihordewebui_";
|
||||
|
@ -2897,6 +2897,7 @@ Current version indicated by LITEVER below.
|
|||
const AVATAR_PX = 384;
|
||||
const SAVE_SLOTS = 6;
|
||||
const num_regex_rows = 4;
|
||||
const default_websearch_template = `### New Task:\nFrom above text, rephrase the search engine query "{{QUERY}}" as a single short phrase (for search engines) using proper nouns, references and names to avoid ambiguity.\n\n### Rephrased Search Query Created:\n`;
|
||||
|
||||
//all configurable globals
|
||||
var unique_uid = "LITE_UID_"+(Math.floor(100000 + Math.random() * 900000)).toString();
|
||||
|
@ -2938,6 +2939,7 @@ Current version indicated by LITEVER below.
|
|||
var documentdb_data = "";
|
||||
var websearch_enabled = false;
|
||||
var websearch_multipass = false;
|
||||
var websearch_template = "";
|
||||
var generateimagesinterval = 750; //if generated images is enabled, it will trigger after every 700 new characters in context.
|
||||
var nextgeneratedimagemilestone = generateimagesinterval; //used to keep track of when to generate the next image
|
||||
var image_db = {}; //stores a dictionary of pending images
|
||||
|
@ -6362,6 +6364,7 @@ Current version indicated by LITEVER below.
|
|||
new_save_storyobj.documentdb_data = documentdb_data;
|
||||
new_save_storyobj.websearch_enabled = websearch_enabled;
|
||||
new_save_storyobj.websearch_multipass = websearch_multipass;
|
||||
new_save_storyobj.websearch_template = websearch_template;
|
||||
new_save_storyobj.thinking_pattern = thinking_pattern;
|
||||
new_save_storyobj.thinking_action = thinking_action;
|
||||
|
||||
|
@ -6679,6 +6682,10 @@ Current version indicated by LITEVER below.
|
|||
{
|
||||
websearch_multipass = storyobj.websearch_multipass;
|
||||
}
|
||||
if(storyobj.websearch_template)
|
||||
{
|
||||
websearch_template = storyobj.websearch_template;
|
||||
}
|
||||
if(storyobj.thinking_pattern)
|
||||
{
|
||||
thinking_pattern = storyobj.thinking_pattern;
|
||||
|
@ -9930,7 +9937,9 @@ Current version indicated by LITEVER below.
|
|||
.then(values => {
|
||||
let success = (values && values.success);
|
||||
if (success) {
|
||||
msgbox("KoboldCpp is now restarting!\n\nIt may take some time before the new instance is ready to use.", "KoboldCpp Reload Started");
|
||||
msgbox("KoboldCpp is now restarting!\n\nIt may take some time before the new instance is ready to use. Please wait a moment, then press OK to refresh the page.", "KoboldCpp Reload Started", false,false,()=>{
|
||||
location.reload(true);
|
||||
});
|
||||
} else {
|
||||
msgbox("The request to reload KoboldCpp with a new configuration failed!\n\nPlease check if the feature is enabled, the admin directory is set, and selected config and password are correct.", "KoboldCpp Reload Failed");
|
||||
}
|
||||
|
@ -11548,6 +11557,7 @@ Current version indicated by LITEVER below.
|
|||
documentdb_chunksize = cleannum(documentdb_chunksize,32,2048);
|
||||
websearch_enabled = document.getElementById("websearch_enabled").checked?true:false;
|
||||
websearch_multipass = document.getElementById("websearch_multipass").checked?true:false;
|
||||
websearch_template = (document.getElementById("websearch_template").value==default_websearch_template?"":document.getElementById("websearch_template").value);
|
||||
if(validate_regex(thinking_pattern))
|
||||
{
|
||||
thinking_pattern = document.getElementById("thinking_pattern").value;
|
||||
|
@ -11580,7 +11590,8 @@ Current version indicated by LITEVER below.
|
|||
let truncated_context = recentCtx.substring(recentCtx.length - max_allowed_characters);
|
||||
|
||||
truncated_context = replace_placeholders(truncated_context);
|
||||
truncated_context += `\n\n### New Task:\nFrom above text, rephrase the search engine query "${search_query}" as a single short phrase (for search engines) using proper nouns, references and names to avoid ambiguity.\n\n### Rephrased Search Query Created:\n`;
|
||||
let wst = (websearch_template==""?default_websearch_template:websearch_template);
|
||||
truncated_context += "\n\n" + wst.replaceAll('{{QUERY}}', search_query);
|
||||
|
||||
let submit_payload = {
|
||||
"prompt": truncated_context,
|
||||
|
@ -11901,6 +11912,7 @@ Current version indicated by LITEVER below.
|
|||
documentdb_data = "";
|
||||
websearch_enabled = false;
|
||||
websearch_multipass = false;
|
||||
websearch_template = "";
|
||||
thinking_pattern = "<think>([\\s\\S]+?)<\/think>";
|
||||
thinking_action = 1;
|
||||
}
|
||||
|
@ -14419,7 +14431,7 @@ Current version indicated by LITEVER below.
|
|||
}
|
||||
|
||||
let sysinst = document.getElementById("gemini_system_instruction").value;
|
||||
if(sysinst!="" && (mdlname.includes("gemini-1.5-") || mdlname.includes("gemini-exp-")))
|
||||
if(sysinst!="" && (mdlname.includes("gemini-1.5-") || mdlname.includes("gemini-2") || mdlname.includes("gemini-exp-")))
|
||||
{
|
||||
payload["systemInstruction"] = {
|
||||
"role": "system",
|
||||
|
@ -18342,6 +18354,7 @@ Current version indicated by LITEVER below.
|
|||
document.getElementById("documentdb_data").value = documentdb_data;
|
||||
document.getElementById("websearch_enabled").checked = websearch_enabled;
|
||||
document.getElementById("websearch_multipass").checked = websearch_multipass;
|
||||
document.getElementById("websearch_template").value = (websearch_template==""?default_websearch_template:websearch_template);
|
||||
if(is_using_kcpp_with_websearch())
|
||||
{
|
||||
document.getElementById("websearchunsupporteddiv").classList.add("hidden");
|
||||
|
@ -20099,7 +20112,7 @@ Current version indicated by LITEVER below.
|
|||
<div style="overflow: auto;">
|
||||
<div id="saveloadentries" class="menutext saveloadgrid">
|
||||
</div>
|
||||
<div class="menutext"><p style="padding:6px;font-size: 10px;" class="color_red">Caution: Storage Slots are saved to a tempoary cache and can be deleted by your browser. To avoid losing data, use the download file button.</p></div>
|
||||
<div class="menutext"><p style="padding:6px;font-size: 10px;" class="color_red">Caution: Storage Slots are saved to a temporary cache and can be deleted by your browser. To avoid losing data, use the download file button.</p></div>
|
||||
<div class="popupfooter">
|
||||
<button type="button" class="btn btn-primary" id=""
|
||||
onclick="hide_popups()">Back</button>
|
||||
|
@ -20365,6 +20378,8 @@ Current version indicated by LITEVER below.
|
|||
<option value="gemini-1.5-flash-latest">gemini-1.5-flash-latest</option>
|
||||
<option value="gemini-1.5-pro-exp-0801">gemini-1.5-pro-exp-0801</option>
|
||||
<option value="gemini-1.5-pro-exp-0827">gemini-1.5-pro-exp-0827</option>
|
||||
<option value="gemini-2.0-flash">gemini-2.0-flash</option>
|
||||
<option value="gemini-2.0-pro-exp">gemini-2.0-pro-exp</option>
|
||||
<option value="gemini-exp-1114">gemini-exp-1114</option>
|
||||
<option value="gemini-exp-1121">gemini-exp-1121</option>
|
||||
<option value="text-bison-001">text-bison-001</option>
|
||||
|
@ -21577,6 +21592,12 @@ Current version indicated by LITEVER below.
|
|||
class="helptext">Using this option will run a second LLM tool call to summarize context and create a more accurate search query. Slower but may be more accurate.</span></span></div>
|
||||
<input title="Use Multiple Passes" type="checkbox" id="websearch_multipass" style="margin:0px 0 0;">
|
||||
</div>
|
||||
<div class="justifyleft settinglabel">Multipass WebSearch Template <span class="helpicon">?<span
|
||||
class="helptext">The template used to generate the search query when multipass search is used</span></span></div>
|
||||
<div style="display: flex; column-gap: 4px; margin-bottom: 4px;">
|
||||
<textarea title="Multipass WebSearch Template" style="height: 80px;" class="form-control menuinput_multiline" id="websearch_template"
|
||||
placeholder=""></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="context_tab_container" id="token_tab_container">
|
||||
|
|
65
koboldcpp.py
65
koboldcpp.py
|
@ -49,7 +49,6 @@ dry_seq_break_max = 128
|
|||
# global vars
|
||||
KcppVersion = "1.83"
|
||||
showdebug = True
|
||||
guimode = False
|
||||
kcpp_instance = None #global running instance
|
||||
global_memory = None
|
||||
using_gui_launcher = False
|
||||
|
@ -604,10 +603,10 @@ def unpack_to_dir(destpath = ""):
|
|||
messagebox.showwarning("Invalid Selection", "The target folder is not empty or invalid. Please select an empty folder.")
|
||||
|
||||
def exit_with_error(code, message, title="Error"):
|
||||
global guimode
|
||||
global using_gui_launcher
|
||||
print("")
|
||||
time.sleep(1)
|
||||
if guimode:
|
||||
if using_gui_launcher:
|
||||
show_gui_msgbox(title, message)
|
||||
else:
|
||||
print(message, flush=True)
|
||||
|
@ -3092,8 +3091,8 @@ def RunServerMultiThreaded(addr, port, server_handler):
|
|||
|
||||
# note: customtkinter-5.2.0
|
||||
def show_gui():
|
||||
global guimode
|
||||
guimode = True
|
||||
global using_gui_launcher
|
||||
using_gui_launcher = True
|
||||
from tkinter.filedialog import askopenfilename, askdirectory
|
||||
from tkinter.filedialog import asksaveasfile
|
||||
|
||||
|
@ -3182,8 +3181,6 @@ def show_gui():
|
|||
else:
|
||||
root.resizable(True,True)
|
||||
root.bind("<Configure>", on_resize)
|
||||
global using_gui_launcher
|
||||
using_gui_launcher = True
|
||||
kcpp_exporting_template = False
|
||||
|
||||
# trigger empty tooltip then remove it
|
||||
|
@ -4393,7 +4390,7 @@ def show_gui():
|
|||
exitcounter = 999
|
||||
print("")
|
||||
time.sleep(0.5)
|
||||
if guimode:
|
||||
if using_gui_launcher:
|
||||
givehelp = show_gui_yesnobox("No Model Loaded","No text or image model file was selected. Cannot continue.\n\nDo you want help finding a GGUF model?")
|
||||
if givehelp == 'yes':
|
||||
display_help_models()
|
||||
|
@ -4810,6 +4807,7 @@ def reload_new_config(filename): #for changing config after launch
|
|||
setattr(args,"benchmark",False)
|
||||
setattr(args,"prompt","")
|
||||
setattr(args,"config",None)
|
||||
setattr(args,"launch",None)
|
||||
|
||||
def load_config_cli(filename):
|
||||
print("Loading .kcpps configuration file...")
|
||||
|
@ -4921,7 +4919,7 @@ def analyze_gguf_model_wrapper(filename=""):
|
|||
dumpthread.start()
|
||||
|
||||
def main(launch_args):
|
||||
global args, showdebug, kcpp_instance, exitcounter
|
||||
global args, showdebug, kcpp_instance, exitcounter, using_gui_launcher
|
||||
args = launch_args #note: these are NOT shared with the child processes!
|
||||
|
||||
if (args.version) and len(sys.argv) <= 2:
|
||||
|
@ -4933,7 +4931,10 @@ def main(launch_args):
|
|||
exit_with_error(1, "Error: Using --quantkv requires --flashattention")
|
||||
|
||||
args = convert_outdated_args(args)
|
||||
if not ((args.model_param or args.model) and args.prompt and not args.benchmark and not (args.debugmode >= 1)):
|
||||
|
||||
temp_hide_print = ((args.model_param or args.model) and args.prompt and not args.benchmark and not (args.debugmode >= 1))
|
||||
|
||||
if not temp_hide_print:
|
||||
print(f"***\nWelcome to KoboldCpp - Version {KcppVersion}")
|
||||
if args.debugmode != 1:
|
||||
showdebug = False #not shared with child process!
|
||||
|
@ -4973,6 +4974,22 @@ def main(launch_args):
|
|||
args.model_param = dlfile
|
||||
load_config_cli(args.model_param)
|
||||
|
||||
# show the GUI launcher if a model was not provided
|
||||
if args.showgui or (not args.model_param and not args.sdmodel and not args.whispermodel and not args.ttsmodel and not args.nomodel):
|
||||
#give them a chance to pick a file
|
||||
print("For command line arguments, please refer to --help")
|
||||
print("***")
|
||||
try:
|
||||
show_gui()
|
||||
except Exception as ex:
|
||||
exitcounter = 999
|
||||
ermsg = "Reason: " + str(ex) + "\nFile selection GUI unsupported.\ncustomtkinter python module required!\n\nYou must use the command line instead, e.g. python ./koboldcpp.py --help"
|
||||
show_gui_msgbox("Warning, GUI failed to start",ermsg)
|
||||
if args.skiplauncher:
|
||||
print("Note: In order to use --skiplauncher, you need to specify a model with --model")
|
||||
time.sleep(3)
|
||||
sys.exit(2)
|
||||
|
||||
# manager command queue
|
||||
with multiprocessing.Manager() as mp_manager:
|
||||
global_memory = mp_manager.dict({"tunnel_url": "", "restart_target":"", "input_to_exit":False})
|
||||
|
@ -4981,7 +4998,7 @@ def main(launch_args):
|
|||
setuptunnel(global_memory, True if args.sdmodel else False)
|
||||
|
||||
# invoke the main koboldcpp process
|
||||
kcpp_instance = multiprocessing.Process(target=kcpp_main_process,kwargs={"launch_args": args, "g_memory": global_memory})
|
||||
kcpp_instance = multiprocessing.Process(target=kcpp_main_process,kwargs={"launch_args": args, "g_memory": global_memory, "gui_launcher": using_gui_launcher})
|
||||
kcpp_instance.daemon = True
|
||||
kcpp_instance.start()
|
||||
|
||||
|
@ -5005,7 +5022,7 @@ def main(launch_args):
|
|||
kcpp_instance = None
|
||||
print("Restarting KoboldCpp...")
|
||||
reload_new_config(targetfilepath)
|
||||
kcpp_instance = multiprocessing.Process(target=kcpp_main_process,kwargs={"launch_args": args, "g_memory": global_memory})
|
||||
kcpp_instance = multiprocessing.Process(target=kcpp_main_process,kwargs={"launch_args": args, "g_memory": global_memory, "gui_launcher": using_gui_launcher})
|
||||
kcpp_instance.daemon = True
|
||||
kcpp_instance.start()
|
||||
global_memory["restart_target"] = ""
|
||||
|
@ -5019,35 +5036,20 @@ def main(launch_args):
|
|||
print("Press ENTER key to exit.", flush=True)
|
||||
input()
|
||||
|
||||
def kcpp_main_process(launch_args, g_memory=None):
|
||||
global embedded_kailite, embedded_kcpp_docs, embedded_kcpp_sdui, start_time, exitcounter, global_memory
|
||||
def kcpp_main_process(launch_args, g_memory=None, gui_launcher=False):
|
||||
global embedded_kailite, embedded_kcpp_docs, embedded_kcpp_sdui, start_time, exitcounter, global_memory, using_gui_launcher
|
||||
global libname, args, friendlymodelname, friendlysdmodelname, fullsdmodelpath, mmprojpath, password, fullwhispermodelpath, ttsmodelpath
|
||||
|
||||
start_server = True
|
||||
|
||||
args = launch_args
|
||||
global_memory = g_memory
|
||||
using_gui_launcher = gui_launcher
|
||||
start_time = time.time()
|
||||
|
||||
if (args.model_param or args.model) and args.prompt and not args.benchmark and not (args.debugmode >= 1):
|
||||
suppress_stdout()
|
||||
|
||||
# show the GUI launcher if a model was not provided
|
||||
if args.showgui or (not args.model_param and not args.sdmodel and not args.whispermodel and not args.ttsmodel and not args.nomodel):
|
||||
#give them a chance to pick a file
|
||||
print("For command line arguments, please refer to --help")
|
||||
print("***")
|
||||
try:
|
||||
show_gui()
|
||||
except Exception as ex:
|
||||
exitcounter = 999
|
||||
ermsg = "Reason: " + str(ex) + "\nFile selection GUI unsupported.\ncustomtkinter python module required!\n\nYou must use the command line instead, e.g. python ./koboldcpp.py --help"
|
||||
show_gui_msgbox("Warning, GUI failed to start",ermsg)
|
||||
if args.skiplauncher:
|
||||
print("Note: In order to use --skiplauncher, you need to specify a model with --model")
|
||||
time.sleep(3)
|
||||
sys.exit(2)
|
||||
|
||||
if args.model_param and (args.benchmark or args.prompt):
|
||||
start_server = False
|
||||
|
||||
|
@ -5326,7 +5328,7 @@ def kcpp_main_process(launch_args, g_memory=None):
|
|||
exitcounter = 999
|
||||
exit_with_error(3,"Could not load text model: " + modelname)
|
||||
|
||||
if (chatcompl_adapter is not None and isinstance(chatcompl_adapter, list)):
|
||||
if (chatcompl_adapter is not None and isinstance(chatcompl_adapter, list) and not args.nomodel):
|
||||
# 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
|
||||
ctbytes = handle.get_chat_template()
|
||||
|
@ -5624,7 +5626,6 @@ def kcpp_main_process(launch_args, g_memory=None):
|
|||
file.write(f"\n{datetimestamp},{libname},{args.gpulayers},{benchmodel},{benchmaxctx},{benchlen},{t_pp:.2f},{s_pp:.2f},{t_gen:.2f},{s_gen:.2f},{(t_pp+t_gen):.2f},{result},{benchflagstr}")
|
||||
except Exception as e:
|
||||
print(f"Error writing benchmark to file: {e}")
|
||||
global using_gui_launcher
|
||||
if using_gui_launcher and not save_to_file:
|
||||
global_memory["input_to_exit"] = True
|
||||
time.sleep(1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue