Skip to main content

Grinning Cat Python SDK


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

Installation

To install Grinning Cat Python SDK, run:

pip install grinning-cat-python-sdk

Usage

Initialization and usage:

from grinning_cat_python_sdk import GrinningCatClient, Configuration

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

cat_client = GrinningCatClient(configuration)

The WebSocket client accepts messages up to 256 MiB by default; change it with Configuration(..., ws_max_size=<bytes>) (None removes the limit).

Authenticate with a username and password (the client keeps the returned access token for the following calls), refresh it before it expires, and log out to revoke the session:

from grinning_cat_python_sdk import GrinningCatClient, Configuration

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

token = cat_client.auth.token("username", "password")
# token.access_token, token.expires_in, token.refresh_token, token.refresh_expires_in

# before the access token expires, exchange the (single-use) refresh token for a new pair
token = cat_client.auth.refresh(token.refresh_token)

# revoke the session; already-issued access tokens stay valid until they expire
cat_client.auth.logout(token.refresh_token)

Send a message to the websocket:

from grinning_cat_python_sdk import GrinningCatClient, Configuration, Message

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

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

# result is the result of the message
result = cat_client.message.send_websocket_message(
    Message(text="Hello world!"),  # message body
    "agent", # agent ID
    "user", # user ID
    callback=notification_closure # websocket notification closure handle
)

Load data to the rabbit hole:

import asyncio

from grinning_cat_python_sdk import GrinningCatClient, Configuration, Message

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

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

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

Memory management utilities:

from grinning_cat_python_sdk import GrinningCatClient, Configuration, Message

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

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

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

# delete memory points by metadata, like this example delete by source
cat_client.memory.delete_memory_points_by_metadata("declarative", "agent", {"source": url})

Metadata

Release files for grinning-cat-python-sdk 1.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for grinning-cat-python-sdk 1.0.6
File Size Uploaded Provenance Actions
grinning_cat_python_sdk-1.0.6.tar.gz 45.5 kB Without provenance Details for grinning_cat_python_sdk-1.0.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for grinning-cat-python-sdk 1.0.6
File Interpreter ABI Platform Actions
grinning_cat_python_sdk-1.0.6-py3-none-any.whl Python 3 none any Details for grinning_cat_python_sdk-1.0.6-py3-none-any.whl

Total release size: 107.8 kB

Release files / grinning_cat_python_sdk-1.0.6.tar.gz

Download URL grinning_cat_python_sdk-1.0.6.tar.gz
Size 45.5 kB
Tags Source
SHA-256 checksum
How to use checksums
868d37713e36cfc9835be82b64b0e9d7aeabddfad916dd20a419cfdaf3e45209
BLAKE2b-256 checksum
How to use checksums
7469736266ac925731808825b30ea2d7f2cf8140c71c8d34ba5661c72bc96754
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / grinning_cat_python_sdk-1.0.6-py3-none-any.whl

Download URL grinning_cat_python_sdk-1.0.6-py3-none-any.whl
Size 62.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
10501952db36b8a3c40e58b61f9d4835aecb2b9cc914297f5484e2810db18ee4
BLAKE2b-256 checksum
How to use checksums
0c01f6d7acbd6f2c08fa2afd8fd8ce5f564d42f1073363cfd59f47db7d09d6b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for grinning-cat-python-sdk 1.0.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page