From 0e8f96414a5f9504e063be71fc14fe1ac1a3cc07 Mon Sep 17 00:00:00 2001 From: Concedo <39025047+LostRuins@users.noreply.github.com> Date: Mon, 14 Jul 2025 17:41:08 +0800 Subject: [PATCH] add in backwards compatibility for older clients with incorrect json_schema passing --- koboldcpp.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/koboldcpp.py b/koboldcpp.py index 5e7ef4436..3f2c612b1 100644 --- a/koboldcpp.py +++ b/koboldcpp.py @@ -2333,6 +2333,15 @@ ws ::= | " " | "\n" [ \t]{0,20} # In case of any issues, just do normal gen print("Structured Output not valid - discarded") pass + elif 'json_schema' in genparams: + try: + schema = genparams.get('json_schema') + decoded = convert_json_to_gbnf(schema) + if decoded: + genparams["grammar"] = decoded + except Exception: + print("Structured Output (old format) not valid - discarded") + pass message_index = 0 for message in messages_array: