From d097e369f5ee4be7398465b9ec6e4a16200f753e Mon Sep 17 00:00:00 2001 From: Concedo <39025047+LostRuins@users.noreply.github.com> Date: Wed, 22 Jul 2026 20:38:31 +0800 Subject: [PATCH] fix for https://github.com/LostRuins/koboldcpp/discussions/2358 Revert "fix device enumeration issues" This reverts commit 287f3cdb53d4c663d3108c6ad6e4e45624c45104. (+4 squashed commit) Squashed commit: [38bf57e59] Revert "try init cuda even earlier" This reverts commit fa3d4dfd22284099d1484f3597ae60162d420e1b. [fa3d4dfd2] try init cuda even earlier [287f3cdb5] fix device enumeration issues [02f9543f1] fix for https://github.com/LostRuins/koboldcpp/discussions/2358 --- koboldcpp.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/koboldcpp.py b/koboldcpp.py index facdf690c..285d8ff7b 100644 --- a/koboldcpp.py +++ b/koboldcpp.py @@ -5254,6 +5254,8 @@ class KcppServerRequestHandler(http.server.SimpleHTTPRequestHandler): genout = run_blocking() recvtxt = genout['text'] + if recvtxt is not None and not isinstance(recvtxt, str): + recvtxt = recvtxt.decode("UTF-8", "ignore") if isinstance(recvtxt, bytes) else str(recvtxt) prompttokens = genout['prompt_tokens'] if genout['prompt_tokens'] > 0 else 0 comptokens = genout['completion_tokens'] if genout['completion_tokens'] > 0 else 0 currfinishreason = "error" if (genout['stopreason'] == -2) else ("length" if (genout['stopreason'] != 1) else "stop") @@ -5305,10 +5307,12 @@ class KcppServerRequestHandler(http.server.SimpleHTTPRequestHandler): flat = [] for obj in tool_calls: if isinstance(obj, list): - flat.extend(obj) - else: + flat.extend(item for item in obj if isinstance(item, dict)) + elif isinstance(obj, dict): flat.append(obj) tool_calls = [normalize_tool_call_resp(obj) for obj in flat] + tool_calls = [tc for tc in tool_calls if isinstance(tc, dict) and isinstance(tc.get("function", None), dict) and tc["function"].get("name")] + if tool_calls and len(tool_calls)>0: for tc in tool_calls: tcarg = tc.get("function",{}).get("arguments",None) tc["id"] = f"call_{random.randint(10000, 99999)}"