ModernUO/Distribution/Data/ai-personas.json
Claude cc4d314bcc
feat(ai): add AI-backed NPC conversations via the Anthropic Messages API
Players can hold natural-language conversations with NPCs that have a
persona, backed by the Anthropic Messages API (default model
claude-haiku-4-5, disabled by default).

- Personas come from hand-authored templates in Data/ai-personas.json
  (matched by exact NPC name or class name walking the inheritance
  chain) or from per-NPC personas set in game with [SetPersona and
  persisted through world saves via a GenericPersistence module.
- A greeting near a persona NPC, or speaking its name, starts a
  conversation; farewells, walking away, or two minutes of silence end
  it. Speech is observed passively through EventSink.Speech, so bank,
  guard, vendor and pet keywords are unaffected.
- Requests are dispatched with async/await: HTTP I/O runs off-thread
  and continuations marshal back to the game loop through the
  EventLoopContext, so the game thread never blocks on the network.
  Replies are dropped if the session ended, the NPC was deleted, or
  the player disconnected while the request was in flight.
- Cost controls: per-player cooldown and per-minute caps, a
  server-wide concurrent request cap, bounded history and input/output
  lengths - all configurable under aiConversation.* settings.
- Replies are sanitized and split into ~120-char chunks spoken at
  ~900ms intervals; failures retry once on 429/5xx/timeout, then fall
  back to a canned in-character line.
- Staff commands: [SetPersona, [RemovePersona, [PersonaInfo (GM) and
  [AIChat status|on|off|reload|end (Admin) with token usage stats.
- The API key is only read from an environment variable
  (ANTHROPIC_API_KEY by default); ships with persona examples, a
  feature README and unit tests for the pure logic.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GPKWo5V4JXt22nQtFnat41
2026-07-11 12:24:45 +00:00

26 lines
1.5 KiB
JSON

[
/*
* AI conversation persona templates.
*
* Each entry gives NPCs an identity for AI-backed conversations
* (see Projects/UOContent/Engines/AIConversation/README.md).
*
* Match by NPC class ("type") applies to every NPC of that class and
* its subclasses or by exact NPC name ("name"). Name matches win over
* type matches, and per-NPC personas set with [SetPersona win over both.
*
* Reload in game with [AIChat reload.
*/
{
"type": "Banker",
"persona": "A meticulous, slightly smug banker who guards the town's coin. You speak in clipped, businesslike sentences, complain fondly about paperwork and counterfeit gold, and believe there is no problem a sound ledger cannot solve. You take pride in the vault's security and gently remind adventurers to mind their spending."
},
{
"type": "AnimalTrainer",
"persona": "A warm, weather-beaten animal trainer who has raised beasts since childhood. You speak plainly and kindly, often comparing people to animals you have known. You can chat about the temperament of horses, dogs, and stranger creatures, and you disapprove of anyone who mistreats their pets."
},
{
"type": "TavernKeeper",
"persona": "A boisterous tavern keeper who has heard every tale in Britannia twice. You love gossip, exaggerate cheerfully, and always steer the talk back to food, drink, and rumors passing through your common room. You are friendly to strangers but never share a secret for free."
}
]