Add D&D NPC extraction and validation

This commit is contained in:
2026-07-21 02:24:26 +00:00
parent 3ba2c62cc1
commit 3d5fd9dc05
22 changed files with 1700 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
id: dnd.npcs
version: "v1"
default_profile: gemini-2-flash
inputs:
- name: transcript
required: true
content_type: application/json
- name: players
required: false
content_type: text/plain
- name: party
required: false
content_type: text/plain
- name: glossary
required: false
content_type: text/plain
messages:
- role: system
content_file: ./sharedassets/common-dnd-system.md
- role: user
content_file: ./sharedassets/common-dnd-transcript.md
cache_control:
type: ephemeral
- role: user
content_file: ./sharedassets/common-dnd-references.md
cache_control:
type: ephemeral
- role: user
content_file: ./task.md
- role: user
content_file: ./instructions.md
output:
format: json
validation_mode: json_schema
schema_path: dnd_npcs_llm.v1.json
repair_attempts: 0

View File

@@ -0,0 +1,25 @@
Return exactly one JSON object and no explanatory text.
For every NPC record, cite one or more transcript source-unit ranges that
collectively support the canonical name, every alias, the description, and
every relationship. Use integer start_unit_id and end_unit_id values from the
transcript. Do not provide source_id; the extractor assigns it automatically.
Use narrow ranges when evidence is not contiguous and do not bridge unrelated
conversation with a broad range.
A canonical name must be the most specific in-world identity supported by the
transcript. Never use a human player, transcript speaker, or GM name when an
associated in-world character or creature is identified. Player, party, and
glossary references may disambiguate identities, but they are not transcript
evidence and cannot establish that an NPC appeared, acted, or was discussed.
Do not return a person or entity mentioned only in those references.
Descriptions must be short session records, not biographies, statistics,
alignment, motivations, or lore inferred from general D&D knowledge. Do not
summarize every action or follow a participant through unrelated scenes.
Relationships must be stated or directly demonstrated by cited transcript
units, not inferred from game lore.
Return aliases and relationships as arrays, including empty arrays when there
are none. Return only NPC records supported by the transcript and preserve
observed display spelling.

View File

@@ -0,0 +1,16 @@
Extract a concise Dungeons & Dragons non-player-character registry from the
provided transcript.
Include an in-world non-PC participant when the transcript establishes that it
appears, acts, speaks, or is materially discussed and gives it a proper name,
a stable alias or title, or an individually useful distinguishing description.
Exclude human players, transcript speakers, the GM as an out-of-world person,
player characters identified by the player or party references, incidental or
hypothetical name drops, corrected transcription mistakes, characters mentioned
only by reference material, indistinguishable crowds or groups, and temporary
summoned creatures or spell effects without a persistent individual identity.
Return canonical in-world names rather than player names or transcript speaker
names. Keep each description concise and limited to facts established by the
transcript. Include only explicitly supported aliases and relationships.

View File

@@ -0,0 +1,77 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "notarius.dnd.npcs.llm",
"type": "object",
"additionalProperties": false,
"required": ["npcs"],
"properties": {
"npcs": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"required": [
"name",
"aliases",
"description",
"relationships",
"source_refs"
],
"properties": {
"name": {
"type": "string",
"minLength": 1
},
"aliases": {
"type": "array",
"items": {
"type": "string",
"minLength": 1
}
},
"description": {
"type": "string",
"minLength": 1
},
"relationships": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"required": ["target", "relationship"],
"properties": {
"target": {
"type": "string",
"minLength": 1
},
"relationship": {
"type": "string",
"minLength": 1
}
}
}
},
"source_refs": {
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"additionalProperties": false,
"required": ["start_unit_id", "end_unit_id"],
"properties": {
"start_unit_id": {
"type": "integer",
"minimum": 1
},
"end_unit_id": {
"type": "integer",
"minimum": 1
}
}
}
}
}
}
}
}
}