Skip to main content

Turn any directed graph into colored ASCII art for your terminal

Project description

graphtty

PyPI downloads PyPI - Version Python versions

Turn any directed graph into colored ASCII art for your terminal. Pure Python, zero external dependencies.

Installation

pip install graphtty

Deep Agent (ocean theme)

Supervisor Agent (dracula theme)

More examples available in the screenshots/ directory.

Quick start

from graphtty import render

graph = {
    "nodes": [
        {"id": "start", "name": "User Input", "type": "entry"},
        {"id": "router", "name": "Router", "type": "condition"},
        {"id": "search", "name": "Web Search", "type": "tool"},
        {"id": "calc", "name": "Calculator", "type": "tool"},
        {"id": "respond", "name": "Respond", "type": "model"},
    ],
    "edges": [
        {"source": "start", "target": "router"},
        {"source": "router", "target": "search", "label": "search"},
        {"source": "router", "target": "calc", "label": "calc"},
        {"source": "search", "target": "respond"},
        {"source": "calc", "target": "respond"},
    ],
}

print(render(graph))
           ┌ entry ─────┐
           │ User Input │
           └─────┬──────┘
                 │
                 ▼
          ┌ condition ──┐
          │   Router    │
          └──────┬──────┘
         ┌search─└──calc───┐
         ▼                 ▼
  ┌ tool ──────┐    ┌ tool ──────┐
  │ Web Search │    │ Calculator │
  └──────┬─────┘    └──────┬─────┘
         └───────┌─────────┘
                 ▼
            ┌ model ──┐
            │ Respond │
            └─────────┘

Nodes support descriptions and nested subgraphs:

# Descriptions appear as extra lines inside the box
{"id": "a", "name": "LLM", "type": "model", "description": "gpt-4o"}

# Nested subgraphs render as boxes within boxes
{"id": "b", "name": "Pipeline", "type": "subgraph", "subgraph": {"nodes": [...], "edges": [...]}}

Apply a color theme:

from graphtty import render, RenderOptions, get_theme

print(render(graph, RenderOptions(theme=get_theme("monokai"))))

CLI

graphtty graph.json
graphtty graph.json --theme monokai
graphtty graph.json --ascii
graphtty graph.json --no-types

Themes

Ten built-in color themes:

default monokai ocean forest dracula solarized nord catppuccin gruvbox tokyo-night

graphtty --list-themes

JSON format

graphtty reads a simple JSON format:

{
  "nodes": [
    { "id": "a", "name": "Start", "type": "entry" },
    { "id": "b", "name": "Process", "type": "tool", "description": "optional detail" },
    { "id": "c", "name": "End", "type": "exit" }
  ],
  "edges": [
    { "source": "a", "target": "b", "label": "optional" },
    { "source": "b", "target": "c" }
  ]
}

Benchmarks

graphtty uses a custom Sugiyama-style layout engine and optimized canvas operations for fast rendering. Benchmarks across all 12 sample graphs (50 iterations each, Python 3.11):

Sample Avg (ms) Ops/sec
react-agent (4 nodes) 0.15 6,593
book-writer-agent (6 nodes) 0.25 4,083
deep-agent (7 nodes) 0.32 3,144
function-agent (8 nodes) 0.37 2,686
travel-rag-agent (8 nodes) 0.41 2,451
workflow-agent (11 nodes) 0.49 2,060
world-map (15 nodes) 0.61 1,651
orchestrator-agent (9 nodes) 0.64 1,561
rag-pipeline (10 nodes) 0.70 1,427
supervisor-agent (7+subs) 0.80 1,250
etl-pipeline (12 nodes) 0.82 1,225
code-review (8+subs) 1.21 829

Run python scripts/benchmark.py to reproduce on your machine.

Related Projects

  • uipath-dev: Developer console for debugging and inspecting AI agents
  • uipath-python: Python SDK and CLI to build, test, and deploy AI agents

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

graphtty-0.1.7.tar.gz (646.2 kB view details)

Uploaded Source

Built Distribution

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

graphtty-0.1.7-py3-none-any.whl (25.2 kB view details)

Uploaded Python 3

File details

Details for the file graphtty-0.1.7.tar.gz.

File metadata

  • Download URL: graphtty-0.1.7.tar.gz
  • Upload date:
  • Size: 646.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for graphtty-0.1.7.tar.gz
Algorithm Hash digest
SHA256 e4919c4de785b8b87833b2b028d0bf8428d815c2873c781aed9832669aab9b53
MD5 9b83a795dfbcf19d753526033d0b7420
BLAKE2b-256 85d9ccf6476603cac1b909e1c226eefd9f52894c56ceb40c1b255a49745cfaf2

See more details on using hashes here.

Provenance

The following attestation bundles were made for graphtty-0.1.7.tar.gz:

Publisher: cd.yml on UiPath/graphtty

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file graphtty-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: graphtty-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 25.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for graphtty-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 21b381c5237b899e98b58b1cb72e698032e8be3c3209c702158a8d46ebe4ca9f
MD5 2f4b9044d4879aa420cfd22620534855
BLAKE2b-256 07c5cd45b8ce42bc030a93872e0f4a1af2fcd69f2805ccd39e4315f955ce1535

See more details on using hashes here.

Provenance

The following attestation bundles were made for graphtty-0.1.7-py3-none-any.whl:

Publisher: cd.yml on UiPath/graphtty

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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