|
| 1 | +tools: story-writer, story-illustrator, server, mkdir, sys.write, sys.read, sys.download |
| 2 | +description: Writes a children's book and generates illustrations for it. |
| 3 | +args: story: The story to write and illustrate. Can be a prompt or a complete story. |
| 4 | + |
| 5 | +Do the following steps sequentially: |
| 6 | + |
| 7 | +1. Create a folder called story with mkdir. |
| 8 | +2. If ${story} is a prompt and not a complete children's story, call story-writer |
| 9 | + to write a story based on the prompt. |
| 10 | +3. Take ${story} and break it up into logical chunks of text. |
| 11 | +4. For each chunk: |
| 12 | + - Call story-illustrator to illustrate it. |
| 13 | + - Download the illustration to a file at story/<chunk_number>.png. |
| 14 | +5. Compile the chunks and their illustrations into an HTML file to story/story.html where |
| 15 | + the text and illustrations are side-by-side scrolling down with good padding. Make sure |
| 16 | + the image is not too large and the text is not too small. |
| 17 | +6. Finally, call serve to serve the story as a webpage and print "Serving at http://localhost:8081". |
| 18 | + |
| 19 | +--- |
| 20 | +name: story-writer |
| 21 | +description: Writes a story for children |
| 22 | +args: prompt: The prompt to use for the story |
| 23 | + |
| 24 | +Write a story with a tone for children based on ${prompt}. |
| 25 | + |
| 26 | +--- |
| 27 | +name: story-illustrator |
| 28 | +temperature: 0.5 |
| 29 | +# assumes you have image-generation.gpt installed |
| 30 | +tools: ../image-generation/tool.gpt, summarize |
| 31 | +description: Generates a illustration for a children's story |
| 32 | +args: prompt: The text of the page to illustrate |
| 33 | + |
| 34 | +Summarize ${promt} to 7 or less words and use the summary to generate an illustration |
| 35 | +for the summary in a cartoon style appropriate for children. Only return the URL of the |
| 36 | +illustration. |
| 37 | + |
| 38 | +--- |
| 39 | +name: mkdir |
| 40 | +description: Creates a directory |
| 41 | +args: name: The name of the directory to create |
| 42 | + |
| 43 | +#!bash |
| 44 | +mkdir -p ${name} |
| 45 | + |
| 46 | +--- |
| 47 | +name: server |
| 48 | +description: Serves the story as a webpage |
| 49 | + |
| 50 | +#!python |
| 51 | +import http.server |
| 52 | +import socketserver |
| 53 | + |
| 54 | +PORT = 8081 |
| 55 | + |
| 56 | +class Handler(http.server.SimpleHTTPRequestHandler): |
| 57 | + def do_GET(self): |
| 58 | + if self.path == '/': |
| 59 | + self.path = 'story/story.html' |
| 60 | + return http.server.SimpleHTTPRequestHandler.do_GET(self) |
| 61 | + |
| 62 | +with socketserver.TCPServer(('', PORT), Handler) as httpd: |
| 63 | + print(f"Serving at port {PORT}") |
| 64 | + httpd.serve_forever() |
0 commit comments