4.2.0 • Published 10 months ago

carter-js v4.2.0

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

Carter JS

TypeDocs | Changelog | Full Documentation

carter-js documentation is a work in progress. Objects described here and in the full documentation can be found in the TypeDoc documentation if you need more details. That documentation is fully updated at all times, though the annotations and descriptions are also a work in progress.

carter-js provides a set of utility functions for interacting with your Carter agent. In order for carter-js to work you'll need to create a Carter agent.

Please note: carter-js is in its infancy and errors are likely. If you experience any issues please feel free to open a GitHub issue or contact me through the Carter Discord server in order to help carter-js improve.

For support and general chit chat, join the discord!

Installation

  npm install carter-js

Basic Usage

  import { Carter } from 'carter-js'

  // Create a Carter object
  // make sure to use the new keyword
  // in order to create a Carter instance
  const carter = new Carter(apiKey, userLogger, speak)

A Carter object contains all the necessary methods for interacting with your Carter agent. You'll need to provide your API key to create this. Make sure you keep this key secret while developing, as this key will allow anyone access to your agent. You can provide your logger object to take advantage of the built-in logging functionality. If you don't provide a logger object, carter-js will not log anything. Any logger with debug. info, warn, and error methods will work, but this feature is in beta.

speak is a boolean value which determines whether or not an audio url is returned from the API. Response times are faster with speak set to false, but you won't be able to access the audio_url. You can set the default speak value on the class constructor as above, or on a per-interaction basis. If you don't provide a default to the constructor, speak will default to false.

Send a message to your Carter agent

  // Send a message to your Carter agent
  const interaction = await carter.say("Hello", 'your_player_id')
  const outputText = interaction.outputText

Carter.say() sends a fetch request, extracts the useful elements of the response and returns a CarterInteraction object.

Take advantage of context

  // Send a message to your Carter agent with some extra context
  const interaction = await carter.say("Hello", 'your_player_id', 'User is very confused')
  const outputText = interaction.outputText

Conversation History

Your Carter object keeps a history of interactions with your carter agent. You can access this through carter.history. carter.history is an array containing CarterInteraction objects.

This entire array is accessible in full, and is ordered with the most recent interaction at the front of the array. For convenience, you can also invoke Carter.latest() which will return the most recent interaction.

For more information and full documentation on carter-js - including audio input, the context endpoint, and more see the GitBook Docs.

4.2.0

10 months ago

4.0.1

11 months ago

4.0.0

11 months ago

3.0.0

1 year ago

2.2.0

1 year ago

2.1.0

1 year ago

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.6.2

1 year ago

1.6.1

1 year ago

1.5.1

1 year ago

1.5.0

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.0

2 years ago

1.1.1

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago