Skip to content

Commit 527989e

Browse files
committed
fix: address issue with image-generation bootstrap not working and improve doc for story-book
Signed-off-by: tylerslaton <[email protected]>
1 parent 39575b8 commit 527989e

File tree

4 files changed

+37
-56
lines changed

4 files changed

+37
-56
lines changed

examples/story-book/README.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,32 @@
33
Story Book is a GPTScript that can generate a story based on a prompt and the number of pages you want the story to be in. It is generated in HTML format and can then be viewed
44
by `index.html` which has some JS/CSS to make the story styling consistent and readable.
55

6-
## How to Use
7-
1. Install the `image-generation` tool.
6+
## Usage Instructions
87

9-
```shell
10-
git clone https://github.com/gptscript-ai/image-generation
11-
```
8+
1. **Install and bootstrap the `image-generation` tool.**
129

13-
2. Bootstrap the `image-generation` tool.
10+
This tool uses the `image-generation` tool, which is in a separate repository. To install and bootstrap the `image-generation` tool, starting at the root of `gptscript` run the following commands:
1411

15-
```shell
16-
(
12+
> Note: We'll soon have package management that handles tools installation for you, but until then, you have to manually clone and boostrap tools.
13+
14+
```shell
15+
cd .. # This assumes you're starting at the root of the gptscript project. We want image-generation to be a sibling of gptscript.
16+
git clone https://github.com/gptscript-ai/image-generation
1717
cd image-generation
1818
make bootstrap
1919
source .venv/bin/activate
20-
)
21-
```
20+
cd - # returns you back to your original directory
21+
```
22+
23+
2. **Run the `story-book.gpt` script.**
24+
25+
In the same terminal session where the virtual environment (venv) is now activated, navigate to the `story-book` example directory and run the `story-book.gpt` script:
2226

23-
3. In the `story-book` directory of `gptscript`, run the `story-book.gpt` script.
27+
```shell
28+
cd examples/story-book
29+
gptscript story-book.gpt --prompt "Goldilocks" --pages 3
30+
```
2431

25-
```shell
26-
cd examples/story-book
27-
gptscript examples/story-book/story-book.gpt --prompt "Goldilocks" --pages 3
28-
```
32+
3. **View the story.**
2933

30-
4. Open `index.html` in your browser to view the story.
34+
Open `index.html` in your browser to view the generated story.

examples/story-book/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ <h1>Story Book</h1>
9191

9292
<script>
9393
// List of pages to display
94-
var pages = [];
94+
var pages = ["pages/page1.html", "pages/page2.html"];
9595

9696
// Populate the select element with options
9797
var select = document.getElementById("pageSelect");

examples/story-book/pages/template.html

Lines changed: 0 additions & 33 deletions
This file was deleted.

examples/story-book/story-book.gpt

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
tools: story-writer, story-illustrator, sys.write, sys.read, sys.download
1+
tools: story-writer, story-illustrator, mkdir, sys.write, sys.read, sys.download
22
description: Writes a children's book and generates illustrations for it.
33
args: story: The story to write and illustrate. Can be a prompt or a complete story.
44
args: pages: The number of pages to generate
55

66
Do the following steps sequentially:
77

8-
1. If ${story} is a prompt and not a complete children's story, call story-writer
8+
1. Create the `pages` directory if it does not already exist.
9+
2. If ${story} is a prompt and not a complete children's story, call story-writer
910
to write a story based on the prompt.
1011
3. Take ${story} and break it up into ${pages} logical "pages" of text.
11-
3. For each page:
12+
4. For each page:
1213
- Call story-illustrator to illustrate it. Be sure to include any relevant characters to include when
1314
asking it to illustrate the page.
1415
- Download the illustration to a file at pages/<page_number>.png.
15-
4. For each page and its illustration write an html file with the text on top and the image below it to
16-
pages/page<page number>.html. Add this style tag to the HTML file:
16+
5. For each page and its illustration write an html file with the text on top and image below it to pages/page<page number>.html.
17+
Assume the illustration file is a sibling to the html file, Add this style tag to the HTML file:
1718
```html
1819
<style>
1920
body {
@@ -36,7 +37,7 @@ Do the following steps sequentially:
3637
}
3738
</style>
3839
```
39-
5. Edit the "pages" variable array in index.html to serve the pages you created. Do not
40+
6. Edit the "pages" variable array in index.html to serve the pages you created. Do not
4041
edit anything else. Do not edit the page select field.
4142

4243
---
@@ -57,3 +58,12 @@ include the name of any relevant characters in your prompt. Then use that prompt
5758
generate an illustration. Append any prompt that you have with ". In an pointilism cartoon
5859
children's book style with no text in it". Only return the URL of the illustration.
5960

61+
---
62+
name: mkdir
63+
tools: sys.write
64+
description: Creates a specified directory
65+
args: dir: Path to the directory to be created
66+
67+
#!bash
68+
69+
mkdir ${dir}

0 commit comments

Comments
 (0)