lemonteaa commited on
Commit
8ae3604
·
1 Parent(s): 28b42d9

fix structured call 1

Browse files
Files changed (4) hide show
  1. wasm/llm-wasm.build.txt +1 -1
  2. wasm/llm-wasm.js +0 -0
  3. wasm/llm-wasm.wasm +2 -2
  4. worker.js +14 -6
wasm/llm-wasm.build.txt CHANGED
@@ -1,4 +1,4 @@
1
  llama.cpp commit: f7591a6a01f9273de03331732bdc0b39721168be
2
  llama.cpp subject: sycl: add f16 support for SWIGLU_OAI (#30857)
3
  emcc: emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 7.0.0 (777e6e5db7b4990bcaeb1b9998ed642cc84e6629)
4
- built: 2026-11-09T14:39:26Z
 
1
  llama.cpp commit: f7591a6a01f9273de03331732bdc0b39721168be
2
  llama.cpp subject: sycl: add f16 support for SWIGLU_OAI (#30857)
3
  emcc: emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 7.0.0 (777e6e5db7b4990bcaeb1b9998ed642cc84e6629)
4
+ built: 2026-11-11T09:31:06Z
wasm/llm-wasm.js CHANGED
The diff for this file is too large to render. See raw diff
 
wasm/llm-wasm.wasm CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:fc70bfd506a4b21c107f6680e4c94a21daa5d7491bb64de0f07b3d143d8d954e
3
- size 7050007
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:29b579b19aa063295a4aa494d2d981436685f97b8603b7ff047cf8b97830bd0b
3
+ size 7141666
worker.js CHANGED
@@ -428,15 +428,23 @@ async function run(opts) {
428
  }
429
 
430
  // structured output: only when the page chose a schema. The tool-call path
431
- // sends neither, so it runs exactly as before.
432
- if (!grammar && json_schema && json_schema.trim()) {
 
 
 
 
 
 
 
433
  const asGrammar = module.ccall("llmjs_grammar_from_schema", "string",
434
  ["string"], [json_schema]);
435
  if (!asGrammar) {
436
- fail(new Error(`could not use the JSON schema: ${module.UTF8ToString(module._llmjs_last_error())}`));
 
437
  return;
438
  }
439
- grammar = asGrammar;
440
  }
441
 
442
  if (createContext(context_size || currentNctx) < 0) {
@@ -465,7 +473,7 @@ async function run(opts) {
465
  ["string", "string", "string", "string", "number", "number", "number",
466
  "number", "number", "number", "number", "string"],
467
  [JSON.stringify(list), tools || "[]", chat_template_source, template_kwargs || "{}",
468
- max_token_len, temp, top_k, top_p, repeat_penalty, repeat_last_n, seed, grammar],
469
  );
470
  } else {
471
  rc = module.ccall(
@@ -474,7 +482,7 @@ async function run(opts) {
474
  ["string", "number", "number", "number", "number", "number",
475
  "number", "number", "string"],
476
  [prompt, max_token_len, temp, top_k, top_p, repeat_penalty,
477
- repeat_last_n, seed, grammar],
478
  );
479
  }
480
  if (rc < 0) {
 
428
  }
429
 
430
  // structured output: only when the page chose a schema. The tool-call path
431
+ // sends neither, so it runs exactly as before. `grammar` above is a const
432
+ // destructured binding, so the schema's result needs its own local.
433
+ let grammarText = grammar;
434
+ if (!grammarText && json_schema && json_schema.trim()) {
435
+ if (typeof module._llmjs_grammar_from_schema !== "function") {
436
+ fail(new Error("this module build has no JSON schema support; the threaded build "
437
+ + "(needs COOP/COEP) has it, or paste a GBNF grammar instead"));
438
+ return;
439
+ }
440
  const asGrammar = module.ccall("llmjs_grammar_from_schema", "string",
441
  ["string"], [json_schema]);
442
  if (!asGrammar) {
443
+ const why = module.UTF8ToString(module._llmjs_last_error());
444
+ fail(new Error(`could not use the JSON schema: ${why}`));
445
  return;
446
  }
447
+ grammarText = asGrammar;
448
  }
449
 
450
  if (createContext(context_size || currentNctx) < 0) {
 
473
  ["string", "string", "string", "string", "number", "number", "number",
474
  "number", "number", "number", "number", "string"],
475
  [JSON.stringify(list), tools || "[]", chat_template_source, template_kwargs || "{}",
476
+ max_token_len, temp, top_k, top_p, repeat_penalty, repeat_last_n, seed, grammarText],
477
  );
478
  } else {
479
  rc = module.ccall(
 
482
  ["string", "number", "number", "number", "number", "number",
483
  "number", "number", "string"],
484
  [prompt, max_token_len, temp, top_k, top_p, repeat_penalty,
485
+ repeat_last_n, seed, grammarText],
486
  );
487
  }
488
  if (rc < 0) {