### Install Cheshire Cat API Python Client Source: https://github.com/cheshire-cat-ai/api-client-py/blob/main/README.md Installs the `cheshire-cat-api` Python package using pip, making the library available for use in Python projects. ```sh pip install cheshire-cat-api ``` -------------------------------- ### Import Cheshire Cat API Package Source: https://github.com/cheshire-cat-ai/api-client-py/blob/main/README.md Imports the installed `cheshire_cat_api` package into a Python script, commonly aliased as `ccat` for brevity. ```python import cheshire_cat_api as ccat ``` -------------------------------- ### Retrieve Available Plugins (HTTP) Source: https://github.com/cheshire-cat-ai/api-client-py/blob/main/README.md Shows how to access the `plugins` attribute of the `CatClient` and call the `get_available_plugins` method to fetch a list of installed plugins via the HTTP API. ```python # Now retrieve a list of the available plugins plugins = cat_client.plugins.get_available_plugins() ``` -------------------------------- ### Send Message via WebSocket Source: https://github.com/cheshire-cat-ai/api-client-py/blob/main/README.md Provides an example of connecting to the WebSocket API, waiting for the connection to be established, sending a message using the `send` method, and finally closing the connection. ```python 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() ``` -------------------------------- ### Instantiate CatClient with Config Source: https://github.com/cheshire-cat-ai/api-client-py/blob/main/README.md Demonstrates how to create a `Config` object to define connection parameters (like user ID) and then use it to instantiate the main `CatClient` for interacting with the API. ```python 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 ) ``` -------------------------------- ### Import Config Class Source: https://github.com/cheshire-cat-ai/api-client-py/blob/main/README.md Shows the specific import statement needed to directly access the `Config` class from the `cheshire_cat_api` package. ```python from cheshire_cat_api import Config ``` -------------------------------- ### Specifying Python Test Dependencies Source: https://github.com/cheshire-cat-ai/api-client-py/blob/main/test-requirements.txt These lines define the necessary Python packages and their acceptable version ranges required to execute the project's test suite. They include the core pytest framework, a plugin for test coverage reporting, and a plugin for randomizing test execution order. ```Python pytest~=7.1.3 pytest-cov>=2.8.1 pytest-randomly>=3.12.0 ``` -------------------------------- ### Upload URL via RabbitHole API (HTTP) Source: https://github.com/cheshire-cat-ai/api-client-py/blob/main/README.md Illustrates how to use the `rabbit_hole` API attribute to upload a URL. It requires creating a `BodyUploadUrl` object with the target URL before making the request. ```python 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) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.