New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ccat-api

Package Overview
Dependencies
Maintainers
1
Versions
42
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.6.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
43
decreased by-32.81%
Maintainers
1
Weekly downloads
 
Created
Source

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 Python Server.
It can be used both in Browser or NodeJS environment.

Every endpoint is a CancelablePromise, it 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',
    //... other settings
})

Client settings

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

PropertyTypeDefaultDescription
baseUrlstringRequiredThe same of CORE_HOST
authKeystring''The same of API_KEY
portstring'1865'The same of the CORE_PORT
instantbooleantrueInstantly initialize the websocket and the API client, or later with .init()
securebooleanfalseThe same of the CORE_USE_SECURE_PROTOCOLS
timeoutnumber10000Timeout for the endpoints, in milliseconds
wsstringundefinedAn object of type WebSocketSettings

WebSocket settings

PropertyTypeDefaultDescription
pathstring'ws'Websocket path to use to communicate with the CCat
retriesnumber3The maximum number of retries before calling onFailed
delaynumber3000The delay for reconnect, in milliseconds
onFailed(ErrorCode) => voidundefinedThe 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.

Keywords

FAQs

Package last updated on 21 Jul 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