genai-processors
GenAI Processors is a lightweight Python library that enables efficient, parallel content processing.
What is genai-processors?
GenAI Processors is a lightweight Python library that enables efficient, parallel content processing.
Overview of genai-processors
What it is
GenAI Processors is a lightweight Python library that enables efficient, parallel content processing. It provides a framework for building modular, asynchronous, and composable AI pipelines for generative AI. The library addresses the fragmentation of LLM APIs through three core pillars: a unified content model for consistent input/output representation, processors as composable Python classes that transform content streams using native asyncio, and built-in asynchronous streaming capabilities.
Key features
- Modular: Breaks down complex tasks into reusable
ProcessorandPartProcessorunits, which can be chained (+) or parallelized (//) to create sophisticated data flows. - Integrated with GenAI API: Includes ready-to-use processors like
GenaiModelfor turn-based API calls andLiveProcessorfor real-time streaming interactions. - Extensible: Allows creation of custom processors by inheriting from base classes or using simple function decorators.
- Rich Content Handling:
ProcessorPartwrapsgenai.types.Partwith metadata like MIME type, role, and custom attributes; supports text, images, audio, and custom JSON. - Asynchronous & Concurrent: Built on Python's
asyncioframework to orchestrate concurrent tasks including network I/O and communication with compute-heavy subthreads. - Stream Management: Utilities for splitting, concatenating, and merging asynchronous streams of
ProcessorParts.
Use cases
- Building real-time audio-in audio-out live agents with tools like Google Search, as demonstrated in the Real-Time Live Example.
- Creating research agents composed of multiple sub-processors, chaining, and custom
ProcessorPartcreation, as shown in the Research Agent Example. - Developing live commentary agents using the Gemini Live API, with separate agents for event detection and conversation management, as illustrated in the Live Commentary Example.
- General parallel content processing and orchestration of generative AI workflows.
Getting started
The library requires Python 3.10+. Install it with:
pip install genai-processors
For detailed guidance, refer to the documentation microsite and the introductory Colab notebooks listed in the repository README.
License and pricing
This project is licensed under the Apache License, Version 2.0. It is open source and free to use.
Based on the project's public README and repository metadata.