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

ccat-api

v0.10.6

Published

API Client to communicate with the Cheshire Cat AI

Downloads

192

Readme

Cheshire Cat AI API Client

API Client made in TypeScript to communicate with the Cheshire Cat AI.
The package provides a class to interface with the Cheshire Cat AI backend.
It can be used both in Browser and NodeJS environments.

Every endpoint is a CancelablePromise, which means you can cancel the request if you want.

Installation

npm install ccat-api
# OR
yarn add ccat-api
# OR
pnpm i ccat-api

Getting started

To set up the client, you must first import the CatClient class:

import { CatClient } from 'ccat-api'

const cat = new CatClient({
    baseUrl: 'localhost',
    user: 'user'.
    //... other settings
})

cat.send('Hello from a user!') // this will send a message to the /ws/user

cat.userId = 'new_user'

cat.send('Hello from a new user!') // this will send a message to the /ws/new_user

Client settings

API_KEY, CORE_HOST, CORE_PORT and CORE_USE_SECURE_PROTOCOLS refer to the CCAT Core .env file.

| Property | Type | Default | Description | |:------------:|:--------:|:------------:|:--------------------------------------------------------------------------------:| | baseUrl | string | Required | The same of CORE_HOST | | authKey | string | '' | The same of API_KEY | | port | number | 1865 | The same of the CORE_PORT | | secure | boolean | false | The same of the CORE_USE_SECURE_PROTOCOLS | | user | string | 'user' | The user ID to use for the WebSocket and the API client | | instant | boolean | true | Instantly initialize the WebSocket and the API client, or later with .init() | | timeout | number | 10000 | Timeout for the endpoints, in milliseconds | | headers | object | {} | The headers to send with the API requests | | ws | string | undefined | An object of type WebSocketSettings |

WebSocket settings

| Property | Type | Default | Description | |:------------:|:--------:|:-----------:|:--------------------------------------------------------:| | path | string | 'ws' | Websocket path to use to communicate with the CCat | | retries | number | 3 | The maximum number of retries before calling onFailed | | query | string | undefined | The query to send with the WebSocket connection | | delay | number | 3000 | The delay for reconnect, in milliseconds | | onFailed | function | undefined | The function to call after failing all the retries |

Then, for example, you can configure the LLM like this:

cat.api.settingsLargeLanguageModel.upsertLlmSetting('LLMOpenAIConfig', {
    openai_api_key: 'OPEN_API_KEY'
})

To send a message to the cat, you can:

cat.send('Hello my friend!')

You can listen to the WebSocket events:

cat.onConnected(() => {
    console.log('Socket connected')
}).onMessage(msg => {
    console.log(msg)
}).onError(err => {
    console.log(err)
}).onDisconnected(() => {
    console.log('Socket disconnected')
})

For example, you can get the list of plugins like this:

cat.api.plugins.listAvailablePlugins().then(plugins => {
    console.log(plugins)
})

Credits

Made for the Cheshire Cat AI organization.

This was possible thanks to openapi-typescript-codegen.