55
55
# dry_seq_break_max = 128
56
56
57
57
# global vars
58
- KcppVersion = "1.84000 "
58
+ KcppVersion = "1.84200 "
59
59
LcppVersion = "b4722"
60
60
CudaSpecifics = "Cu128_Ar86_SMC2_DmmvX32Y1"
61
61
ReleaseDate = "2025/02/15"
106
106
websearch_lastresponse = []
107
107
preloaded_story = None
108
108
chatcompl_adapter = None
109
+ chatcompl_adapter_list = None #if using autoguess, will populate this will potential adapters
109
110
embedded_kailite = None
110
111
embedded_kcpp_docs = None
111
112
embedded_kcpp_sdui = None
@@ -3093,7 +3094,7 @@ def do_GET(self):
3093
3094
opts = []
3094
3095
if args .admin and args .admindir and os .path .exists (args .admindir ) and self .check_header_password (args .adminpassword ):
3095
3096
dirpath = os .path .abspath (args .admindir )
3096
- opts = [f for f in sorted (os .listdir (dirpath )) if f .endswith (".kcpps" ) and os .path .isfile (os .path .join (dirpath , f ))]
3097
+ opts = [f for f in sorted (os .listdir (dirpath )) if ( f .endswith (".kcpps" ) or f . endswith ( ".kcppt" ) ) and os .path .isfile (os .path .join (dirpath , f ))]
3097
3098
response_body = (json .dumps (opts ).encode ())
3098
3099
3099
3100
elif self .path .endswith (('/api/extra/perf' )):
@@ -3465,7 +3466,7 @@ def do_POST(self):
3465
3466
if targetfile and targetfile != "" :
3466
3467
dirpath = os .path .abspath (args .admindir )
3467
3468
targetfilepath = os .path .join (dirpath , targetfile )
3468
- opts = [f for f in os .listdir (dirpath ) if f .endswith (".kcpps" ) and os .path .isfile (os .path .join (dirpath , f ))]
3469
+ opts = [f for f in os .listdir (dirpath ) if ( f .endswith (".kcpps" ) or f . endswith ( ".kcppt" ) ) and os .path .isfile (os .path .join (dirpath , f ))]
3469
3470
if targetfile in opts and os .path .exists (targetfilepath ):
3470
3471
print (f"Admin: Received request to reload config to { targetfile } " )
3471
3472
global_memory ["restart_target" ] = targetfile
@@ -5384,7 +5385,7 @@ def make_url_request_horde(url, data, method='POST',addmykey=False):
5384
5385
"name" : worker_name ,
5385
5386
"models" : [friendlymodelname ],
5386
5387
"max_length" : maxhordelen ,
5387
- "max_context_length" : maxhordectx ,
5388
+ "max_context_length" : min ( maxctx , maxhordectx ) ,
5388
5389
"priority_usernames" : [],
5389
5390
"softprompts" : [],
5390
5391
"bridge_agent" : BRIDGE_AGENT ,
@@ -5697,7 +5698,7 @@ def sanitize_string(input_string):
5697
5698
sanitized_string = re .sub ( r'[^\w\d\.\-_]' , '' , input_string )
5698
5699
return sanitized_string
5699
5700
5700
- def downloader_internal (input_url , output_filename , capture_output , min_file_size = 64 ): #64 bytes required by default
5701
+ def downloader_internal (input_url , output_filename , capture_output , min_file_size = 64 ): # 64 bytes required by default
5701
5702
import shutil
5702
5703
import subprocess
5703
5704
import os
@@ -5711,20 +5712,44 @@ def downloader_internal(input_url, output_filename, capture_output, min_file_siz
5711
5712
return output_filename
5712
5713
print (f"Downloading { input_url } " , flush = True )
5713
5714
dl_success = False
5714
- if shutil .which ("aria2c" ) is not None :
5715
- rc = subprocess .run (f"aria2c -x 16 -s 16 --summary-interval=30 --console-log-level=error --log-level=error --download-result=default --allow-overwrite=true --file-allocation=none -o { output_filename } { input_url } " , shell = True , capture_output = capture_output , text = True , check = True , encoding = 'utf-8' )
5716
- dl_success = (rc .returncode == 0 and os .path .exists (output_filename ) and os .path .getsize (output_filename ) > min_file_size )
5717
- if not dl_success and shutil .which ("curl" ) is not None :
5718
- rc = subprocess .run (f"curl -fLo { output_filename } { input_url } " , shell = True , capture_output = capture_output , text = True , check = True , encoding = 'utf-8' )
5719
- dl_success = (rc .returncode == 0 and os .path .exists (output_filename ) and os .path .getsize (output_filename ) > min_file_size )
5720
- if not dl_success and shutil .which ("wget" ) is None :
5721
- rc = subprocess .run (f"wget -O { output_filename } { input_url } " , shell = True , capture_output = capture_output , text = True , check = True , encoding = 'utf-8' )
5722
- dl_success = (rc .returncode == 0 and os .path .exists (output_filename ) and os .path .getsize (output_filename ) > min_file_size )
5715
+
5716
+ try :
5717
+ if shutil .which ("aria2c" ) is not None :
5718
+ rc = subprocess .run (
5719
+ f"aria2c -x 16 -s 16 --summary-interval=30 --console-log-level=error --log-level=error --download-result=default --allow-overwrite=true --file-allocation=none -o { output_filename } { input_url } " ,
5720
+ shell = True , capture_output = capture_output , text = True , check = True , encoding = 'utf-8'
5721
+ )
5722
+ dl_success = (rc .returncode == 0 and os .path .exists (output_filename ) and os .path .getsize (output_filename ) > min_file_size )
5723
+ except subprocess .CalledProcessError as e :
5724
+ print (f"aria2c failed: { e } " )
5725
+
5726
+ try :
5727
+ if not dl_success and shutil .which ("curl" ) is not None :
5728
+ rc = subprocess .run (
5729
+ f"curl -fLo { output_filename } { input_url } " ,
5730
+ shell = True , capture_output = capture_output , text = True , check = True , encoding = 'utf-8'
5731
+ )
5732
+ dl_success = (rc .returncode == 0 and os .path .exists (output_filename ) and os .path .getsize (output_filename ) > min_file_size )
5733
+ except subprocess .CalledProcessError as e :
5734
+ print (f"curl failed: { e } " )
5735
+
5736
+ try :
5737
+ if not dl_success and shutil .which ("wget" ) is not None :
5738
+ rc = subprocess .run (
5739
+ f"wget -O { output_filename } { input_url } " ,
5740
+ shell = True , capture_output = capture_output , text = True , check = True , encoding = 'utf-8'
5741
+ )
5742
+ dl_success = (rc .returncode == 0 and os .path .exists (output_filename ) and os .path .getsize (output_filename ) > min_file_size )
5743
+ except subprocess .CalledProcessError as e :
5744
+ print (f"wget failed: { e } " )
5745
+
5723
5746
if not dl_success :
5724
- print ("Could not find suitable download software, please install aria2 or curl ." )
5747
+ print ("Could not find suitable download software, or all download methods failed. Please install aria2, curl, or wget ." )
5725
5748
return None
5749
+
5726
5750
return output_filename
5727
5751
5752
+
5728
5753
def download_model_from_url (url , permitted_types = [".gguf" ,".safetensors" , ".ggml" , ".bin" ], min_file_size = 64 ):
5729
5754
if url and url != "" :
5730
5755
if url .endswith ("?download=true" ):
@@ -5789,6 +5814,9 @@ def main(launch_args):
5789
5814
# print("Python version: " + sys.version)
5790
5815
if args .debugmode != 1 :
5791
5816
showdebug = False #not shared with child process!
5817
+ if args .debugmode >= 1 :
5818
+ print ("Debug Mode is Enabled!" )
5819
+ args .quiet = False # verbose outputs
5792
5820
5793
5821
try :
5794
5822
delete_old_pyinstaller () #perform some basic cleanup of old temporary directories
@@ -5991,7 +6019,7 @@ def kcpp_main_process(launch_args, g_memory=None, gui_launcher=False):
5991
6019
5992
6020
# try to read chat completions adapter
5993
6021
if args .chatcompletionsadapter :
5994
- global chatcompl_adapter
6022
+ global chatcompl_adapter , chatcompl_adapter_list
5995
6023
ccadapter_path = None
5996
6024
canload = False
5997
6025
adapt_dir = os .path .join (os .path .abspath (os .path .dirname (__file__ )), 'kcpp_adapters' )
@@ -6031,6 +6059,9 @@ def kcpp_main_process(launch_args, g_memory=None, gui_launcher=False):
6031
6059
print ("Chat Completions Adapter Loaded" )
6032
6060
else :
6033
6061
print ("Warning: Chat Completions Adapter invalid or not found." )
6062
+ if (chatcompl_adapter is not None and isinstance (chatcompl_adapter , list )):
6063
+ chatcompl_adapter_list = chatcompl_adapter
6064
+ chatcompl_adapter = None
6034
6065
6035
6066
# handle model downloads if needed
6036
6067
if args .model_param and args .model_param != "" :
@@ -6238,23 +6269,20 @@ def kcpp_main_process(launch_args, g_memory=None, gui_launcher=False):
6238
6269
exitcounter = 999
6239
6270
exit_with_error (3 ,"Could not load text model: " + modelname )
6240
6271
6241
- if (chatcompl_adapter is not None and isinstance (chatcompl_adapter , list )):
6272
+ if (chatcompl_adapter_list is not None and isinstance (chatcompl_adapter_list , list )):
6242
6273
# The chat completions adapter is a list that needs derivation from chat templates
6243
6274
# Try to derive chat completions adapter from chat template, now that we have the model loaded
6244
6275
if not args .nomodel and args .model_param :
6245
6276
ctbytes = handle .get_chat_template ()
6246
6277
chat_template = ctypes .string_at (ctbytes ).decode ("UTF-8" ,"ignore" )
6247
- candidates = chatcompl_adapter
6248
6278
if chat_template != "" :
6249
- for entry in candidates :
6279
+ for entry in chatcompl_adapter_list :
6250
6280
if all (s in chat_template for s in entry ['search' ]):
6251
6281
print (f"Chat completion heuristic: { entry ['name' ]} " )
6252
6282
chatcompl_adapter = entry ['adapter' ]
6253
6283
break
6254
6284
if chatcompl_adapter is None :
6255
6285
print ("Chat template heuristics failed to identify chat completions format. Alpaca will be used." )
6256
- else :
6257
- chatcompl_adapter = None #if no text model loaded, erase the list.
6258
6286
6259
6287
#handle loading image model
6260
6288
if args .sdmodel and args .sdmodel != "" :
@@ -6445,7 +6473,10 @@ def kcpp_main_process(launch_args, g_memory=None, gui_launcher=False):
6445
6473
print (f"StableUI is available at { endpoint_url } /sdui/" )
6446
6474
global_memory ["load_complete" ] = True
6447
6475
if args .launch :
6448
- LaunchWebbrowser (endpoint_url ,"--launch was set, but could not launch web browser automatically." )
6476
+ def launch_browser_thread ():
6477
+ LaunchWebbrowser (endpoint_url ,"--launch was set, but could not launch web browser automatically." )
6478
+ browser_thread = threading .Timer (2 , launch_browser_thread ) #2 second delay
6479
+ browser_thread .start ()
6449
6480
6450
6481
if args .hordekey and args .hordekey != "" :
6451
6482
if args .hordeworkername and args .hordeworkername != "" :
0 commit comments