From 5e7932b09505e01dff80b77044f1585caa03dde7 Mon Sep 17 00:00:00 2001 From: JustVugg Date: Wed, 22 Jul 2026 20:55:38 +0200 Subject: [PATCH] serve: the gateway's engine default follows the #391 rename python3 openai_server.py --model looked for a binary named 'glm' next to itself. Since #391 the build produces 'colibri', so direct invocation was broken on any clean checkout -- it only appeared to work in trees that still had a stale glm from an older build. Spotted by @RDouglasSharp while working on #488. Resolve the engine by probing colibri / colibri.exe first and falling back to glm / glm.exe, the same order the coli launcher uses, so old trees keep starting. Verified by removing the stale glm and running the gateway: it resolves to colibri and the engine launches. Co-Authored-By: Claude Fable 5 --- c/openai_server.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/c/openai_server.py b/c/openai_server.py index 8115687bb..6b8632de1 100644 --- a/c/openai_server.py +++ b/c/openai_server.py @@ -24,6 +24,18 @@ HERE = Path(__file__).resolve().parent + + +def default_engine(): + """The engine next to this file. Since #391 it is built as `colibri`; `glm` stays as a + fallback so an old tree (or an old hand-built binary) still starts. Reported by + @RDouglasSharp in #488: the default still said `glm`, so `python3 openai_server.py` + on a clean checkout looked for a file the build no longer produces.""" + for name in ("colibri", "colibri.exe", "glm", "glm.exe"): + candidate = HERE / name + if candidate.exists(): + return candidate + return HERE / "colibri" END = b"\x01\x01END\x01\x01\n" READY = b"\x01\x01READY\x01\x01\n" MAX_BODY = 4 << 20 @@ -1612,8 +1624,10 @@ def completion(self, body, request_id): def serve(model, host="127.0.0.1", port=8000, model_id="glm-5.2-colibri", api_key=None, - cap=8, max_tokens=1024, engine=HERE / "glm", env=None, cors_origins=None, + cap=8, max_tokens=1024, engine=None, env=None, cors_origins=None, max_queue=8, queue_timeout=300, kv_slots=1): + if engine is None: + engine = default_engine() if not 1 <= max_tokens: raise ValueError("max_tokens must be positive") if not 1 <= port <= 65535: @@ -1658,7 +1672,7 @@ def serve(model, host="127.0.0.1", port=8000, model_id="glm-5.2-colibri", api_ke def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--model", default=os.environ.get("COLI_MODEL"), required=not os.environ.get("COLI_MODEL")) - parser.add_argument("--engine", default=str(HERE / "glm")) + parser.add_argument("--engine", default=str(default_engine())) parser.add_argument("--host", default="127.0.0.1") parser.add_argument("--port", type=int, default=8000) parser.add_argument("--model-id", default=os.environ.get("COLI_MODEL_ID", "glm-5.2-colibri"))