Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦
C
Merge pull request #1802 from bherald/contrib/strict-glm-tool-calls
Vincenzo Fornaro15641cfb0517
diff --cc c/openai_server.pyindex 64507c92,ee05a9d8..7bf1b642--- a/c/openai_server.py+++ b/c/openai_server.py@@@ -6904,17 -6765,21 +6980,28 @@@ class APIHandler(BaseHTTPRequestHandlerpreserve_thinking = body.get("preserve_thinking", not enable_thinking)if not isinstance(preserve_thinking, bool):raise APIError(400, "`preserve_thinking` must be a boolean.", "preserve_thinking")+ # The request's shape is checked before the image expanders and the renderer read it.+ # generation() validates `tools` too, but only after rendering, and a renderer handed a+ # `tools` of 5 or a `messages` of null raises TypeError, which do_POST answers with 500.+ validate_tools(body)tools = body.get("tools") or body.get("functions") or Nonetool_choice = body.get("tool_choice")+ if strict_tools and (not isinstance(tools, list) or not tools or tool_choice == "none"):+ raise APIError(400, "`strict_tool_calls` requires active `tools`.",+ "strict_tool_calls", "unsupported_parameter")+ if strict_tools:+ for index, tool in enumerate(tools):+ params = _tool_function(tool).get("parameters") or {}+ if (not isinstance(params, dict) or+ not isinstance(params.get("properties", {}), dict) or+ not isinstance(params.get("required", []), list)):+ raise APIError(400, "Strict tool schemas need object `parameters`, "+ "object `properties` and array `required`.", f"tools.{index}")audio_clips = [] if ARCH == "inkling" else None- messages, image = self.expand_images(body.get("messages"))+ messages = body.get("messages")+ if not isinstance(messages, list) or not messages:+ raise APIError(400, "`messages` must be a non-empty array.", "messages")+ messages, image = self.expand_images(messages)add_generation_prompt = resolve_generation_prompt(messages, body)prompt = render_chat_for_arch(messages, enable_thinking, reasoning_effort,tools, tool_choice, audio_out=audio_clips,