@johnhenry/aimatey-native-laya
v0.2.0
Published
Laya (ConvAI) typed-decision backend for Aimatey, via @receptron/laya
Maintainers
Readme
@johnhenry/aimatey-native-laya
Run Aimatey typed-decision requests against ConvAI's Laya model on-device, via
@receptron/laya -- a real TypeScript/
ONNX Runtime port, not a hosted-API wrapper. No network call, no API key.
Part of the aimatey monorepo.
Requirements
- Node.js 18+ (this package: Node 26+)
- The optional native binding:
npm install @receptron/laya - ~1.7GB of ONNX weights, downloaded from HuggingFace on first use and cached
locally (
cacheDir, or@receptron/laya's ownLAYA_CACHEdefault)
Installation
npm install @johnhenry/aimatey-native-laya @receptron/layaQuick Start
import { Bridge } from '@johnhenry/aimatey-core';
import { LayaFrontendAdapter } from '@johnhenry/aimatey-frontend';
import { LayaBackendAdapter } from '@johnhenry/aimatey-native-laya';
const backend = new LayaBackendAdapter();
// Sessions are loaded lazily on first decide(); initialize eagerly to
// surface a missing-dependency or download failure early.
await backend.initialize();
const bridge = new Bridge(new LayaFrontendAdapter(), backend);
// IR in, IR out. The frontend is not involved.
const response = await bridge.decide(
{ headline: 'Local sea levels rising faster than predicted' },
{ urgency: { type: 'score', instructions: 'How urgent is this?', criteria: ['low', 'medium', 'high'] } }
);
// Laya's own request/response shapes in and out, via the frontend adapter.
const native = await bridge.decideFrom({
state: { headline: 'Local sea levels rising faster than predicted' },
questions: { urgency: { type: 'score', instructions: 'How urgent is this?', criteria: ['low', 'medium', 'high'] } },
});
await backend.close();What the adapter declares
decisionModels:english,multilingual,typed-decisionsdecisionTypes:choice,score,nouldecisionLimits: 20 choice options (Laya is weak beyond that), 10 score levels, 512 state tokens (the English checkpoint; multilingual allows 1024), no images (decisionImages: false; images are dropped with acapability-unsupportedwarning)
Behaviour notes
decide(request, signal)honourssignalbefore loading, before running, and once the result arrives. An in-flight ONNX run cannot be cancelled.- The checkpoint is chosen when the session loads (
subfolder), and@receptron/laya'ssystemOne()takes notask/lang. Aparameters.modelthat differs fromsubfolder, andparameters.custom.task/lang, are reported asparameter-unsupportedwarnings onresponse.metadata.warningsrather than ignored silently. - Laya's per-answer
rl_agentsub-object is kept underresponse.raw.rl_agent, keyed by question. Convai measured itsact_probabilityas uninformative, so treat it as diagnostic. - Laya reports no
confidencefornoulanswers; the adapter derivesmax(p, 1 - p).
License
MIT - see LICENSE for details.
