Skip to main content

8-bit visualization for LangGraph agents

Project description

PixelGraph

8-bit visualization for LangGraph agents

PixelGraph transforms your LangGraph agent interactions into a retro 8-bit game experience. Watch your AI agents think, speak, and use tools in a nostalgic pixel-art environment.

Features

  • Drop-in Integration: Works with any existing LangGraph application
  • Real-time Visualization: See agent thoughts, speech, and tool usage
  • 8-bit Aesthetics: Pixel art sprites and retro styling
  • WebSocket Communication: Bidirectional real-time updates
  • Action Queue: Smooth animation sequencing regardless of event speed

Quick Start

Installation

# Clone the repository
git clone https://github.com/diegonov1/PixelGraph.git
cd PixelGraph

# Install Python dependencies
pip install -r requirements.txt

# Install frontend dependencies
cd frontend && npm install && cd ..

Run Demo Mode

Without any LLM API key, you can run the demo:

# Terminal 1: Start backend
python examples/simple_demo.py

# Terminal 2: Start frontend
cd frontend && npm run dev

Open http://localhost:3000 in your browser.

Run with LangGraph

# Set your OpenAI API key
export OPENAI_API_KEY=your-api-key

# Run the LangGraph example
python examples/langgraph_example.py

Usage

Integrate PixelGraph with your existing LangGraph application:

from langgraph.graph import StateGraph
from pixelgraph import GameServer

# Your existing LangGraph code
graph = StateGraph(State)
# ... add nodes and edges ...
app = graph.compile()

# Add visualization with one line
server = GameServer(app)
server.serve()

Visual Configuration

Customize how agents appear in the game:

from pixelgraph import GameServer
from pixelgraph.schemas.events import VisualConfig, AgentConfig

config = VisualConfig(
    title="My Agent Team",
    theme="dungeon",
    nodes={
        "researcher": AgentConfig(sprite="wizard", color="blue"),
        "writer": AgentConfig(sprite="bard", color="red"),
    }
)

server = GameServer(app, config=config)
server.serve()

Architecture

Frontend (React + Phaser)     Backend (FastAPI + LangGraph)
     ┌─────────────┐              ┌─────────────┐
     │   Phaser    │◄─WebSocket──►│  GameServer │
     │   Canvas    │              │             │
     └─────────────┘              │  Callback   │
     ┌─────────────┐              │   Handler   │
     │   React     │              │      ▲      │
     │   HUD/Log   │              │      │      │
     └─────────────┘              │  LangGraph  │
                                  └─────────────┘

Event Flow

  1. LangGraph emits events during execution
  2. GameVisualizerCallbackHandler captures and transforms events
  3. Events are sent via WebSocket to the frontend
  4. Frontend queues events in the ActionQueue
  5. Phaser consumes events one at a time, playing animations

Development

Project Structure

pixelgraph/
├── pixelgraph/          # Python package
│   ├── __init__.py      # Package exports
│   ├── callback.py      # LangChain callback handler
│   ├── server.py        # FastAPI WebSocket server
│   ├── schemas/         # Pydantic event schemas
│   └── static/          # Built frontend (after npm build)
├── frontend/            # React + Phaser frontend
│   ├── src/
│   │   ├── game/        # Phaser logic
│   │   │   ├── scenes/  # Game scenes
│   │   │   ├── entities/# Sprite classes
│   │   │   └── systems/ # Event bus, action queue
│   │   └── components/  # React UI components
│   └── public/assets/   # Sprites and assets
├── examples/            # Usage examples
└── tests/               # Test suite

Commands

make install      # Install all dependencies
make dev          # Run both backend and frontend
make build        # Build frontend for production
make test         # Run tests
make docker-dev   # Run with Docker (development)
make docker-prod  # Run with Docker (production)

Roadmap

  • Multi-agent support with dynamic positioning
  • Tool-specific animations (search, calculator, etc.)
  • Speed control for event playback
  • Custom sprite support
  • Themes (dungeon, sci-fi, city)
  • Export conversation as GIF

License

MIT

Contributing

Contributions welcome! Please read our contributing guidelines first.

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

pixelgraph-0.1.0.tar.gz (402.6 kB view details)

Uploaded Source

Built Distribution

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

pixelgraph-0.1.0-py3-none-any.whl (403.5 kB view details)

Uploaded Python 3

File details

Details for the file pixelgraph-0.1.0.tar.gz.

File metadata

  • Download URL: pixelgraph-0.1.0.tar.gz
  • Upload date:
  • Size: 402.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.7

File hashes

Hashes for pixelgraph-0.1.0.tar.gz
Algorithm Hash digest
SHA256 67580252281324185ed62afbf85d4fd2c2974ee9708da7043b0516828257e7c7
MD5 2c80ff2f5b0487c7dd8ee59d08976781
BLAKE2b-256 dc21cbd8ee7eeccef1d30f36bf3ab88c6e6f0cbe132afaaeeeb1f4f46005eeca

See more details on using hashes here.

File details

Details for the file pixelgraph-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pixelgraph-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 403.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.7

File hashes

Hashes for pixelgraph-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 da3cd4415c9c64f9d0ba78a030ef3b5ed871275821a07d1c62b54d1d9dade64d
MD5 e16542da62ea571709228334de26013f
BLAKE2b-256 799624d4e586e4103165a419c36ed947cd96870cc4885a54dc5c34cd5ac26d6d

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