Skip to content

matteocacciola/cheshirecat-python-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CheshireCat Python SDK


CheshireCat Python SDK is a library to help the implementation of Cheshire Cat on a Python Project

Installation

To install CheshireCat Python SDK, run:

pip install cheshirecat-python-sdk

Usage

Initialization and usage:

from cheshirecat_python_sdk import CheshireCatClient, Configuration

configuration = Configuration(host="localhost", port=1865, auth_key="test", secure_connection=False)

cheshire_cat_client = CheshireCatClient(configuration)

Send a message to the websocket:

from cheshirecat_python_sdk import CheshireCatClient, Configuration, Message

configuration = Configuration(host="localhost", port=1865, auth_key="test", secure_connection=False)
cheshire_cat_client = CheshireCatClient(configuration)

notification_closure = lambda message: None # handle websocket notification, like chat token stream

# result is the result of the message
result = cheshire_cat_client.message.send_websocket_message(
    Message("Hello world!", 'user', []),  # message body
    notification_closure # websocket notification closure handle
)

Load data to the rabbit hole:

import asyncio

from cheshirecat_python_sdk import CheshireCatClient, Configuration, Message

configuration = Configuration(host="localhost", port=1865, auth_key="test", secure_connection=False)
cheshire_cat_client = CheshireCatClient(configuration)

# file
file = "path/to/file"
result = asyncio.run(cheshire_cat_client.rabbit_hole.post_file(file, None, None))

# url
url = "https://www.google.com"
result = asyncio.run(cheshire_cat_client.rabbit_hole.post_web(url, None, None))

Memory management utilities:

from cheshirecat_python_sdk import Collection, CheshireCatClient, Configuration, Message

configuration = Configuration(host="localhost", port=1865, auth_key="test", secure_connection=False)
cheshire_cat_client = CheshireCatClient(configuration)

cheshire_cat_client.memory.get_memory_collections()  # get number of vectors in the working memory
cheshire_cat_client.memory.get_memory_recall("HELLO")  # recall memories by text

url = "https://www.google.com"

# delete memory points by metadata, like this example delete by source
cheshire_cat_client.memory.delete_memory_points_by_metadata(Collection.DECLARATIVE, {"source": url})

About

😸 Cheshire-Cat API Client

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published