@clutor/cli 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/c/src/main.c CHANGED
@@ -12,7 +12,7 @@
12
12
  #include <stdlib.h>
13
13
  #include <string.h>
14
14
 
15
- #define VERSION "0.3.0"
15
+ #define VERSION "0.3.1"
16
16
 
17
17
  static void usage(void) {
18
18
  puts("clutor-engine " VERSION "\n"
@@ -374,7 +374,7 @@ static int cmd_generate(int argc, char **argv) {
374
374
  int b = 0;
375
375
  for (int i = 1; i < f.n_vocab; i++) if (logits[i] > logits[b]) b = i;
376
376
  gen++;
377
- if (b == cl_tok_eos(tok) || gen > want) break;
377
+ if (cl_tok_is_eog(tok, b) || gen > want) break;
378
378
  char piece[256];
379
379
  int pl = cl_tok_piece(tok, b, piece, sizeof piece);
380
380
  if (!quiet) { fwrite(piece, 1, (size_t)pl, stdout); fflush(stdout); }
package/c/src/tokenizer.c CHANGED
@@ -219,6 +219,16 @@ int cl_tok_bos(const cl_tok *t) { return t->bos; }
219
219
  int cl_tok_eos(const cl_tok *t) { return t->eos; }
220
220
  int cl_tok_add_bos(const cl_tok *t) { return t->add_bos; }
221
221
 
222
+ int cl_tok_is_eog(const cl_tok *t, int id) {
223
+ if (id < 0 || (uint64_t)id >= t->n) return 0;
224
+ if (id == t->eos) return 1;
225
+ if (!t->types || (t->types[id] != 3 && t->types[id] != 4)) return 0; /* only control or user-defined tokens */
226
+ static const char *const eog[] = {"<|endoftext|>", "<|im_end|>", "<|eot_id|>", "<|end_of_text|>", "<|end|>", "<|eom_id|>", "<end_of_turn>", "</s>"};
227
+ const cl_str *tk = &t->tokens[id];
228
+ for (size_t i = 0; i < sizeof eog / sizeof *eog; i++) if (tk->len == strlen(eog[i]) && !memcmp(tk->p, eog[i], tk->len)) return 1;
229
+ return 0;
230
+ }
231
+
222
232
  /* Byte-pair-encodes one pre-token and appends its ids. */
223
233
  static int bpe(const cl_tok *t, const uint8_t *s, size_t len, int32_t *out, int cap, int *n) {
224
234
  if (len == 0) return 1;
package/c/src/tokenizer.h CHANGED
@@ -17,6 +17,8 @@ int cl_tok_vocab_size(const cl_tok *t);
17
17
  int cl_tok_bos(const cl_tok *t);
18
18
  int cl_tok_eos(const cl_tok *t);
19
19
  int cl_tok_add_bos(const cl_tok *t);
20
+ /* True for a token that ends generation: the model's EOS, or a control token such as <|endoftext|>, <|im_end|> or <|eot_id|> (llama.cpp stops on all of these, and a model may emit one that is not its configured EOS). */
21
+ int cl_tok_is_eog(const cl_tok *t, int id);
20
22
  /* Encodes text. With parse_special, control tokens such as <|endoftext|> written in the text become their single token. Returns the number of
21
23
  * tokens written, or -1 when `cap` is too small. */
22
24
  int cl_tok_encode(const cl_tok *t, const char *text, size_t len, int parse_special, int32_t *out, int cap);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clutor/cli",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "The clutor command and local server: plan whether a model fits your machine, inspect GGUF files, simulate expert streaming, run a sandboxed coding agent, and serve an OpenAI- and Ollama-compatible API on localhost in front of llama.cpp.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -13,6 +13,6 @@
13
13
  "exports": { ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" } },
14
14
  "files": ["dist", "c/src", "c/Makefile", "README.md", "LICENSE"],
15
15
  "engines": { "node": ">=20" },
16
- "dependencies": { "@clutor/core": "^0.3.0", "zod": "^4.0.0" },
16
+ "dependencies": { "@clutor/core": "^0.3.1", "zod": "^4.0.0" },
17
17
  "scripts": { "prepack": "node ../../scripts/pack-engine.mjs", "postpack": "node ../../scripts/pack-engine.mjs clean", "build": "tsup", "typecheck": "tsc --noEmit", "test": "vitest run" }
18
18
  }