JavaScript

Use browser version

npm install --save las-sdk-browser
import { AuthorizationCodeCredentials } from '@lucidtech/las-sdk-browser';
import { Client } from '@lucidtech/las-sdk-core';
const credentials = new AuthorizationCodeCredentials('<apiEndpoint>', '<apiKey>', '<clientId>', '<redirectUri>', '<launchUriFn>', '<authEndpoint>');
const client = new Client(credentials);

Use node version

npm install --save las-sdk-node
import { AuthorizationCodeCredentials } from '@lucidtech/las-sdk-browser';
import { Client } from '@lucidtech/las-sdk-core';
const credentials = new ClientCredentials('<apiEndpoint>', '<apiKey>', '<clientId>', '<clientSecret>', '<authEndpoint>');
const client = new Client(credentials);

Make a prediction on a document

Suppose we wish to run inference on a document using Lucidtech’s invoice model.

client.createDocument('<document content>', '<document mime type>', '<consent id>')
.then(({ documentId }) => client.
createPrediction(documentId, '<model name>')
.then(({ documentId, predictions }) => console.log(prediction.data)));

Set ground truth of document

Suppose we make a prediction that returns incorrect values and we wish to improve the model for future use. We can do so by sending feedback to the model, telling it what the expected values should have been.

Consent ID is an identifier you can assign to documents to keep track of document ownership for your customers.

client.createDocument('<document content>', '<document mime type>', '<consent id>')
.then(({ documentId }) => {
const feedback = [
{ 'label': 'total_amount', 'value': '240.01' },
{ 'label': 'due_date', 'value': '2020-01-31' },
];
client.updateDocument(documentId);
});

Create a batch and associate a few documents with it

Creating a batch is a way to group documents. This is useful for specifying batches of documents to use in improving the model later.

client.createBatch(batchDescription)
.then(({ batchId }) => {
client.createDocument('<content>', '<content type>', '<consent id>', batchId)
client.createDocument('<another content>', '<another content type>', '<consent id>', batchId);
})