Ptree: Interactive Tree of Life Explorer Blog & articles

Blog · Backend · · 4 min read

Rehearsing AI tours on the real viewer

Ptree’s question box answers with a guided tour on the visitor’s screen instead of a chat log. A quick opener speaks and classifies the question while the main guide inspects the tree, streams short stretches of UI moves paired with captions, and rehearses every stop against the live viewer code in a worker thread before a word reaches the browser.

Keeping the visitor ahead of the model

Waiting for a language model to plan a twenty-stop tour before anything moves leaves the visitor staring at a frozen screen. Ptree overlaps every stage in parallel so that classification, lookups, failed stops, and rewrites all finish behind a moving playback buffer:

Parallel timeline of a guided tour turn: the visitor watches an uninterrupted sequence of opening line, stretch 1, repaired stretch 2, and closing answer over 15 seconds while the quick opener classifies the question, the guide looks up data and streams stretches, and the rehearsal worker catches and discards a bad click in stretch 2 so a rewritten stretch arrives 0.9 seconds before playback catches up0 s3 s6 s9 s12 s15 sVisitor’s screenuninterruptedRehearsal workerlive viewer DOMGuide modellookups & scriptQuick openerruns at t = 0Opening line+ tree colorStretch 1 plays5 s playback bufferStretch 2 playsrepaired seamlesslyAnswershareable link✓ 1✗ Cut✓ 2✓ 3bad click discardednever sent to screenLook 1Say 1Look + Say 2Rewrite 2Look + AnswerOpenerspeaks opening line while classifying command / fact / open / site,safety concern, language, or a published-tour match (which cancels the guide)queued 0.9 s earlyVerified playback on screen (zero dead air)Rehearsed & queued aheadFailed stop cut & replaced
  1. At t = 0, a fast opener model starts streaming one non-committal spoken sentence while classifying the question’s size (command, fact, open, or site), safety concern, language, and whether the question already matches a curated published tour. If a published tour matches, the background guide is canceled immediately and the curated script plays at zero guide cost.
  2. Without waiting for the opener to finish, the guide starts its first batch of tree lookups in parallel. As soon as that first lookup names a property, the viewer switches the tree to that color while the opening line is still playing.
  3. Rather than planning the entire tour before speaking, the guide sends short stretches through say. Each say call reports how many seconds of verified playback are queued on the visitor’s screen. Thinking is free while beats are playing and only costs the visitor on a still screen, so a turn that thinks too long with an empty queue is cut short and told to write from what it already holds.
  4. If the rehearsal worker catches a broken click during Stretch 2, it cuts the model’s stream immediately, discards everything from the failed stop onward, leaves the worker at the last valid stop, and returns the exact error to the guide. While Stretch 1 is still playing on the visitor’s screen, the guide rewrites Stretch 2 and queues the repaired beats ahead of the playhead. The visitor experiences one continuous tour with zero dead air and never sees the discarded attempt.

Reading what the visitor sees

The guide inspects the tree through read tools that return the exact formatting shown on screen:

  • see reads a taxon’s lineage, sibling and child rows, property readouts, numeric spreads, range descriptions, citations, interactions, and active filters.
  • compare runs the multi-tree ancestry lookup and side-by-side property table from Compare.
  • article and look read the offline Wikipedia book and describe the organism’s served photograph through a vision pass when appearance matters.
  • read opens Ptree’s public documentation pages (/about/, /about/methods.html, /about/source-errors.html) for questions about the site itself.

Every row includes its bracketed node ID so follow-up lookups address exact taxa rather than guessing spellings.

Moves paired with captions

Instead of paragraphs of prose, the model calls say and answer with beats in Ptree’s tour grammar: a bracketed UI verb followed by a short spoken caption.

[click property=nutrition] “Nutrition colors every branch by how organisms feed.”
[click legend=parasitic] “Pressing parasitic lights every lineage that takes food from a host.”

In the browser, the tour player moves a cursor across the screen, clicks controls, brushes legend categories, drags filter thumbs, highlights sentences in Wikipedia articles, and speaks each caption sentence by sentence. When the tour finishes, the viewer stays in that state, and the visitor has watched every click needed to reproduce it.

Running every stop in a worker first

Models hallucinate UI targets: tiles folded into the gutter, legend cells belonging to another property, or interaction partners not listed on the current page. Rather than letting a broken click reach the visitor, the rehearsal stage boots the real viewer modules inside a linkedom worker thread against the local origin at the visitor’s exact route and column count.

As each beat streams from say or answer, the gate parses the grammar, resolves named places through /api/place, and executes the stop on the worker’s live DOM. Because the stream is cut on the first refusal rather than read to completion, the guide never wastes tokens writing six more stops against a screen state that will never exist.

Every ordinary tour that plays to completion without a visible flaw receives a deterministic three-word link (/?tour=word-word-word) stored beside the data generation digest it passed against.

When Ptree rebuilds its biodiversity stores, taxonomy and traits can shift. Rather than discarding old links or serving broken scripts, the first request for a tour from an older generation runs a single-flight rehearsal against the new data. If every stop still lands, the tour is stamped with the new generation and replays at zero model cost. If a stop breaks, only that tour is rewritten once under the same link.