Skip to content

Commit 06581f2

Browse files
committed
perf endpoint lets you monitor if the embedded horde worker has issues
1 parent fce971d commit 06581f2

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

koboldcpp.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ def bring_terminal_to_foreground():
401401
session_kudos_earned = 0
402402
session_jobs = 0
403403
session_starttime = None
404-
exitcounter = 0
404+
exitcounter = -1
405405
punishcounter = 0 #causes a timeout if too many errors
406406
rewardcounter = 0 #reduces error counts for successful jobs
407407
totalgens = 0
@@ -708,7 +708,7 @@ def noscript_webui(self):
708708
self.wfile.write(finalhtml)
709709

710710
def do_GET(self):
711-
global maxctx, maxhordelen, friendlymodelname, KcppVersion, totalgens, preloaded_story
711+
global maxctx, maxhordelen, friendlymodelname, KcppVersion, totalgens, preloaded_story, exitcounter
712712
self.path = self.path.rstrip('/')
713713
response_body = None
714714
content_type = 'application/json'
@@ -754,7 +754,7 @@ def do_GET(self):
754754
lastc = handle.get_last_token_count()
755755
totalgens = handle.get_total_gens()
756756
stopreason = handle.get_last_stop_reason()
757-
response_body = (json.dumps({"last_process":lastp,"last_eval":laste,"last_token_count":lastc, "total_gens":totalgens, "stop_reason":stopreason, "queue":requestsinqueue, "idle":(0 if modelbusy.locked() else 1)}).encode())
757+
response_body = (json.dumps({"last_process":lastp,"last_eval":laste,"last_token_count":lastc, "total_gens":totalgens, "stop_reason":stopreason, "queue":requestsinqueue, "idle":(0 if modelbusy.locked() else 1), "hordeexitcounter":exitcounter}).encode())
758758

759759
elif self.path.endswith('/api/extra/generate/check'):
760760
pendtxtStr = ""
@@ -1893,7 +1893,7 @@ def submit_completed_generation(url, jobid, sessionstart, submit_dict):
18931893
rewardcounter += 1
18941894
if rewardcounter > 50:
18951895
rewardcounter = 0
1896-
if exitcounter >= 1:
1896+
if exitcounter > 1:
18971897
exitcounter -= 1
18981898

18991899
def make_url_request_horde(url, data, method='POST'):
@@ -1908,6 +1908,7 @@ def make_url_request_horde(url, data, method='POST'):
19081908
current_generation = None
19091909
session_starttime = datetime.now()
19101910
sleepy_counter = 0 #if this exceeds a value, worker becomes sleepy (slower)
1911+
exitcounter = 0
19111912
print(f"===\nEmbedded Horde Worker '{worker_name}' Starting...\n(To use your own KAI Bridge/Scribe worker instead, don't set your API key)")
19121913
BRIDGE_AGENT = f"KoboldCppEmbedWorker:2:https://github.com/LostRuins/koboldcpp"
19131914
cluster = "https://horde.koboldai.net"
@@ -1931,7 +1932,7 @@ def make_url_request_horde(url, data, method='POST'):
19311932
print_with_time(f"Caution: Too many failed jobs may lead to entering maintenance mode.")
19321933
time.sleep(60 * penaltytime)
19331934
else:
1934-
print_with_time(f"Exit limit reached, too many errors.")
1935+
print_with_time(f"Horde Worker Exit limit reached, too many errors.")
19351936

19361937
#first, make sure we are not generating
19371938
if modelbusy.locked():

0 commit comments

Comments
 (0)