Add H3 beat prompt builder node

This commit is contained in:
2026-08-25 23:10:50 +00:00
parent 9d70f74b23
commit 18129327d9
4 changed files with 523 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
import importlib
import unittest
class DumasH3BeatPromptTests(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.module = importlib.import_module("dumas_h3_beat_prompt")
def test_parse_state_falls_back_to_default(self):
state = self.module._parse_beat_prompt_state("not json")
self.assertEqual(
state,
{"beats": [{"text": "Describe this beat."}]},
)
def test_assemble_prompt_joins_beats_with_blank_lines(self):
prompt = self.module._assemble_beat_prompt(
{
"beats": [
{"text": "A woman enters the room."},
{"text": "wardrobe: Maya = red jacket\nShe sits at the table."},
{"text": " "},
{"text": "music: low synth pulse"},
]
}
)
self.assertEqual(
prompt,
(
"A woman enters the room.\n\n"
"wardrobe: Maya = red jacket\nShe sits at the table.\n\n"
"music: low synth pulse"
),
)
def test_node_build_prompt_uses_hidden_state(self):
node = self.module.DumasH3BeatPromptNode()
result = node.build_prompt(
'{"beats":[{"text":"Beat one"},{"text":"Beat two"}]}'
)
self.assertEqual(result, ("Beat one\n\nBeat two",))
if __name__ == "__main__":
unittest.main()