==> include/mesh/infer_request.h <==1/* @ajax/mesh-infer-request: an `infer` request (infer.rs Request, parse,
2 * from_query, text): `infer [fast|fast16|exact|exact-cpu] [max N]
3 * [prefill=K decode=J | mono=K] [repeat=R] [len=N] <prompt>` on the control
4 * port, `GET /infer?prompt=..&max=..&mode=..` on meshd's http. */
5#ifndef MESH_INFER_REQUEST_H
6#define MESH_INFER_REQUEST_H
7
8#include "mesh/buf.h"
9#include "mesh/infer_wire.h"
10
11#include <stdbool.h>
12#include <stdint.h>
13
14#define MESH_INFER_USAGE \
15 "usage: infer [fast|fast16|exact|exact-cpu] [max N] [prefill=K decode=J | mono=K] [repeat=R (the prompt R times)] " \
16 "[len=N (cut to N tokens)] <prompt>"
17
18typedef struct {
19 char mode[16];
20 uint32_t max;
21 bool has_prefill, has_decode, has_mono, has_len, has_repeat;
22 uint32_t prefill, decode, mono, len, repeat;
23 char *prompt;
24} mesh_infer_request;
25
26/* The words after `infer`: 0, or -1 with *err (free it). Free r with mesh_infer_request_free. */
27int mesh_infer_parse(const char *arg, mesh_infer_request *r, char **err);
28/* GET /infer's query: the request and whether format=full. */
29int mesh_infer_from_query(const char *q, mesh_infer_request *r, bool *full, char **err);
30void mesh_infer_request_free(mesh_infer_request *r);
31/* The control port's text: `key value` lines, then `text <the generated text>`. */
32void mesh_infer_text(mesh_buf *out, const mesh_infer_msg *res);
33/* %XX and '+' decoded; the bytes read as UTF-8 lossily (infer.rs url_decode). */
34char *mesh_infer_url_decode(const char *s);
35
36#endif