Update app.py
Browse files
app.py
CHANGED
@@ -28,17 +28,17 @@ global_chapters = ""
|
|
28 |
# Generation functions
|
29 |
def generate_synopsis(topic):
|
30 |
global global_synopsis
|
31 |
-
prompt = f"Write a synopsis for a story about {topic}: "
|
32 |
-
global_synopsis = generate_text(prompt, max_length=
|
33 |
return global_synopsis
|
34 |
|
35 |
def generate_chapters():
|
36 |
global global_synopsis, global_chapters
|
37 |
if not global_synopsis:
|
38 |
return "Please generate a synopsis first."
|
39 |
-
prompt = f'''Based on this synopsis for a book: {global_synopsis}
|
40 |
-
|
41 |
-
global_chapters = generate_text(prompt, max_length=
|
42 |
return global_chapters
|
43 |
|
44 |
def expand_chapter(chapter_number):
|
@@ -48,7 +48,8 @@ def expand_chapter(chapter_number):
|
|
48 |
chapters = global_chapters.split("\n")
|
49 |
if chapter_number <= 0 or chapter_number > len(chapters):
|
50 |
return f"Select a number between 1 and {len(chapters)}."
|
51 |
-
prompt = f
|
|
|
52 |
return generate_text(prompt, max_length=200)
|
53 |
|
54 |
# Gradio interface
|
|
|
28 |
# Generation functions
|
29 |
def generate_synopsis(topic):
|
30 |
global global_synopsis
|
31 |
+
prompt = f"Write a brief synopsis for a story about {topic}: "
|
32 |
+
global_synopsis = generate_text(prompt, max_length=100)
|
33 |
return global_synopsis
|
34 |
|
35 |
def generate_chapters():
|
36 |
global global_synopsis, global_chapters
|
37 |
if not global_synopsis:
|
38 |
return "Please generate a synopsis first."
|
39 |
+
prompt = f'''Based on this synopsis for a book: {global_synopsis}. Divide the story into 4 chapters with brief descriptions for each.
|
40 |
+
Enumerate every chapter created followed by its description and make the first chapter sound like an introduction and the last may sound as the epilogue'''
|
41 |
+
global_chapters = generate_text(prompt, max_length=2000)
|
42 |
return global_chapters
|
43 |
|
44 |
def expand_chapter(chapter_number):
|
|
|
48 |
chapters = global_chapters.split("\n")
|
49 |
if chapter_number <= 0 or chapter_number > len(chapters):
|
50 |
return f"Select a number between 1 and {len(chapters)}."
|
51 |
+
prompt = f'''Knowing this synopsis for a book: {global_synopsis}. Expand and describe Chapter {chapter_number}
|
52 |
+
in more detail, the title and current brief description of this chapter is: {chapters[chapter_number - 1]}'''
|
53 |
return generate_text(prompt, max_length=200)
|
54 |
|
55 |
# Gradio interface
|