0.10.6 • Published 1 month ago

ccat-api v0.10.6

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

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.

PropertyTypeDefaultDescription
baseUrlstringRequiredThe same of CORE_HOST
authKeystring''The same of API_KEY
portnumber1865The same of the CORE_PORT
securebooleanfalseThe same of the 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
headersobject{}The headers to send with the API requests
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
querystringundefinedThe query to send with the WebSocket connection
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.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.

0.10.4

1 month ago

0.10.5

1 month ago

0.10.6

1 month ago

0.10.3

2 months ago

0.10.2

2 months ago

0.10.1

2 months ago

0.10.0

2 months ago

0.9.3

3 months ago

0.9.2

4 months ago

0.9.1

4 months ago

0.9.0

5 months ago

0.8.1

6 months ago

0.7.2

8 months ago

0.4.5

10 months ago

0.8.0

6 months ago

0.7.1

9 months ago

0.6.2

9 months ago

0.4.4

10 months ago

0.7.3

8 months ago

0.5.0

10 months ago

0.7.0

9 months ago

0.6.1

10 months ago

0.6.0

10 months ago

0.5.1

10 months ago

0.4.3

10 months ago

0.4.2

10 months ago

0.4.1

10 months ago

0.4.0

10 months ago

0.3.1

11 months ago

0.3.0

11 months ago

0.2.3

11 months ago

0.2.2

11 months ago

0.2.1

11 months ago

0.2.0

11 months ago

0.1.1

11 months ago

0.1.0

11 months ago