Migrate spell extraction to native execution and semantic continuation
This commit is contained in:
5
assets/dnd/spells/prompts/correction.md
Normal file
5
assets/dnd/spells/prompts/correction.md
Normal file
@@ -0,0 +1,5 @@
|
||||
Revise the previous spell-cast list using these findings:
|
||||
|
||||
{{ input "guidance" }}
|
||||
|
||||
Return the complete replacement spell-cast list under the same output contract.
|
||||
@@ -1,14 +1 @@
|
||||
Extract Dungeons & Dragons spell-cast artifacts from the provided transcript.
|
||||
Include an actual casting event or an unambiguous declared casting attempt.
|
||||
Exclude spell mentions, hypothetical plans, rules discussion, and catalog
|
||||
matches that do not establish a casting event in the transcript.
|
||||
|
||||
For every extracted cast, the transcript evidence must collectively support the
|
||||
in-world caster, the spell, and the fact that the cast or declared attempt
|
||||
occurred.
|
||||
|
||||
Attribute every cast to its in-world caster. Map first-person player speech to
|
||||
the associated player character, and attribute a spell narrated by the GM to
|
||||
the in-world creature that casts it. If the caster cannot be resolved, use only
|
||||
the most specific in-world identity supported by the transcript; do not invent
|
||||
a name.
|
||||
Extract the spell casts established by the provided transcript chunk. Return the complete spell-cast list, or an empty list when no casting event is supported.
|
||||
|
||||
18
assets/dnd/spells/prompts/principles.md
Normal file
18
assets/dnd/spells/prompts/principles.md
Normal file
@@ -0,0 +1,18 @@
|
||||
Extract Dungeons & Dragons spell-cast artifacts from transcript evidence.
|
||||
Include an actual casting event or an unambiguous declared casting attempt.
|
||||
Exclude spell mentions, hypothetical plans, rules discussion, and catalog
|
||||
matches that do not establish a casting event in the transcript.
|
||||
|
||||
For every extracted cast, the transcript evidence must collectively support the
|
||||
in-world caster, the spell, and the fact that the cast or declared attempt
|
||||
occurred.
|
||||
|
||||
Attribute every cast to its in-world caster. Map first-person player speech to
|
||||
the associated player character, and attribute a spell narrated by the GM to
|
||||
the in-world creature that casts it. If the caster cannot be resolved, use only
|
||||
the most specific in-world identity supported by the transcript; do not invent
|
||||
a name.
|
||||
|
||||
The spell catalog lists each spell's canonical_name and recognized aliases.
|
||||
If the transcript uses an alias, select that entry's canonical_name. Return the
|
||||
canonical spelling exactly; never return an alias as a spell name.
|
||||
@@ -23,8 +23,10 @@ prompts:
|
||||
messages:
|
||||
- role: system
|
||||
content_file: ../../shared/prompts/common-dnd-system.md
|
||||
- role: user
|
||||
- role: system
|
||||
content_file: ../../shared/prompts/common-dnd-identity.md
|
||||
- role: system
|
||||
content_file: ./principles.md
|
||||
- role: user
|
||||
content_file: ../../shared/prompts/common-dnd-references.md
|
||||
cache_control:
|
||||
@@ -33,7 +35,7 @@ prompts:
|
||||
content_file: ../../shared/prompts/common-dnd-transcript-chunk.md
|
||||
cache_control:
|
||||
type: ephemeral
|
||||
- role: user
|
||||
- role: system
|
||||
content_file: ../../shared/prompts/common-dnd-extraction-evidence.md
|
||||
- role: user
|
||||
content_file: ../../shared/prompts/common-dnd-npc-registry.md
|
||||
@@ -47,3 +49,17 @@ prompts:
|
||||
format: json
|
||||
validation_mode: json_schema
|
||||
schema_path: dnd/spells/schemas/dnd_spells_llm.v1.json
|
||||
|
||||
- id: dnd.spells.repair
|
||||
default_profile: notarius/dnd-extraction
|
||||
inputs:
|
||||
- name: guidance
|
||||
required: true
|
||||
content_type: text/plain
|
||||
messages:
|
||||
- role: user
|
||||
content_file: ./correction.md
|
||||
output:
|
||||
format: json
|
||||
validation_mode: json_schema
|
||||
schema_path: dnd/spells/schemas/dnd_spells_llm.v1.json
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
The spell catalog for this extraction is provided below as JSON. Each entry
|
||||
lists a `canonical_name` and its recognized `aliases`. If the transcript uses
|
||||
an alias, select that entry's `canonical_name`. Return spell names using the
|
||||
canonical spelling exactly; never return an alias as a spell name.
|
||||
The spell recognition catalog for this operation:
|
||||
|
||||
{{ input "spell_catalog" }}
|
||||
|
||||
@@ -131,8 +131,11 @@ func TestEmbeddedPromptsPrepareWithNativeContracts(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(details.Messages) == 0 || details.Messages[0].Role != "system" || strings.TrimSpace(details.Messages[0].Content) != strings.TrimSpace(string(content)) {
|
||||
t.Fatal("shared initial system context was not preserved")
|
||||
if first.Role == nil || len(details.Messages) == 0 || details.Messages[0].Role != *first.Role {
|
||||
t.Fatal("declared message role was not preserved")
|
||||
}
|
||||
if !strings.Contains(string(content), "{{") && strings.TrimSpace(details.Messages[0].Content) != strings.TrimSpace(string(content)) {
|
||||
t.Fatal("source-relative message content was not preserved")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user