From 2fa28fdcf8ec47bd0de3f189d00e112ae1036ab8 Mon Sep 17 00:00:00 2001 From: Concedo <39025047+LostRuins@users.noreply.github.com> Date: Mon, 6 Oct 2025 00:05:19 +0800 Subject: [PATCH] wrap sd_parse_meta_field in trycatch --- koboldcpp.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/koboldcpp.py b/koboldcpp.py index 7189a4205..0558d4de2 100644 --- a/koboldcpp.py +++ b/koboldcpp.py @@ -1814,17 +1814,21 @@ def sd_process_meta_fields(fields, config): # json with top-level dict def sd_parse_meta_field(prompt, config=False): jfields = {} + kv_dict = {} try: - jfields = json.loads(prompt) - except json.JSONDecodeError: - # accept "field":"value",... without {} (also empty strings) try: - jfields = json.loads('{ ' + prompt + ' }') + jfields = json.loads(prompt) except json.JSONDecodeError: - print("Warning: couldn't parse meta prompt; it should be valid JSON.") - if not isinstance(jfields, dict): - jfields = {} - kv_dict = sd_process_meta_fields(jfields.items(), config) + # accept "field":"value",... without {} (also empty strings) + try: + jfields = json.loads('{ ' + prompt + ' }') + except json.JSONDecodeError: + print("Warning: couldn't parse meta prompt; it should be valid JSON.") + if not isinstance(jfields, dict): + jfields = {} + kv_dict = sd_process_meta_fields(jfields.items(), config) + except Exception: + pass return kv_dict