Skip to main content

PlayPi

Automate AI chat workflows through browser automation.

PlayPi provides simple, high-level functions for automating browser-based AI chat workflows, starting with Google Gemini Deep Research. The package delegates all browser lifecycle management to the playwrightauthor library, so Chrome for Testing installation and profile handling happen automatically.

Installation

pip install playpi

Or for development:

git clone https://github.com/twardoch/playpi
cd playpi
uv sync

Quick Start

Google Deep Research

import asyncio
from playpi import google_gemini_deep_research

async def main():
    # Perform deep research on a topic
    result = await google_gemini_deep_research(
        "Analyze the impact of quantum computing on cryptography",
        headless=True,  # Retained for compatibility; playwrightauthor runs headed
        timeout=600,    # 10 minute timeout
        verbose=True    # Enable detailed logging
    )

    print(result)  # Markdown-formatted research results

asyncio.run(main())

Command Line Interface

# Standard Gemini prompt with optional file prompt + Deep Think toggle
playpi gemi --file_prompt prompt.md --prompt "Add a concise summary" --deep --output_file response.md

# Single or multi Deep Research via JSON piped on stdin
printf '{"prompt": "What are the latest developments in renewable energy?"}' | playpi gemi_dr
cat jobs.json | playpi gemi_dr

# Test browser session
playpi test

Headless flags are currently ignored because playwrightauthor always operates Chrome in headed mode.

Prerequisites

Authentication

Before using Google Deep Research, you need to:

  1. Login to Google: Open https://gemini.google.com in your browser and sign in
  2. Browser profiles: PlayPi relies on playwrightauthor-managed profiles, so you only need to login once in the selected profile

System Requirements

  • Python 3.12+
  • Chrome for Testing (downloaded automatically by playwrightauthor)
  • 2GB+ RAM for browser automation
  • Internet connection

Features

  • ✅ Google Gemini Deep Research - Automated research with source compilation
  • ✅ Session Management - Persistent authentication across multiple queries
  • ✅ Cross-Platform - Works on Windows, macOS, and Linux
  • ✅ Concurrent Processing - Run up to 3 research tasks simultaneously
  • ✅ Rich Output - Clean Markdown formatting with links and structure
  • ✅ Error Handling - Graceful handling of timeouts and UI changes

API Reference

google_gemini_deep_research(prompt, **options)

Perform Google Gemini Deep Research on a given prompt.

Parameters:

  • prompt (str): Research query or question
  • headless (bool): Retained for compatibility; playwrightauthor currently launches Chrome in headed mode (default: True)
  • timeout (int): Maximum wait time in seconds (default: 600)
  • verbose (bool): Enable detailed logging (default: False)
  • profile (str): Browser profile name managed by playwrightauthor (default: "default")

Returns:

  • str: Research results formatted as Markdown

Raises:

  • AuthenticationError: Not logged in to Google/Gemini
  • PlayPiTimeoutError: Research exceeded timeout limit
  • ProviderError: UI elements not found or changed

Development

Running Tests

# Run all tests without hitting live Gemini login
PLAYPI_FORCE_AUTH_FAILURE=1 uvx hatch run test:python -m pytest

# Run with coverage (same auth guard applies)
PLAYPI_FORCE_AUTH_FAILURE=1 uvx hatch run test:python -m pytest --cov=src/playpi --cov-report=html

# Run specific test categories
PLAYPI_FORCE_AUTH_FAILURE=1 uvx hatch run test:python -m pytest tests/test_session.py -v

PLAYPI_FORCE_AUTH_FAILURE=1 short-circuits the authentication check during testing so suites do not wait for manual Google sign-in.

Code Quality

# Format code
uv run ruff format

# Lint code
uv run ruff check

# Type checking
uv run mypy src/playpi

License

MIT License. See LICENSE for details.

Release files for playpi 1.0.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for playpi 1.0.13
File Size Uploaded
playpi-1.0.13.tar.gz 10.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for playpi 1.0.13
File Interpreter ABI Platform
playpi-1.0.13-py3-none-any.whl Python 3 none any Details

Total release size: 34.9 kB

Release files / playpi-1.0.13.tar.gz

Download URL playpi-1.0.13.tar.gz
Size 10.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a8d5543a3707c7dd3408989caea7cfb218c6fa8cf70caa48c73ea53def8c08ea
BLAKE2b-256 checksum
How to use checksums
48d9d8f35bb282f1ed3aa25ae124b684fc4dd969735acb3a2bff496f554e4c17
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.15

Release files / playpi-1.0.13-py3-none-any.whl

Download URL playpi-1.0.13-py3-none-any.whl
Size 24.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
092d49c7b14482a2172b416d2c9d005ad6fa4f824a8d7fd1fb929dc0572ef519
BLAKE2b-256 checksum
How to use checksums
20490a8aa63a1c46f4d8a67f17ee12d3f753650067d5ab94d941b9a4ed60aada
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.15

Release history Release notifications | RSS feed

This release

1.0.13 This release

2 release files

1.0.12

2 release files

1.0.11

2 release files

1.0.10

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page