Docs
search Esc
v10.48.0 AI Optimization

Offline AI Integration

UbuntuPlay features native, on-device AI capabilities—including the Gogo AI Student Tutor and Adaptive Difficulty Engine—running entirely without internet.

auto_awesome
RequirementsThe Gogo AI engine runs in a browser with WebGPU (Chrome/Edge 121+ on a device with a usable GPU) and needs a one-time ~2 GB model download. Translation fallbacks (Tiers 2–3 below) work on any device. After installation, everything runs fully offline.

How It Works — Three Tiers

Every AI request tries the richest available tier and falls back gracefully, so AI features never hard-fail:

TierEngineWhere it runsNeeds
Tier 1 — Gogo LLMLiteRT-LM (Google AI Edge) + Gemma, pure WASM/WebGPUThe teacher's browser (the Gogo tab hosts the engine; the classroom server relays requests over the Gogo Bridge WebSocket)WebGPU + downloaded model
Tier 2 — NLLB-200Neural machine translation microservice (translation only)Optionally alongside the classroom server (port 5001)Optional Python service
Tier 3 — Lookup + cacheFLORES+ phrase/word lookup tables and the server translation cacheClassroom server (ships in every install)Nothing — always available

The bridge page resolves its WebSocket endpoint from GET /api/ai/bridge-info (default port 3001, configurable via WS_BRIDGE_PORT; also served as wss://host:HTTPS_PORT/gogo-bridge). If the Gogo tab is closed or the device has no WebGPU, requests fall through to the lower tiers automatically.

Language Coverage

Tier 3 lookup data is built from FLORES+ (CC-BY-SA-4.0, NLLB Team / Open Language Data Initiative):

LanguageTier 1 (Gogo LLM)Tier 3 (Lookup)
BembaLive translationSentence + word tables included
NyanjaLive translationSentence + word tables included
TongaLive translationNo open dataset exists — falls back to English
LoziLive translationNo open dataset exists — falls back to English

Untranslated strings always fail safely to English, so games remain fully playable in every language.

Capabilities

As of v10.48.0, the platform includes advanced local AI features powered by LiteRT-LM (Google AI Edge) and the Gemma 4 model family, designed for the African classroom context:

  • Gogo AI Tutor: Context-aware hints and support for students during gameplay powered by Gemma 4 E2B.
  • Local Language Translation: Game UIs translate into Bemba, Nyanja, Tonga, and Lozi (see coverage above).
  • AI Level Generation: Dynamic content generation based on curriculum topics.
  • Adaptive Difficulty: Recommends easy/medium/hard from the student's rolling accuracy.
  • Vision Interface: Gesture-controlled interaction via MediaPipe Vision tasks (used by Rangi hand tracking).
  • Voice Input: Web Speech API voice commands where the browser supports it.

Developer API

Games can access AI features via the UbuntuAI global object. The API is resilient and handles lazy-loading of models automatically.

1. Automated Translation

Batch translate multiple strings at once using local language models:

JAVASCRIPT
const translations = await window.UbuntuAI.batchTranslate(
  ["Level 1", "Score", "Game Over"],
  "Bemba"
);
console.log(translations["Level 1"]); // "Ilingi 1"

2. Content Generation

Generate structured level JSON for a game at a chosen difficulty and theme:

JAVASCRIPT
const level = await window.UbuntuAI.generateLevel(
  'nzelu',      // game id
  'medium',     // difficulty
  'Wildlife'    // optional theme
);
// Returns parsed JSON, or null if the engine is unavailable

3. Gesture Tracking

Initialize hand tracking for gesture-based gameplay:

JAVASCRIPT
const tracker = await window.UbuntuAI.initVision('hand');

Installation — Classroom Server

Two equivalent paths install the AI assets on a school server:

BASH
ubuntuplay setup-ai

Or use the model manager in the Teacher Dashboard's Gogo tab, which downloads each model with progress and validates file sizes (placeholder/stub files are never reported as installed). Assets land in public/js/ai/ — the LiteRT-LM runtime, the Gemma model, and MediaPipe vision tasks. The runtime loads with zero CDN dependencies, so it works on fully offline LANs.

Installation — Hub (Browser-Local AI)

The cloud Hub cannot host a teacher's Gogo tab, so it uses a browser-local mode instead: the Hub Admin toggles AI on (Hub Admin → Config), the hub downloads the same asset set to its data volume, and each visitor's browser runs the engine itself via WebGPU. This powers marketplace game demos ("Ask Gogo") and the parent tutor's on-device upgrade.

  • GET /api/ai/status — advertises readiness and the client asset map
  • Downloads resume automatically after an interrupted provisioning run
  • Operators can tune behaviour with the HUB_AI_* environment variables — see Environment Variables →

Troubleshooting

SymptomCause & Fix
"WebGPU Required" on the Gogo tabThe engine needs WebGPU — there is no CPU fallback for the LLM. Use Chrome/Edge 121+ on a device with a GPU. Translation still works via Tiers 2–3.
Bridge shows offlineCheck GET /api/ai/bridge-info — it reports the configured WebSocket port and whether the bind succeeded. Keep the Gogo tab open while students play.
Models show "missing" after installA download was interrupted or a stub file was detected (files below the per-asset size floor count as missing). Re-run the download from the model manager.
Answers look cannedThe request landed on Tier 3 (bridge offline). Open the Gogo tab on a WebGPU device to restore Tier 1.