Repository navigation
feat(sdk): add TypeScript SDK - #198
Conversation
|
Thank you for the substantial work, a typed SDK with no runtime dependencies is really nice. One direction question before review. #31 landed today as the repo's server, speaking the Jev-compatible |
|
@NandhaKishorM I’ll keep the typed API and zero runtime dependencies, align request/response handling with the shared protocol, and update the tests and examples. I’ll also check compatibility with Jev before documenting support through a |
21aa596 to
1625644
Compare
|
Thank you for reworking this so quickly. Targeting /v1/systemone and dropping the separate server is exactly what we hoped for, and the zero-dependency typed client with a live test against laya-serve is lovely. The open-source repo stays focused on local, self-hosted inference, so please remove the hosted-service parts: the TypeSafe base URL, API key and model examples, the docs.typesafe.ai links, the Jev API box in the diagram, and the jev-latest default (leave model unset so laya-serve auto-routes). Please also add a sentence on when to use this client versus laya-ts, drop examples/benchmark.ts, and use a package name we control, for example laya-client, rather than the @laya scope. With those changes it is ready for a final review. |
e522a53 to
4fa7a42
Compare
|
Thank you for such a thorough rework, every hosted piece is gone, model is unset by default, and the live test against laya-serve plus the zero-dependency build make this a really solid client. Two small things: please revert the edits to the existing 'Self-Hosting: HTTP Server' section of the main README and keep only your new JavaScript / TypeScript subsection. That keeps the PR focused, and the heading rename currently breaks the link from sdk/typescript/README.md to #self-hosting-http-server-jev-compatible. Please also change 'is published as laya-client' in docs/typescript-sdk.md to say it will be published under that name, since it is not on npm yet. With those two fixes it is ready. |
|
@NandhaKishorM I’ve made the changes. Could you please take a look and let me know if anything else needs to be updated? |
|
Hi @NandhaKishorM Is there anything else I need to check on this PR |
|
Passed checks and merged. Thank you @baninaveen! It ships in 0.3.22. |
|
Thank you so much @NandhaKishorM |
Adds
@laya/typescript-sdk, a typed JavaScript/TypeScript HTTP client for the existing Jev-compatiblePOST /v1/systemoneserver from #31. Applications can use the same prediction API against self-hosted Laya or Jev by changingbaseURLand credentials. This PR adds no Python production code or changes to the server dependencies.The SDK ships ESM, CommonJS, and declarations with zero runtime dependencies. It infers answer types and choice labels, includes all five generated presets, and provides input/response validation, typed errors, timeouts, and cancellation.
Protocol and scope
predict()sends{state, questions, model}to/v1/systemone. The defaultjev-latestworks as a Jev model alias and lets Laya auto-route; client-wide and per-request model overrides are supported.health()uses Laya's existing{status, loaded, device}probe. Standaloneroute(),task, andlangoptions are excluded because the shared HTTP endpoint does not expose them.{detail: ...}errors preserve their HTTP status, message, and validation details.serveextra and environment-variable server configuration. The only Python additions are development/test helpers for generated presets and offline integration.Try locally
At the repository root:
pip install -e '.[serve]' LAYA_HOST=127.0.0.1 LAYA_MODELS=english laya-serveIn another terminal:
cd sdk/typescript npm ci npm run build node examples/triage.mjsSee the SDK guide for typed questions, Jev configuration, and publishing.
Validation
npm test: 18 client tests plus TypeScript and ESM/CommonJS checks passed.laya.serveintegration passed using a tiny offline PyTorch checkpoint; answers match direct Python inference, and tests cover presets, routing, authentication, and request limits.pytest tests/test_serve.py: 22 tests passed.Jev compatibility is tested with fixtures based on its official API contract; no live Jev request was made. The npm package is configured as
@laya/typescript-sdk@0.1.0and has not been published. These checks verify transport and compatibility, not pretrained model quality or performance.