Skip to main content

😸 Cheshire-Cat API Client

Project description

Cheshire Cat API client

API to develop Python clients to interact with the Cheshire Cat.

The package allows instantiating a WebSocket client and provides the API to interact with all the endpoints.

A part of this Python package is automatically generated by the OpenAPI Generator project.

For deeper documentation about the available endpoints, please refer to the API ReDoc. The official Cheshire Cat documentation is available here.

Requirements.

Python 3.10

Installation & Usage

pip install

You can install the API with pip:

pip install cheshire-cat-api

Then import the package:

import cheshire_cat_api as ccat

Interact with the HTTP Endpoints

Available APIs

The CatClient has the following attributes to easily interface with the related APis:

  • memory
  • plugins
  • rabbit_hole
  • status
  • embedder
  • settings
  • llm

Instantiate connection

import cheshire_cat_api as ccat

# A config is necessary to set up base parameters like
# URL, port, user_id, etc.
config = ccat.Config(user_id="my_user_42")

# Connect to the API
cat_client = ccat.CatClient(
    config=config
)

Plugin API - Retrieve plugins

# Now retrieve a list of the available plugins
plugins = cat_client.plugins.get_available_plugins()

RabbitHole API - Upload a URL

from cheshire_cat_api.models.body_upload_url import BodyUploadUrl

# Please note that interacting with the RabbitHole to upload
# a URL requires structuring the body like this

body_upload_url = BodyUploadUrl(
    url="https://cheshire-cat-ai.github.io/docs/conceptual/cheshire_cat/rabbit_hole/"
)

# then you can make the request as follows
response = cat_client.rabbit_hole.upload_url(body_upload_url)

Send a WebSocket message

import time
import cheshire_cat_api as ccat

# A config is necessary to set up base parameters like
# URL, port, user_id, etc.
config = ccat.Config(user_id="my_user_42")
cat_client = ccat.CatClient(config=config)

# Connect to the WebSocket API
cat_client.connect_ws()

while not cat_client.is_ws_connected: 
# A better handling is strongly advised to avoid an infinite loop 
    time.sleep(1)
    
# Send the message
cat_client.send(message="Hello Cat!")

# Close connection
cat_client.close()

Documentation for Config

Both the classes are available with:

from cheshire_cat_api import Config
Class Name Default Description
Config base_url "localhost" base URL where the Cat is hosted
Config port 1865 port for the connection
Config user_id "user" id of the client
Config auth_key "" authentication key for the http endpoints
Config secure_connection False if to use secure protocol

Low-level API

For a more advanced usage, you can directly interact with the auto-generated client. For documentation see here

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cheshire_cat_api-1.4.9.tar.gz (31.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cheshire_cat_api-1.4.9-py3-none-any.whl (49.3 kB view details)

Uploaded Python 3

File details

Details for the file cheshire_cat_api-1.4.9.tar.gz.

File metadata

  • Download URL: cheshire_cat_api-1.4.9.tar.gz
  • Upload date:
  • Size: 31.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.11.0 Linux/6.8.0-1020-azure

File hashes

Hashes for cheshire_cat_api-1.4.9.tar.gz
Algorithm Hash digest
SHA256 c3eb0d17f0b8003871a70315d558e4d20ad2a123322dd7b5f08a4310e799a4e2
MD5 483f062cead62a2cc780d8754c8a8476
BLAKE2b-256 fdc3f0002343a0251300bef114c1803c72a2bc51bb9de1d3f3e68f50abda1991

See more details on using hashes here.

File details

Details for the file cheshire_cat_api-1.4.9-py3-none-any.whl.

File metadata

  • Download URL: cheshire_cat_api-1.4.9-py3-none-any.whl
  • Upload date:
  • Size: 49.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.11.0 Linux/6.8.0-1020-azure

File hashes

Hashes for cheshire_cat_api-1.4.9-py3-none-any.whl
Algorithm Hash digest
SHA256 ddd831b05d0afa31ab7ae642ca1612326ff3801ce7b9d672851beb1c67d93544
MD5 d091570f2e66cfeca967fb10501f3ba2
BLAKE2b-256 aa652d0664bc3bf455464cdd18032806e4a6c82ea2bd02ed82f1c8363cc1d55d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page