npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

carter-js

v4.2.0

Published

A utility module for easy integration with Carter

Downloads

10

Readme

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.