mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2026-05-06 16:21:49 +00:00
wrap sd_parse_meta_field in trycatch
This commit is contained in:
parent
c48999f7c0
commit
2fa28fdcf8
1 changed files with 12 additions and 8 deletions
20
koboldcpp.py
20
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
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue