tools: rad-chatparse --request, one chat request rendered and read back as the server does

--request REQ.json --rad MODEL.rad renders an OpenAI request through parse_chat_request with the
server's own adapters (the container's vocabulary, --override-chat-template, --chat-template-kwargs,
the architecture plugin's declared reply format from --home or the template's analysis with
--no-plugin), and reads each --reply file as the model's tokens: stopped at end of generation,
detokenised with the request's preserved tokens, parsed whole (the non-streaming body) and through
the SSE emitter (reassembled as a client does), with the tool-call grammar run over the tokens as
the sampler masks them. --render-raw renders a template with any JSON context through the vendored
jinja engine, for message shapes a request cannot carry. One JSON object on stdout.

rad-chatparse is now a plugin host: rad_core whole-archive with exports, the legacy parser's sources
compiled in.
This commit is contained in:
baKon authored and StillDeadcode committed 2026-10-27 18:17:06 +01:00
1 parent fe27edb4da
commit 731a23a65a
3 files changed
+470 -5

No files matched your search

+10 -1
View File
@@ -30,7 +30,11 @@
* chunk JSON, and the tool-call grammar's accept_token / fill_mask), with every SSE event checked
* against nlohmann's serialisation.
*
* Exit status is non-zero when any reply breaks the contract or a verdict is not allowed. */
* Exit status is non-zero when any reply breaks the contract or a verdict is not allowed.
*
* With --request or --render-raw it instead renders one request and reads its replies the way the
* server does, against a container's vocabulary and its plugin's reply format
* (chatparse_serve.cpp). */
#include "chatdiff.h"
#include "iface.h"
#include "sample/grammar.h"
@@ -525,7 +529,12 @@ int breakdown(const Bench& b, const Tok& tk, const TokenView& view, int reps) {
} /* namespace */
int serve_main(int argc, char** argv); /* chatparse_serve.cpp */
int main(int argc, char** argv) {
for (int i = 1; i < argc; ++i)
if (!std::strcmp(argv[i], "--request") || !std::strcmp(argv[i], "--render-raw"))
return serve_main(argc, argv);
std::vector<std::pair<std::string, std::string>> want; /* model name, folder */
int fuzz = 300;
int reps = 5;