Setup
Here we include some examples of how to use Cancelable and what it can do.
Installation
Install Cancelable with the examples dependencies:
This installs the core library plus dependencies for running all examples:
google-genai- For LLM streaming examplespynput- For keyboard input monitoringpsutil- For system resource monitoring
Getting the Examples
The examples are available in the GitHub repository.
Running Examples
Navigate to the examples directory and run any example:
Optional Dependencies
Different examples require different integration libraries. Install only what you need:
Web Framework (FastAPI)
For FastAPI examples:
Examples requiring this:
- 03_integrations/04_fastapi_example.py
All Integrations
Install everything at once:
Environment Variables
Some examples require API keys or configuration:
LLM Examples
The LLM streaming example requires a Gemini API key:
# Get your API key from https://aistudio.google.com/app/apikey
export GEMINI_API_KEY="your-api-key-here"
# Run the LLM example
python 06_llm/01_llm_streaming.py
API Key Required
Without a valid API key, the LLM examples will fail. All other examples work without any API keys.