Skip to content

keeping-an-npc-on-quest

Educational code where a local LLM voices a game NPC and Jev classifies player messages and checks every line for spoilers.

ProjectprototypeApache-2.0

Overview

This is companion code for an Old Nain YouTube episode about keeping an LLM-run non-player character on quest. In a terminal text game, Boone, a reporter on a bayou stakeout, will reveal what has been stealing biscuits only after the player brings three pieces of evidence. A local model, by default via Ollama, writes every line he says, and left alone it gives away the secret, follows off-topic players and drops character when told to ignore instructions.

The first fix needs no Jev: the code only gives the model facts the current stage unlocks. Then Jev handles the rest. A Choice classifies each player message as about the quest, small talk, a tangent or breaking the game, and code sets Boone's job for the turn, steering back more firmly if the player keeps wandering. After the local model writes a line, four Noul checks run at once: does it reveal a locked fact, invent something, break character or fail to steer back. A failed check gets one rewrite with the reason, then a pre-written fallback line. It is explicitly for educational use only.

What the decision model decides

TypeQuestionAnswers
ChoiceWhat kind of message is this?about the quest · small talk · a tangent · breaking the game
Yes / noDoes this line give away a locked fact?—
Yes / noDoes it invent something / break character / fail to steer back?—

How it works

  1. Player sends a message
  2. Jev classifies the message type
  3. Code sets Boone's goal for the turn
  4. Local model writes a line from only the unlocked facts
  5. Jev runs four checks; failures get one rewrite then a fallback line

Strengths

  • Clear separation: local model writes, Jev checks, code decides
  • Staged facts prevent most spoilers before any check
  • Questions are visible exactly as Jev sees them

Caveats

  • Educational code, not hardened for production
  • Needs a local model server and a TypeSafe key
  • Single example game

Getting started

Install uv and a local model server (Ollama by default), set a TypeSafe API key, and follow the Run it section.

At a glance

Type
Project
Status
prototype
Language
Python
Runtime
terminal game with Ollama
Has code
yes
License
Apache-2.0
Stars
0

Use cases and integrations

How curated lists describe it

  • Companion code for Old Nain episode 002: keeping an LLM-run NPC on quest with staged facts and Jev, TypeSafe's System One model, checking every line. For educational use only.

    wh000wh000/awesome-jev-live

Frequently asked questions

Does Jev write the NPC's lines?

No. A local model writes them; Jev classifies messages and checks each line.

What stops spoilers?

Staged facts limit what the model knows, and a Jev check catches any line that reveals a locked fact.

Can I use this in production?

The README says it is for educational use only.

Related projects

  • Small Python demos of Jev: parallel Noul ticket checks with measured speedup, and a three-way Choice citation and claim checker.

    AppprototypePython
  • TypeScript demos for testers: Jev triages CI test failures, gates test-agent commands and RAG answers, across gateway, Ollama and Foundry.

    LibraryprototypeTypeScript
  • Official TypeSafe cookbook example for checking whether source context actually supports a claim.

    Articleproduction
  • Public Jev lab centred on a chess match broadcast where Jev picks from legal moves, plus smaller judgment booths and a Fast Flag catalogue.

    ProjectprototypeJavaScript, Python
  • 25-second Japanese IT-buzzword game that shows Jev's speed and cost: every typed term is classified live, with no LLM-generated text.

    ProjectprototypePython, JavaScript
  • Visual workbench (in Portuguese) for wiring Jev decision funnels as node graphs and watching them play a game in real time.

    ProjectprototypePython