Generate a longer, continuous storyline suitable for reading to small children at bedtime. Allows incremental additions of chapters by providing key events.
Deploy ollama and a suitable LLM (i am using gemma3:27b as of 2025)
Clone the git repo. https://github.com/boaworm/story_py/tree/main
Install dependencies (LangGraph and a few more things) using pip
Replace my sample storyline with something suitable for your family
Insert 5-10 new key events in the instructions.txt file
Run the ./run.sh script to generate a new chapter
Append the new chapter to the end of your story_background.txt file
Repeat 5,6,7 to continue to build the storyline.
caesarspalace:story_py henrik$ ./run.sh
Loading documents and instructions...
Original text split into 4 chunks.
Processing initial chunk to create the narrative...
Refining narrative with chunk 2 of 4...
Refining narrative with chunk 3 of 4...
Refining narrative with chunk 4 of 4...
==================================================
Applying final instructions to the detailed narrative...
==================================================
==================================================
Applying final instructions to the detailed narrative...
==================================================
The sun warmed the deck of the *Sunstone* as they sailed south. Hobby felt a happy hum in his chest. They had a good supply of fresh fruit, and cool water from the mountains, packed carefully below deck. It felt good to be on an adventure, like Bilbo Baggins leaving the Shire. He remembered the tales of faraway lands, and brave heroes. But he also remembered Old Man Tiber’s warning. The cave. The crater. Something dangerous lived near the island. He tried not to think about it.
...
They bid farewell to the fishermen, promising to remember their kindness. The *Sunstone* turned towards the island, sailing into the unknown. The sun dipped below the horizon, casting long shadows across the water. The journey had only just begun.
Final output successfully written to 'new_chapter.txt'.
Total script execution time: 00:17:18