Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@memori.ai/memori-api-client

Package Overview
Dependencies
Maintainers
2
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@memori.ai/memori-api-client

React library to integrate a Memori in your app or website

  • 0.10.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
203
decreased by-2.4%
Maintainers
2
Weekly downloads
 
Created
Source

memori-api-client

npm version Tests TypeScript Support

TypeScript client to integrate with Memori API.

Installation

yarn add @memori.ai/memori-api-client
npm install @memori.ai/memori-api-client

Usage

Every method has JSDoc annotations with usage and description and typings information.

See examples for Node (TypeScript) and React.

import memoriApiClient from '@memori.ai/memori-api-client';

const memori = memoriApiClient('https://backend.memori.ai');

(async () => {
  const { sessionID, currentState, ...response } = await memori.initSession(
    '768b9654-e781-4c3c-81fa-ae1529d1bfbe'
  );

  const {
    currentState: dialogState,
    ...resp
  } = await memori.postTextEnteredEvent(sessionID, 'Ciao, Memori!');
})();

For the specification of the APIs, see the typings or the documentation from the dashboard if you are allowed to see it.

Constants

import memoriApiClient from '@memori.ai/memori-api-client';

const memori = memoriApiClient('https://backend.memori.ai');

memori.constants.allowedMediaTypes; // list of allowed media types in asset upload
memori.constants.anonTag; // tag for anonymous users

Asset

There is a helper method parsing media urls from the DB, handling different cases

const memori = memoriApiClient('https://backend.memori.ai');

memori.asset.getResourceUrl({
  type: 'avatar',
  resourceURI: '768b9654-e781-4c3c-81fa-ae1529d1bfbe.png',
  mediaType: 'image/png',
  sessionId: 'be2e4a44-890b-483b-a26a-f6e122f36e2b',
});

TTS

Experimental

Bundled with this client there is a TTS utility that can be used to synthesize text to speech.

const memori = memoriApiClient('https://backend.memori.ai');

// Needs Azure Speech API key
// See https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/quickstarts/setup-platform?pivots=programming-language-javascript
// Second parameter is for debug mode
const speechSdk = memori.speech(AZURE_COGNITIVE_SERVICES_TTS_KEY, true);

// Requires the language code of the text to be spoken
// And the voice type (female or male)
const speech = speechSdk('it', 'FEMALE');

speech.speak('Ciao, Memori!', () => {
  console.log('spoken');
});

speech.isSpeaking();

speech.stopSpeaking();

STT

Experimental

There is also a speech recognition utility.

// Same as for the TTS
const speech = speechSdk('it', 'FEMALE');

speech.recognize(transcript => {
  console.log('Recognized ', transcript);
});

speech.isRecognizing();

speech.stopRecognizing();

Development

To run TSDX, use:

npm start # or yarn start

This builds to /dist and runs the project in watch mode so any edits you save inside src causes a rebuild to /dist.

To do a one-off build, use npm run build or yarn build.

To run tests, use npm test or yarn test.

Formatting and linting

Code quality is set up with prettier, husky, and lint-staged.

You can run prettier with npm format or yarn format. You can run linter with npm lint or yarn lint. You can run type checking with npm typecheck or yarn typecheck.

Jest

Jest tests are set up to run with npm test or yarn test.

Bundle Analysis

size-limit is set up to calculate the real cost of your library with npm run size and visualize the bundle with npm run analyze.

Rollup

TSDX uses Rollup as a bundler and generates multiple rollup configs for various module formats and build settings. See Optimizations for details.

TypeScript

tsconfig.json is set up to interpret dom and esnext types, as well as react for jsx. You can run type checking with npm typecheck or yarn typecheck.

Continuous Integration

GitHub Actions

Two actions are added by default:

  • main which installs deps w/ cache, lints, tests, and builds on all pushes against a Node and OS matrix
  • size which comments cost comparison of your library on every pull request using size-limit

Optimizations

Please see the main tsdx optimizations docs. In particular, know that you can take advantage of development-only optimizations:

// ./types/index.d.ts
declare var __DEV__: boolean;

// inside your code...
if (__DEV__) {
  console.log('foo');
}

You can also choose to install and use invariant and warning functions.

Module Formats

CJS, ESModules, and UMD module formats are supported.

The appropriate paths are configured in package.json and dist/index.js accordingly. Please report if any issues are found.

Commitlint

We use commmitlint for commit message validation based on Conventional Commits.

Release

Changelog and release management with release-it, using convential changelog.

Keywords

FAQs

Package last updated on 20 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc