Coming Soon
The Knowlify Python package is currently under development and will be available soon.The Python package will automatically generate explanatory videos from your Python code by capturing it and sending it to Knowlify’s AI service.
Installation
Once released, you’ll be able to install the package using pip:Quick Start
The package will work by simply callingknowlify.create() in your Python code:
API Reference
Main Functions
create(mode=“grant”, wait=False, function=None)
Creates a video from your Python code. Parameters:mode(str, optional): Video generation mode. Either “grant” or “prism”. Defaults to “grant”wait(bool, optional): If True, blocks until video is ready and returns the URL. If False (default), runs in backgroundfunction(str, optional): Name of specific function to capture. Supports “function_name” or “Class.method_name”
str: Video URL ifwait=True. Ifwait=False, returns empty string and saves video to./knowlify_videos/directory without hanging the terminal
start()
Marks the beginning of a code region to capture. Must be paired withend().
Example:
end(mode=“grant”, wait=False)
Closes the active capture region and generates a video. Parameters:mode(str, optional): Video generation mode. Either “grant” or “prism”. Defaults to “grant”wait(bool, optional): If True, blocks until video is ready and returns the URL. If False (default), runs in background
str: Video URL ifwait=True. Ifwait=False, returns empty string and saves video to./knowlify_videos/directory without hanging the terminal
Usage Patterns
1. One-Shot Capture (Default)
2. Region-Based Capture
3. Function-Specific Capture
Video Modes
Grant Mode (“grant”)
- Quick generation using finetuned live generation
- Suitable for simple code explanations
- Faster processing time
Prism Mode (“prism”)
- Pre-rendered high-quality videos
- More comprehensive explanations
- Better for complex algorithms and concepts
Output
Videos will be automatically saved to the./knowlify_videos/ directory in your current working directory. The package will:
- Create the directory if it doesn’t exist
- Download the generated video as an MP4 file
- Handle filename conflicts by adding timestamps
- Print the save location to console
Error Handling
The package will raiseKnowlifyError for common issues:
- Source file not found
- Function not found when using function parameter
start()called without matchingend()end()called without matchingstart()- Invalid mode parameter
Requirements
- Python 3.8+
- Internet connection (for video generation)
- websockets package (automatically installed)
Stay Updated
For now, please use our REST API directly. Check back soon for the Python SDK release!Use REST API
Start building with our REST API while the SDK is in development.
