Skip to main content

Automate AI chat workflows through browser automation

Project description

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.

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_deep_research

async def main():
    # Perform deep research on a topic
    result = await google_deep_research(
        "Analyze the impact of quantum computing on cryptography",
        headless=True,  # Run browser in background
        timeout=600,    # 10 minute timeout
        verbose=True    # Enable detailed logging
    )

    print(result)  # Markdown-formatted research results

asyncio.run(main())

Command Line Interface

# Perform research and save to file
playpi google "What are the latest developments in renewable energy?" --output research.md

# Interactive mode (visible browser)
playpi google "Climate change mitigation strategies" --headless=false --verbose

# Test browser session
playpi test

Prerequisites

Authentication

Before using Google Deep Research, you need to:

  1. Install Playwright browsers: playwright install chromium
  2. Login to Google: Open https://gemini.google.com in your browser and sign in
  3. Browser profiles: PlayPi reuses browser sessions, so you only need to login once

System Requirements

  • Python 3.12+
  • Chromium browser (installed automatically)
  • 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_deep_research(prompt, **options)

Perform Google Gemini Deep Research on a given prompt.

Parameters:

  • prompt (str): Research query or question
  • headless (bool): Run browser in headless mode (default: True)
  • timeout (int): Maximum wait time in seconds (default: 600)
  • verbose (bool): Enable detailed logging (default: False)
  • profile (str): Browser profile name (reserved for future use)

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
uv run pytest

# Run with coverage
uv run pytest --cov=src/playpi --cov-report=html

# Run specific test categories
uv run pytest tests/test_session.py -v

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

playpi-1.0.3.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

playpi-1.0.3-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

Details for the file playpi-1.0.3.tar.gz.

File metadata

  • Download URL: playpi-1.0.3.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.15

File hashes

Hashes for playpi-1.0.3.tar.gz
Algorithm Hash digest
SHA256 f154f1c2b703bbc827aad80108052f5c6b28f15d2da42d3f717ab98422a8375f
MD5 6b41a04cb94840451a7750d4a236e95f
BLAKE2b-256 7a48754999133fcbdd26f3e5ceaea9e2562d2c4e379c24f6a037787a5f0f7d8a

See more details on using hashes here.

File details

Details for the file playpi-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: playpi-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 14.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.15

File hashes

Hashes for playpi-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7cfbb1c93bf6e3c5a41b863ba38e07658aa9cc4bec9ecc04726caa27a01c65c6
MD5 6cdcf0ec8e039fe52ddfffa8cd4afcf7
BLAKE2b-256 8a53a1250f5a158ac57ed17c6480807a3bd43fd74c95ee6c64f98c1c9aabb185

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page