37 tok/s from Qwen3-Next-80B (48 GB) on a 32 GB laptop, 24 without drafts vs 2.8 for llama.cpp; reading 62 vs 16 tok/s. Faster than llama.cpp on all 13 models compared in Q4_K_M. LLMs bigger than your RAM, pure C, CPU or GPU.
C avx2ccpu-inferenceggufinference-enginelinuxllmlocal-llmmixture-of-expertsmoenvmequantizationqwen3simdspeculative-decodingvulkan
Release 2026-09-27: no Python left, and the author credited
camauri2f342043388a
diff --git a/ChangeLog.md b/ChangeLog.mdindex 8bcdfc9..96e5ea5 100644--- a/ChangeLog.md+++ b/ChangeLog.md@@ -2,6 +2,23 @@> Curated, user-facing summary of completed work, newest first.+## [2026-09-27] - No Python left++- The README names its author, Maurizio "camauri" Cammalleri, under the+ introduction and in a new Credits section, with the copyright line in+ the Licence one; the section also credits the models' authors, llama.cpp+ and ggml (the reference, and the IQ3_S grid), the Unicode Character+ Database, OpenAI's specification, the libraries compiled in, and the+ testers.+- The last two Python scripts are C programs, built with everything else:+ `tools/gen_unicode` writes the tokenizer's Unicode tables from the+ Unicode Character Database (`/usr/share/unicode` on Debian and its kin),+ `tools/openapi_routes` writes `janas-server`'s route table from OpenAI's+ specification. Both give, byte for byte, the files the scripts gave+ (Unicode 15.1.0; OpenAPI 2.3.0, 345 operations), and the coverage count+ is the same. Nothing in Janas needs Python any more, to build or to+ regenerate.+## [2026-09-27] - janas-get: a model in one command- **`janas-get`** downloads a model of its catalog (the thirteen ofdiff --git a/README.md b/README.mdindex 1dfa4a1..fdf12c7 100644--- a/README.md+++ b/README.md@@ -23,6 +23,8 @@ a GPU: the weights stay on disk, the experts each token needs are streamed froman NVMe SSD, and the ones that keep coming back stay in memory. An 80-billionparameter model runs, and answers, on a laptop with 32 GB of RAM.+Designed and written by **Maurizio "camauri" Cammalleri**.+---## ⚠️ Read this first@@ -961,7 +963,7 @@ says so.follows (2.3.0) - has a route that answers 501 and says why: not writtenyet, needs a model of another kind (sound, images, video), trains models, orbelongs to the administration of OpenAI's service. The table is generated-from the specification by `tools/openapi_routes.py`, which also counts what is+from the specification by `tools/openapi_routes`, which also counts what isdone.**One request at a time.** The model holds one sequence, so requests wait in@@ -1010,7 +1012,8 @@ wants fewer threads than for one.| `tools/hf2jns_mtp` | the multi-token prediction block, from the original checkpoint: its shards, or just the block's tensors from Hugging Face (`hf:<owner>/<repo>`) || `tools/jns_planes` | rewrites a model with the experts' down matrix in bit planes, so a machine short of memory can read part of it || `jns_check` | checks a model file, with `--verify` every expert's checksum |-| `tools/openapi_routes.py` | `janas-server`'s route table, from OpenAI's specification |+| `tools/openapi_routes` | `janas-server`'s route table, from OpenAI's specification |+| `tools/gen_unicode` | the tokenizer's Unicode tables, from the Unicode Character Database || `mcp_fake_server` | an MCP server over stdio in either era of the protocol, for trying a client without anybody else's server || `llm_eval` | compares the engine's logits against a reference dump || `bench_gemm`, `bench_attn`, `bench_long`, ... | the pieces measured on their own |@@ -1093,8 +1096,36 @@ outside the Qwen3 MoE families (they are refused with a message).Patches are welcome too, but a measurement from a machine nobody here can buy isworth more than most patches.+## Credits++Janas is designed and written by **Maurizio "camauri" Cammalleri**+([LinkedIn](https://www.linkedin.com/in/maurizio-cammalleri-80a89a11/),+[Substack](https://cammalleri.substack.com/)).++It stands on the work of others, and says so:++- **The models** it runs are their authors': Qwen3, Qwen3.5, Qwen3.6 and+ Qwen3-Next by the Qwen team of Alibaba Cloud, Gemma 4 by Google; the GGUF+ quantizations by Qwen, bartowski and unsloth ([MODELS.md](MODELS.md) has+ every source).+- **llama.cpp and ggml** are the reference the engine is checked against+ (logits, tokens, speed); none of their code is in Janas. The one thing+ taken from ggml is data that defines a format: the IQ3_S grid, in+ `src/llm/iq3s_grid.h`, under ggml's MIT licence.+- **The Unicode Character Database** gives the tokenizer its tables+ (`tools/gen_unicode`), and **OpenAI's OpenAPI specification** gives+ `janas-server` its route table (`tools/openapi_routes`).+- **GNU libmicrohttpd, yyjson and Mbed TLS** are compiled into the programs+ named below.+- **The people who tried it on their own machines** and reported what they+ saw, in the issues of this repository: their reports changed the engine+ more than once (the threads it picks, the prompt's progress, the GPU's+ diagnosis).+## Licence+Copyright © 2026 Maurizio "camauri" Cammalleri.+Janas is free software under the **GNU General Public License, version 3 orlater** — see [LICENSE](LICENSE). Every source file carries its SPDX line.diff --git a/src/llm/unicode_data.h b/src/llm/unicode_data.hindex 52ef449..f1bc7a9 100644--- a/src/llm/unicode_data.h+++ b/src/llm/unicode_data.h@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-3.0-or-laterCopyright (C) 2026 Maurizio Cammalleri */-/* Generated by tools/gen_unicode.py from Unicode 15.1.0. Do not edit. */+/* Generated by tools/gen_unicode.c from Unicode 15.1.0. Do not edit. */#ifndef JANAS_LLM_UNICODE_DATA_H#define JANAS_LLM_UNICODE_DATA_Hdiff --git a/src/server/routes.inc b/src/server/routes.incindex 6339358..2a57680 100644--- a/src/server/routes.inc+++ b/src/server/routes.inc@@ -1,4 +1,4 @@-/* Generated by tools/openapi_routes.py - do not edit.+/* Generated by tools/openapi_routes.c - do not edit.OpenAI OpenAPI 2.3.0, sha256 d6085f8c39db2048f29cbc813452f20c0e7e882457d5b07c9468cec4eae7fb19,345 operations, 27 implemented. */JANAS_ROUTE(GET, "/agents", "listAgents", "Agents", cloud, NULL)diff --git a/tools/gen_unicode.c b/tools/gen_unicode.cnew file mode 100644index 0000000..0b9d0b5--- /dev/null+++ b/tools/gen_unicode.c@@ -0,0 +1,155 @@+/* SPDX-License-Identifier: GPL-3.0-or-later+ Copyright (C) 2026 Maurizio Cammalleri */+/*+ * gen_unicode.c - generates src/llm/unicode_data.h: code point ranges of the+ * Unicode letter (L*), number (N*) and mark (M*) categories and of the+ * White_Space property, for the pre-tokenizer of src/llm/tokenizer.c.+ *+ * It reads the Unicode Character Database: the general categories from+ * UnicodeData.txt (a code point it does not list is unassigned, Cn), the+ * version from the first line of DerivedAge.txt. Debian and its kin ship+ * the database in /usr/share/unicode (package unicode-data); it is also at+ * https://www.unicode.org/Public/<version>/ucd/.+ *+ * Usage: gen_unicode <ucd-directory> > src/llm/unicode_data.h+ */+#include <stdint.h>+#include <stdio.h>+#include <stdlib.h>+#include <string.h>++#define N_CP 0x110000++static const uint32_t WHITE_SPACE[][2] = {+ {0x09, 0x0D}, {0x20, 0x20}, {0x85, 0x85}, {0xA0, 0xA0},+ {0x1680, 0x1680}, {0x2000, 0x200A}, {0x2028, 0x2029}, {0x202F, 0x202F},+ {0x205F, 0x205F}, {0x3000, 0x3000},+};++/* the first letter of each code point's general category; 'C' when the+ database does not list it */+static char major[N_CP];++static FILE *open_in(const char *dir, const char *name)+{+ char path[4096];+ snprintf(path, sizeof path, "%s/%s", dir, name);+ FILE *f = fopen(path, "r");+ if (!f)+ perror(path);+ return f;+}++/* Fields: code;name;category;... A range is two lines, its name ending in+ ", First>" and ", Last>". */+static int read_categories(const char *dir)+{+ FILE *f = open_in(dir, "UnicodeData.txt");+ if (!f)+ return -1;+ memset(major, 'C', sizeof major);+ char line[1024];+ long first = -1, lines = 0;+ while (fgets(line, sizeof line, f)) {+ char *name = strchr(line, ';');+ char *cat = name ? strchr(name + 1, ';') : NULL;+ char *end;+ long cp = strtol(line, &end, 16);+ if (!cat || end != name || cp < 0 || cp >= N_CP) {+ fprintf(stderr, "UnicodeData.txt: bad line: %s", line);+ fclose(f);+ return -1;+ }+ size_t name_n = (size_t)(cat - name - 1);+ if (name_n >= 7 && !memcmp(cat - 7, ", Last>", 7)) {+ if (first < 0 || first > cp) {+ fprintf(stderr, "UnicodeData.txt: range without a start\n");+ fclose(f);+ return -1;+ }+ memset(major + first, cat[1], (size_t)(cp - first + 1));+ first = -1;+ } else {+ major[cp] = cat[1];+ if (name_n >= 8 && !memcmp(cat - 8, ", First>", 8))+ first = cp;+ }+ lines++;+ }+ fclose(f);+ if (lines == 0) {+ fprintf(stderr, "UnicodeData.txt: empty\n");+ return -1;+ }+ return 0;+}++/* The version from "# DerivedAge-15.1.0.txt". */+static int read_version(const char *dir, char *out, size_t out_n)+{+ FILE *f = open_in(dir, "DerivedAge.txt");+ if (!f)+ return -1;+ char line[256];+ int ok = fgets(line, sizeof line, f) != NULL;+ fclose(f);+ const char *p = ok ? strstr(line, "DerivedAge-") : NULL;+ const char *e = p ? strstr(p, ".txt") : NULL;+ if (!e || (size_t)(e - p - 11) >= out_n || e - p - 11 == 0) {+ fprintf(stderr, "DerivedAge.txt: no version on its first line\n");+ return -1;+ }+ memcpy(out, p + 11, (size_t)(e - p - 11));+ out[e - p - 11] = 0;+ return 0;+}++static void emit_head(const char *name)+{+ printf("static const uint32_t %s[][2] = {\n", name);+}++static void emit_category(const char *name, char c)+{+ emit_head(name);+ long start = -1;+ for (long cp = 0; cp <= N_CP; cp++) {+ int ok = cp < N_CP && major[cp] == c;+ if (ok && start < 0) {+ start = cp;+ } else if (!ok && start >= 0) {+ printf(" {0x%lX, 0x%lX},\n", start, cp - 1);+ start = -1;+ }+ }+ printf("};\n");+}++int main(int argc, char **argv)+{+ if (argc != 2) {+ fprintf(stderr, "usage: gen_unicode <ucd-directory> "+ "> src/llm/unicode_data.h\n");+ return 2;+ }+ char version[32];+ if (read_version(argv[1], version, sizeof version) != 0 ||+ read_categories(argv[1]) != 0)+ return 1;+ printf("/* SPDX-License-Identifier: GPL-3.0-or-later\n"+ " Copyright (C) 2026 Maurizio Cammalleri */\n");+ printf("/* Generated by tools/gen_unicode.c from Unicode %s. "+ "Do not edit. */\n",+ version);+ printf("#ifndef JANAS_LLM_UNICODE_DATA_H\n#define JANAS_LLM_UNICODE_DATA_H"+ "\n\n");+ printf("#include <stdint.h>\n\n");+ emit_category("janas_uni_letter", 'L');+ emit_category("janas_uni_number", 'N');+ emit_category("janas_uni_mark", 'M');+ emit_head("janas_uni_space");+ for (size_t i = 0; i < sizeof WHITE_SPACE / sizeof *WHITE_SPACE; i++)+ printf(" {0x%X, 0x%X},\n", WHITE_SPACE[i][0], WHITE_SPACE[i][1]);+ printf("};\n\n#endif\n");+ return ferror(stdout) ? 1 : 0;+}diff --git a/tools/gen_unicode.py b/tools/gen_unicode.pydeleted file mode 100644index c2b6db1..0000000--- a/tools/gen_unicode.py+++ /dev/null@@ -1,48 +0,0 @@-#!/usr/bin/env python3-# SPDX-License-Identifier: GPL-3.0-or-later-# Copyright (C) 2026 Maurizio Cammalleri-"""Generates src/llm/unicode_data.h: code point ranges of the Unicode letter-(L*), number (N*) and mark (M*) categories and of the White_Space property, for the-pre-tokenizer of src/llm/tokenizer.c.--Usage: gen_unicode.py > src/llm/unicode_data.h-"""-import sys-import unicodedata--WHITE_SPACE = [(0x09, 0x0D), (0x20, 0x20), (0x85, 0x85), (0xA0, 0xA0),- (0x1680, 0x1680), (0x2000, 0x200A), (0x2028, 0x2029),- (0x202F, 0x202F), (0x205F, 0x205F), (0x3000, 0x3000)]---def ranges(pred):- out, start = [], None- for cp in range(0x110000):- ok = pred(cp)- if ok and start is None:- start = cp- elif not ok and start is not None:- out.append((start, cp - 1))- start = None- if start is not None:- out.append((start, 0x10FFFF))- return out---def emit(name, rs):- print(f"static const uint32_t {name}[][2] = {{")- for a, b in rs:- print(f" {{0x{a:X}, 0x{b:X}}},")- print("};")---cat = unicodedata.category-print("/* Generated by tools/gen_unicode.py from Unicode "- f"{unicodedata.unidata_version}. Do not edit. */")-print("#ifndef JANAS_LLM_UNICODE_DATA_H\n#define JANAS_LLM_UNICODE_DATA_H\n")-print("#include <stdint.h>\n")-emit("janas_uni_letter", ranges(lambda c: cat(chr(c))[0] == "L"))-emit("janas_uni_number", ranges(lambda c: cat(chr(c))[0] == "N"))-emit("janas_uni_mark", ranges(lambda c: cat(chr(c))[0] == "M"))-emit("janas_uni_space", WHITE_SPACE)-print("\n#endif")diff --git a/tools/openapi_routes.c b/tools/openapi_routes.cnew file mode 100644index 0000000..f54b13e--- /dev/null+++ b/tools/openapi_routes.c@@ -0,0 +1,292 @@+/* SPDX-License-Identifier: GPL-3.0-or-later+ Copyright (C) 2026 Maurizio Cammalleri */+/*+ * openapi_routes.c - the route table of janas-server, from OpenAI's OpenAPI+ * specification (https://github.com/openai/openai-openapi, openapi.json).+ *+ * Every operation of the specification gets a row: those janas-server+ * implements name their handler, the others answer 501 with a message that+ * says why. Running it again on a newer specification keeps the table whole.+ *+ * Usage: openapi_routes openapi.json > src/server/routes.inc+ * openapi_routes openapi.json --coverage+ */+#include <stdio.h>+#include <stdlib.h>+#include <string.h>++#include "common/sha256.h"+#include "llm/json.h"++/* operationId -> handler in src/server/ (declared in routes.h) */+static const char *const HANDLERS[][2] = {+ {"listModels", "srv_models_list"},+ {"retrieveModel", "srv_models_get"},+ {"createChatCompletion", "srv_chat_create"},+ {"createCompletion", "srv_completion_create"},+ {"deleteModel", "srv_models_delete"},+ {"listChatCompletions", "srv_stored_list"},+ {"getChatCompletion", "srv_stored_get"},+ {"updateChatCompletion", "srv_stored_update"},+ {"deleteChatCompletion", "srv_stored_delete"},+ {"getChatCompletionMessages", "srv_stored_messages"},+ {"createResponse", "srv_responses_create"},+ {"getResponse", "srv_responses_get"},+ {"deleteResponse", "srv_responses_delete"},+ {"cancelResponse", "srv_responses_cancel"},+ {"listInputItems", "srv_responses_input_items"},+ {"Getinputtokencounts", "srv_responses_input_tokens"},+ {"Compactconversation", "srv_responses_compact"},+ {"createConversation", "srv_conv_create"},+ {"getConversation", "srv_conv_get"},+ {"updateConversation", "srv_conv_update"},+ {"deleteConversation", "srv_conv_delete"},+ {"listConversationItems", "srv_conv_items_list"},+ {"createConversationItems", "srv_conv_items_create"},+ {"getConversationItem", "srv_conv_item_get"},+ {"deleteConversationItem", "srv_conv_item_delete"},+ {"createEmbedding", "srv_embeddings_create"},+ {"createModeration", "srv_moderations_create"},+};++/* What an operation that is not implemented is, by its tag: the text of the+ 501 answer. "planned" operations are ones a local text model can serve;+ a tag not listed is "cloud". */+static const char *const KIND[][2] = {+ {"Chat", "planned"}, {"Completions", "planned"},+ {"Models", "planned"}, {"Responses", "planned"},+ {"Conversations", "planned"}, {"Embeddings", "planned"},+ {"Moderations", "planned"}, {"Files", "planned"},+ {"Uploads", "planned"}, {"Batch", "planned"},+ {"Vector stores", "planned"}, {"Assistants", "planned"},+ {"Evals", "planned"}, {"Audio", "other_model"},+ {"Images", "other_model"}, {"Videos", "other_model"},+ {"Realtime", "other_model"}, {"Live", "other_model"},+ {"Fine-tuning", "training"},+};++static const char *const METHODS[][2] = {+ {"get", "GET"}, {"post", "POST"}, {"put", "PUT"},+ {"delete", "DELETE"}, {"patch", "PATCH"},+};++#define COUNT(a) (sizeof(a) / sizeof *(a))++struct op {+ const char *method; /* upper case */+ char *path; /* without a "?beta=true" and the like */+ const char *id, *tag;+};++static const char *lookup(const char *const (*t)[2], size_t n, const char *key)+{+ for (size_t i = 0; i < n; i++)+ if (!strcmp(t[i][0], key))+ return t[i][1];+ return NULL;+}++static const char *handler(const char *id)+{+ return lookup(HANDLERS, COUNT(HANDLERS), id);+}++static int by_path_method(const void *a, const void *b)+{+ const struct op *x = a, *y = b;+ int c = strcmp(x->path, y->path);+ return c ? c : strcmp(x->method, y->method);+}++static int by_string(const void *a, const void *b)+{+ return strcmp(*(const char *const *)a, *(const char *const *)b);+}++static char *read_all(const char *path, size_t *n)+{+ FILE *f = fopen(path, "rb");+ if (!f) {+ perror(path);+ return NULL;+ }+ size_t cap = 1 << 20, len = 0;+ char *p = malloc(cap);+ for (size_t r; p && (r = fread(p + len, 1, cap - len, f)) > 0;) {+ len += r;+ if (len == cap) {+ char *q = realloc(p, cap *= 2);+ if (!q)+ free(p);+ p = q;+ }+ }+ if (!p || ferror(f)) {+ fprintf(stderr, "%s: cannot be read\n", path);+ free(p);+ p = NULL;+ }+ fclose(f);+ *n = len;+ return p;+}++/* Every operation once: the "?..." variants of a path are the same route. */+static struct op *operations(const struct janas_json *paths, size_t *count)+{+ size_t cap = 0, n = 0;+ for (const struct janas_json *p = paths->child; p; p = p->next)+ cap += COUNT(METHODS);+ struct op *ops = calloc(cap ? cap : 1, sizeof *ops);+ if (!ops)+ return NULL;+ for (const struct janas_json *p = paths->child; p; p = p->next) {+ size_t bare_n = strcspn(p->key, "?");+ for (const struct janas_json *o = p->child;+ p->type == JANAS_JSON_OBJECT && o; o = o->next) {+ const char *method = lookup(METHODS, COUNT(METHODS), o->key);+ if (!method)+ continue;+ int seen = 0;+ for (size_t i = 0; i < n && !seen; i++)+ seen = ops[i].method == method &&+ strlen(ops[i].path) == bare_n &&+ !memcmp(ops[i].path, p->key, bare_n);+ if (seen)+ continue;+ const struct janas_json *tags = janas_json_get(o, "tags");+ const char *tag = tags && tags->type == JANAS_JSON_ARRAY+ ? janas_json_str(tags->child)+ : NULL;+ const char *id = janas_json_str(janas_json_get(o, "operationId"));+ ops[n] = (struct op){+ .method = method,+ .path = strndup(p->key, bare_n),+ .id = id ? id : "",+ .tag = tag ? tag : "-",+ };+ if (!ops[n].path) {+ for (size_t i = 0; i < n; i++)+ free(ops[i].path);+ free(ops);+ return NULL;+ }+ n++;+ }+ }+ *count = n;+ return ops;+}++static void c_str(const char *s)+{+ putchar('"');+ for (; *s; s++) {+ if (*s == '\\' || *s == '"')+ putchar('\\');+ putchar(*s);+ }+ putchar('"');+}++static void coverage(const struct op *ops, size_t n)+{+ const char **tags = malloc((n ? n : 1) * sizeof *tags);+ if (!tags)+ return;+ size_t done = 0;+ for (size_t i = 0; i < n; i++) {+ tags[i] = ops[i].tag;+ done += handler(ops[i].id) != NULL;+ }+ qsort(tags, n, sizeof *tags, by_string);+ printf("%zu of %zu operations implemented\n", done, n);+ for (size_t i = 0; i < n;) {+ size_t d = 0, k = 0;+ for (size_t j = 0; j < n; j++)+ if (!strcmp(ops[j].tag, tags[i])) {+ k++;+ d += handler(ops[j].id) != NULL;+ }+ printf(" %-40s %3zu / %zu\n", tags[i], d, k);+ i += k;+ }+ free(tags);+}++/* The rows of routes.inc, with what they came from. */+static void table(const struct janas_json *spec, const struct op *ops, size_t n,+ const char *raw, size_t raw_n)+{+ const char *ver =+ janas_json_str(janas_json_get(janas_json_get(spec, "info"), "version"));+ struct janas_sha256 sha;+ char hex[65];+ janas_sha256_init(&sha);+ janas_sha256_update(&sha, raw, raw_n);+ janas_sha256_hex(&sha, hex);+ size_t done = 0;+ for (size_t i = 0; i < n; i++)+ done += handler(ops[i].id) != NULL;+ printf("/* Generated by tools/openapi_routes.c - do not edit.\n");+ printf(" OpenAI OpenAPI %s, sha256 %s,\n", ver ? ver : "?", hex);+ printf(" %zu operations, %zu implemented. */\n", n, done);+ for (size_t i = 0; i < n; i++) {+ const char *h = handler(ops[i].id);+ const char *kind =+ h ? "implemented" : lookup(KIND, COUNT(KIND), ops[i].tag);+ printf("JANAS_ROUTE(%s, ", ops[i].method);+ c_str(ops[i].path);+ printf(", ");+ c_str(ops[i].id);+ printf(", ");+ c_str(ops[i].tag);+ printf(", %s, %s)\n", kind ? kind : "cloud", h ? h : "NULL");+ }+}++int main(int argc, char **argv)+{+ if (argc < 2) {+ fprintf(stderr, "usage: openapi_routes openapi.json "+ "> src/server/routes.inc\n"+ " openapi_routes openapi.json --coverage\n");+ return 2;+ }+ int cover = 0;+ for (int i = 2; i < argc; i++)+ cover |= !strcmp(argv[i], "--coverage");+ size_t raw_n, n = 0;+ char *raw = read_all(argv[1], &raw_n);+ if (!raw)+ return 1;+ char err[256];+ struct janas_json_doc *doc = janas_json_parse(raw, raw_n, err, sizeof err);+ const struct janas_json *spec = doc ? janas_json_root(doc) : NULL;+ const struct janas_json *paths = janas_json_get(spec, "paths");+ struct op *ops = NULL;+ int rc = 1;+ if (!doc)+ fprintf(stderr, "%s: %s\n", argv[1], err);+ else if (!paths || paths->type != JANAS_JSON_OBJECT)+ fprintf(stderr, "%s: no paths\n", argv[1]);+ else if (!(ops = operations(paths, &n)))+ fprintf(stderr, "out of memory\n");+ else+ rc = 0;+ if (rc == 0) {+ qsort(ops, n, sizeof *ops, by_path_method);+ if (cover)+ coverage(ops, n);+ else+ table(spec, ops, n, raw, raw_n);+ rc = ferror(stdout) ? 1 : 0;+ }+ for (size_t i = 0; ops && i < n; i++)+ free(ops[i].path);+ free(ops);+ if (doc)+ janas_json_free(doc);+ free(raw);+ return rc;+}diff --git a/tools/openapi_routes.py b/tools/openapi_routes.pydeleted file mode 100644index 3e80764..0000000--- a/tools/openapi_routes.py+++ /dev/null@@ -1,122 +0,0 @@-#!/usr/bin/env python3-# SPDX-License-Identifier: GPL-3.0-or-later-# Copyright (C) 2026 Maurizio Cammalleri-"""-openapi_routes.py - the route table of janas-server, from OpenAI's OpenAPI-specification (https://github.com/openai/openai-openapi, openapi.json).--Every operation of the specification gets a row: those janas-server-implements name their handler, the others answer 501 with a message that-says why. Running it again on a newer specification keeps the table whole.--Usage: tools/openapi_routes.py openapi.json > src/server/routes.inc- tools/openapi_routes.py openapi.json --coverage-"""-import hashlib-import json-import sys--# operationId -> handler in src/server/ (declared in routes.h)-HANDLERS = {- "listModels": "srv_models_list",- "retrieveModel": "srv_models_get",- "createChatCompletion": "srv_chat_create",- "createCompletion": "srv_completion_create",- "deleteModel": "srv_models_delete",- "listChatCompletions": "srv_stored_list",- "getChatCompletion": "srv_stored_get",- "updateChatCompletion": "srv_stored_update",- "deleteChatCompletion": "srv_stored_delete",- "getChatCompletionMessages": "srv_stored_messages",- "createResponse": "srv_responses_create",- "getResponse": "srv_responses_get",- "deleteResponse": "srv_responses_delete",- "cancelResponse": "srv_responses_cancel",- "listInputItems": "srv_responses_input_items",- "Getinputtokencounts": "srv_responses_input_tokens",- "Compactconversation": "srv_responses_compact",- "createConversation": "srv_conv_create",- "getConversation": "srv_conv_get",- "updateConversation": "srv_conv_update",- "deleteConversation": "srv_conv_delete",- "listConversationItems": "srv_conv_items_list",- "createConversationItems": "srv_conv_items_create",- "getConversationItem": "srv_conv_item_get",- "deleteConversationItem": "srv_conv_item_delete",- "createEmbedding": "srv_embeddings_create",- "createModeration": "srv_moderations_create",-}--# What an operation that is not implemented is, by its tag: the text of the-# 501 answer. "planned" operations are ones a local text model can serve.-KIND = {- "Chat": "planned",- "Completions": "planned",- "Models": "planned",- "Responses": "planned",- "Conversations": "planned",- "Embeddings": "planned",- "Moderations": "planned",- "Files": "planned",- "Uploads": "planned",- "Batch": "planned",- "Vector stores": "planned",- "Assistants": "planned",- "Evals": "planned",- "Audio": "other_model",- "Images": "other_model",- "Videos": "other_model",- "Realtime": "other_model",- "Live": "other_model",- "Fine-tuning": "training",-}-METHODS = ("get", "post", "put", "delete", "patch")---def operations(spec):- seen = set()- for path, ops in spec["paths"].items():- bare = path.split("?")[0] # "?beta=true" variants are the same route- for method, op in ops.items():- if method not in METHODS or (method, bare) in seen:- continue- seen.add((method, bare))- tag = (op.get("tags") or ["-"])[0]- yield method.upper(), bare, op.get("operationId", ""), tag---def c_str(s):- return '"' + s.replace("\\", "\\\\").replace('"', '\\"') + '"'---def main():- if len(sys.argv) < 2:- sys.exit(__doc__)- raw = open(sys.argv[1], "rb").read()- spec = json.loads(raw)- ops = sorted(operations(spec), key=lambda o: (o[1], o[0]))- if "--coverage" in sys.argv[2:]:- by = {}- for _, _, oid, tag in ops:- t = by.setdefault(tag, [0, 0])- t[1] += 1- t[0] += oid in HANDLERS- done = sum(v[0] for v in by.values())- print(f"{done} of {len(ops)} operations implemented")- for tag, (d, n) in sorted(by.items()):- print(f" {tag:40} {d:3} / {n}")- return- ver = spec.get("info", {}).get("version", "?")- print("/* Generated by tools/openapi_routes.py - do not edit.")- print(f" OpenAI OpenAPI {ver}, sha256 {hashlib.sha256(raw).hexdigest()},")- print(f" {len(ops)} operations, {sum(o[2] in HANDLERS for o in ops)}"- " implemented. */")- for method, path, oid, tag in ops:- h = HANDLERS.get(oid, "NULL")- kind = "implemented" if oid in HANDLERS else KIND.get(tag, "cloud")- print(f"JANAS_ROUTE({method}, {c_str(path)}, {c_str(oid)}, "- f"{c_str(tag)}, {kind}, {h})")---if __name__ == "__main__":- main()