Consolidate grounded event extraction instructions
This commit is contained in:
@@ -18,7 +18,6 @@ var promptAssetManifest = shared.PromptAssetManifest{
|
||||
ModuleFiles: []promptfs.ModulePromptFile{
|
||||
{Name: "prompt.yaml", Path: "prompts/prompt.yaml"},
|
||||
{Name: "combat-grounding.md", Path: "prompts/combat-grounding.md"},
|
||||
{Name: "task.md", Path: "prompts/task.md"},
|
||||
{Name: "instructions.md", Path: "prompts/instructions.md"},
|
||||
},
|
||||
SharedFiles: []string{
|
||||
|
||||
@@ -28,21 +28,32 @@ func TestRegisterPromptAssetsAndPrepareEnemyEventPrompt(t *testing.T) {
|
||||
if prepared.PromptID != PromptID || prepared.OutputContract.SchemaPath != "dnd_enemy_events_llm.v1.json" || prepared.SelectedProfileID != "dnd-extraction" {
|
||||
t.Fatalf("prepared prompt = %#v", prepared)
|
||||
}
|
||||
referenceIndex := renderedMessageIndex(t, prepared.Messages, "enemy-player")
|
||||
transcriptIndex := renderedMessageIndex(t, prepared.Messages, "enemy-transcript")
|
||||
for _, sentinel := range []string{"enemy-npc", "enemy-turn", "enemy-opponent", "Extract Dungeons & Dragons enemy events"} {
|
||||
if transcriptIndex <= referenceIndex {
|
||||
t.Fatalf("transcript message index = %d, want after references index %d", transcriptIndex, referenceIndex)
|
||||
}
|
||||
groundingIndices := make([]int, 0, 3)
|
||||
for _, sentinel := range []string{"enemy-npc", "enemy-turn", "enemy-opponent"} {
|
||||
if index := renderedMessageIndex(t, prepared.Messages, sentinel); index <= transcriptIndex {
|
||||
t.Fatalf("message containing %q has index %d, want after transcript index %d", sentinel, index, transcriptIndex)
|
||||
} else {
|
||||
groundingIndices = append(groundingIndices, index)
|
||||
}
|
||||
}
|
||||
instructionIndex := renderedMessageIndex(t, prepared.Messages, "Return the `events` array")
|
||||
if instructionIndex <= transcriptIndex {
|
||||
t.Fatalf("instruction index = %d, want after transcript index %d", instructionIndex, transcriptIndex)
|
||||
instructionIndex := renderedMessageIndex(t, prepared.Messages, "Extract Dungeons & Dragons enemy events")
|
||||
for _, index := range groundingIndices {
|
||||
if instructionIndex <= index {
|
||||
t.Fatalf("instruction index = %d, want after grounding index %d", instructionIndex, index)
|
||||
}
|
||||
}
|
||||
if instructionIndex != len(prepared.Messages)-1 {
|
||||
t.Fatalf("instruction message index = %d, want final message", instructionIndex)
|
||||
}
|
||||
if cache := prepared.Messages[instructionIndex].CacheControl; cache == nil || cache.Type != promptkit.CacheControlEphemeral {
|
||||
t.Fatalf("final instruction cache control = %#v", cache)
|
||||
for _, index := range []int{referenceIndex, transcriptIndex, instructionIndex} {
|
||||
if cache := prepared.Messages[index].CacheControl; cache == nil || cache.Type != promptkit.CacheControlEphemeral {
|
||||
t.Fatalf("message %d cache control = %#v, want ephemeral", index, cache)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user