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

ccat-api

Package Overview
Dependencies
Maintainers
0
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ccat-api

API Client to communicate with the Cheshire Cat AI

  • 0.11.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
55
increased by57.14%
Maintainers
0
Weekly downloads
 
Created
Source
GitHub Stars Discord Server NPM Version NPM Downloads Bundle Size

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 i ccat-api
# OR
yarn add ccat-api
# OR
pnpm i ccat-api
# OR
bun 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({
    host: 'localhost',
    userId: '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

CCAT_API_KEY, CCAT_CORE_HOST, CCAT_CORE_PORT and CCAT_CORE_USE_SECURE_PROTOCOLS refer to the CCAT Core .env file.

PropertyTypeDefaultDescription
hoststringRequiredThe same of CCAT_CORE_HOST
credentialstringundefinedThe same of CCAT_API_KEY or the JWT token
portnumber1865The same of the CCAT_CORE_PORT
securebooleanfalseThe same of the CCAT_CORE_USE_SECURE_PROTOCOLS
userstring'user'The user ID to use for the WebSocket and the API client
instantbooleantrueInstantly initialize the WebSocket and the API client, or later with .init()
timeoutnumber10000Timeout for the endpoints, in milliseconds
wsstringundefinedAn object of type WebSocketSettings

WebSocket settings

PropertyTypeDefaultDescription
retriesnumber3The maximum number of retries before calling onFailed
delaynumber3000The delay for reconnect, in milliseconds
onFailedfunctionundefinedThe function to call after failing all the retries

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

cat.api.llm.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, e) => {
    console.error(err, e)
}).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.

Keywords

FAQs

Package last updated on 15 Oct 2024

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