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)
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})
Release files for grinning-cat-python-sdk 1.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| grinning_cat_python_sdk-1.0.5.tar.gz | 44.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| grinning_cat_python_sdk-1.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 106.6 kB
Release files / grinning_cat_python_sdk-1.0.5.tar.gz
| Download URL | grinning_cat_python_sdk-1.0.5.tar.gz |
|---|---|
| Size | 44.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0658c03d8594490c14ff996c6598397ac3d4d4d07360c9c2a680b9e1e648e95a
|
|
BLAKE2b-256 checksum How to use checksums |
b7ffa3e529a24eade5637e7ebf86a0e97e42498e754c2c115852dae717530154
|
| 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.5-py3-none-any.whl
| Download URL | grinning_cat_python_sdk-1.0.5-py3-none-any.whl |
|---|---|
| Size | 62.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
59377791bbdcd96d8cf555ae02d086a5eb879526aa687df4dfc940557ef5e33b
|
|
BLAKE2b-256 checksum How to use checksums |
ac3ca9a87316a1cbc930dc8c32e0bb649f1e693b44c13a7dbc1220fb46e10714
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|