Skip to content

Latest commit

 

History

History
69 lines (50 loc) · 2.1 KB

14_c_GENERATE_A_STORY_WITH_INLINE_IMAGES.md

File metadata and controls

69 lines (50 loc) · 2.1 KB

Generating and Verifying an Illustrated Story with Hyv, OpenAI GPT and DALL-E

Overview

In the third and final part of this guide, we will learn how to execute the agents, generate our story with illustrations, and verify the output.

Prerequisites

Make sure you have followed the steps outlined in both the first part, "Initial Setup for Generating Illustrated Stories with Hyv, OpenAI GPT and DALL-E," and the second part, "Generating and Illustrating a Story with Hyv, OpenAI GPT and DALL-E."

Guide

Initiating the Sequence and Story Generation

Having prepared our agents, we can now start the sequence to create our story:

try {
    await sequence(
        {
            task: "provide information about the story",
            competitionRules: {
                wordCount: 500,
                chapterCount: 1,
                imageCount: 3,
                maturityRating: "G|PG|PG13",
            },
        },
        [bookAgent, author, illustrator]
    );
    console.log("Done");
} catch (error) {
    console.error("Error:", error);
}

Executing the Script

Save the script in a .ts (TypeScript) file and execute it using the ts-node command. If you don't already have ts-node, you can install it via npm:

ts-node your_script_file.ts

Verifying the Output

After running the script, you should verify the output directory, which is examples/output/auto-book/ in our example. You should find a story crafted by the author agent, complete with reading time and word count, and images generated by the illustrator agent, inlined within the story.

Handling Errors

In case of any errors during the script execution, they will be logged to the console, thanks to the try/catch block surrounding the sequence function.

Summary

This guide covered the process of executing AI agents to generate an illustrated story using Hyv, OpenAI's GPT-4, and DALL-E. By following these steps, you can create engaging narratives with accompanying illustrations.

Tags

Hyv, OpenAI, GPT-4, DALL-E, TypeScript, Story Generation, AI, Illustrations