@dasha.ai/sdk
v0.10.20
Published
Dasha.AI SDK
Downloads
462
Readme
Dasha SDK for JavaScript - new and improved
We are proud to present a new iteration of the Dasha SDK for JavaScript. You can find more about the new SDK interfaces in the SDK reference, or by browsing the examples. Below are some highlights of what's changed.
Installation
npm install "@dasha.ai/sdk"
What's new?
Stored accounts
Using the Dasha CLI, you can store your credentials to be fetched automatically by the SDK:
$ npm install --global "@dasha.ai/cli"
$ dasha account login
const dasha = require("@dasha.ai/sdk");
const app = await dasha.deploy("path/to/app");
Automatic reconnections
When encountering a connection problem, Dasha SDK will now automatically attempt to reconnect to the server. You can control this behavior via deployment options.
Promise-based conversation interface
Instead of the old startJob()
method, use app.createConversation()
.
const conv = app.createConversation();
conv.input = { foo: "bar" };
const result = await conv.execute();
console.log(result.output);
Event-based conversation queue
The conversation queue handlers now operate on the same [conversation objects] as if created by app.createConversation()
, enabling easier migration to and from a queue-based operation model.
storage.set(convKey, { foo: "bar" });
app.queue.push(convKey);
app.queue.on("ready", async (key, conv) => {
conv.input = storage.get(convKey);
await conv.execute();
})
Better logging
Dasha SDK now uses winston, and logs events more thoroughly.
License
This SDK is distributed under the Apache License, Version 2.0.