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 (includes a planner-executor workflow):

python examples/simple_demo.py

Open http://localhost:8000 in your browser and send a message to see the agents in action.

For frontend development with hot-reload:

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

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

Then open http://localhost:5173 instead.

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.2.0.tar.gz (403.4 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.2.0-py3-none-any.whl (403.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pixelgraph-0.2.0.tar.gz
Algorithm Hash digest
SHA256 24bf693440a40496566dfc694665062f2d74e47eb7ab6649e0aa3a675c545b40
MD5 95beca4183ea02285eb06ea42bcb7c1a
BLAKE2b-256 84d7a128167002385efa4d08c32b3f4cf2323543d768531cc5e7c18bd31915a7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pixelgraph-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 403.9 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6f24031ad72ab679645266bff5858bdfce299aaa02187c8688d24fc1047a9728
MD5 22a5f7ffcd42996e22d1995dac499663
BLAKE2b-256 b26d67e3afaf6f192945c1c401bff4720d24f99c1427e3d87630a99abfc62532

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