Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦
C
fix(serve): a non-object json_schema answered 500 "engine failed"
kevin932707259f2c15a3
diff --git a/c/openai_server.py b/c/openai_server.pyindex 7476fc08..4c6c3f3f 100644--- a/c/openai_server.py+++ b/c/openai_server.py@@ -2681,7 +2681,8 @@ def generation_options(body, limit):if ftype == "json_object":grammar = GENERIC_JSON_GBNFelif ftype == "json_schema":- schema = (response_format.get("json_schema") or {}).get("schema")+ json_schema = response_format.get("json_schema")+ schema = json_schema.get("schema") if isinstance(json_schema, dict) else Noneif not isinstance(schema, dict):raise APIError(400, "`response_format.json_schema.schema` must be an object.","response_format", "invalid_value")diff --git a/c/tests/test_openai_server.py b/c/tests/test_openai_server.pyindex b08d5dff..f15999c2 100644--- a/c/tests/test_openai_server.py+++ b/c/tests/test_openai_server.py@@ -363,6 +363,16 @@ class TemplateTest(unittest.TestCase):generation_options({"response_format": {"type": "yaml"}}, 8)with self.assertRaises(APIError):generation_options({"response_format": {"type": "json_schema", "json_schema": {}}}, 8)+ # a json_schema that is not an object is the client's mistake too: a 400+ # naming the parameter, not an AttributeError the handler turns into a+ # 500 "engine failed" (which OpenAI SDKs retry)+ for json_schema in ('{"schema": {}}', [schema], 5, True):+ with self.subTest(json_schema=json_schema):+ with self.assertRaises(APIError) as caught:+ generation_options({"response_format": {"type": "json_schema",+ "json_schema": json_schema}}, 8)+ self.assertEqual(caught.exception.status, 400)+ self.assertEqual(caught.exception.param, "response_format")with self.assertRaises(APIError): # non-dict response_formatgeneration_options({"response_format": "json"}, 8)with self.assertRaises(APIError): # empty gbnf