Skip to content

armgit / laya

Public Imported from GitHub
0

Non-autoregressive System 1 decision engine. Typed choice, score and yes/no decisions over any text in a single forward pass, in 100+ languages, with a router that picks the right checkpoint per request.

docs(ts): point examples at the shipped model weights

nnlgsakib00e6dbb7ee4d
diff --git a/laya-ts/examples/snake.mjs b/laya-ts/examples/snake.mjs
index dd901de0..17afe10e 100644
--- a/laya-ts/examples/snake.mjs
+++ b/laya-ts/examples/snake.mjs
@@ -1,4 +1,5 @@
import { Agent } from "../dist/index.js";
+import { existsSync } from "node:fs";
// ---- CLI (no deps) ----
const args = process.argv.slice(2);
@@ -6,7 +7,7 @@ const opt = (name, def) => {
const i = args.indexOf(name);
return i === -1 || i + 1 >= args.length ? def : args[i + 1];
};
-const MODEL_DIR = opt("--model", "./model-ml");
+const MODEL_DIR = opt("--model", ["./model-ml", "laya-ts/examples/model-ml", "./examples/model-ml"].find((d) => existsSync(d)) ?? "./model-ml");
const TICK_MS = Math.max(20, Number(opt("--tick", "120")) || 120);
const W = Math.max(10, Number(opt("--width", "20")) || 20);
const H = Math.max(6, Number(opt("--height", "12")) || 12);
diff --git a/laya-ts/examples/try-ml.mjs b/laya-ts/examples/try-ml.mjs
index cc4ee6f7..fd600e74 100644
--- a/laya-ts/examples/try-ml.mjs
+++ b/laya-ts/examples/try-ml.mjs
@@ -1,6 +1,16 @@
import { Agent, Router } from "../dist/index.js";
+import { existsSync } from "node:fs";
-const agent = await Agent.load("./model-ml"); // run as: node laya-ts/examples/try-ml.mjs (repo root)
+// run as: node laya-ts/examples/try-ml.mjs (repo root) or node examples/try-ml.mjs (laya-ts dir)
+// --model overrides; otherwise first existing dir wins (repo ships weights at laya-ts/examples/model-ml)
+const args = process.argv.slice(2);
+const flag = (name) => {
+ const i = args.indexOf(name);
+ return i === -1 || i + 1 >= args.length ? null : args[i + 1];
+};
+const MODEL_DIR = flag("--model") ??
+ ["./model-ml", "laya-ts/examples/model-ml", "./examples/model-ml"].find((d) => existsSync(d)) ?? "./model-ml";
+const agent = await Agent.load(MODEL_DIR);
console.log("loaded:", agent.cfg.encoder ?? "multilingual");
// Direct predict (Hindi -> multilingual weights)