Update app.py
Browse files
app.py
CHANGED
@@ -25,14 +25,14 @@ def storyGPT(key, name, situation, direction):
|
|
25 |
system_message = story["choices"][0]["message"]
|
26 |
messages.append(system_message)
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
|
37 |
story_parts = []
|
38 |
for message in messages:
|
@@ -52,8 +52,8 @@ def storyGPT(key, name, situation, direction):
|
|
52 |
for i in range(len(story_parts)):
|
53 |
story_parts[i] = story_parts[i].replace(". ", ".\n\n")
|
54 |
|
55 |
-
|
56 |
-
return (story_parts[0], story_parts[1], story_parts[2])
|
57 |
|
58 |
|
59 |
# EXAMPLE
|
@@ -117,18 +117,18 @@ with gr.Blocks(title="StoryGPT", css="#button{background-color:#4CAF50} #title{t
|
|
117 |
illustration3 = gr.Image(
|
118 |
show_label=False, brush_radius=0).style(height=200)
|
119 |
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
|
129 |
inputs = [key, name, situation, direction]
|
130 |
-
|
131 |
-
outputs = [story1, illustration1, story2,illustration2, story3, illustration3]
|
132 |
|
133 |
Generate_btn.click(storyGPT, inputs=inputs, outputs=outputs)
|
134 |
|
|
|
25 |
system_message = story["choices"][0]["message"]
|
26 |
messages.append(system_message)
|
27 |
|
28 |
+
for i in ["Third", "Final"]:
|
29 |
+
new_story_second_half = {
|
30 |
+
"role": "user", "content": f"Write the {i} part of the story among 3 continuing from the previous part"+"in the "+direction+". Include a bold heading above the top starting with '{i} part:'. Limit your answer to 4 sentences or less"}
|
31 |
+
messages.append(new_story_second_half)
|
32 |
+
story = openai.ChatCompletion.create(
|
33 |
+
model="gpt-3.5-turbo", messages=messages)
|
34 |
+
system_message = story["choices"][0]["message"]
|
35 |
+
messages.append(system_message)
|
36 |
|
37 |
story_parts = []
|
38 |
for message in messages:
|
|
|
52 |
for i in range(len(story_parts)):
|
53 |
story_parts[i] = story_parts[i].replace(". ", ".\n\n")
|
54 |
|
55 |
+
return (story_parts[0], illustration_parts[0], story_parts[1], illustration_parts[1], story_parts[2], illustration_parts[2], story_parts[3], illustration_parts[3])
|
56 |
+
# return (story_parts[0], story_parts[1], story_parts[2])
|
57 |
|
58 |
|
59 |
# EXAMPLE
|
|
|
117 |
illustration3 = gr.Image(
|
118 |
show_label=False, brush_radius=0).style(height=200)
|
119 |
|
120 |
+
with gr.Row(variant="compact").style(equal_height=True):
|
121 |
+
with gr.Column(scale=3):
|
122 |
+
story4 = gr.Textbox(show_label=False, lines=9).style(
|
123 |
+
container=False)
|
124 |
|
125 |
+
with gr.Column(scale=1):
|
126 |
+
illustration4 = gr.Image(
|
127 |
+
show_label=False, brush_radius=0).style(height=200)
|
128 |
|
129 |
inputs = [key, name, situation, direction]
|
130 |
+
outputs = [story1, illustration1, story2,illustration2, story3, illustration3, story4, illustration4]
|
131 |
+
# outputs = [story1, illustration1, story2,illustration2, story3, illustration3]
|
132 |
|
133 |
Generate_btn.click(storyGPT, inputs=inputs, outputs=outputs)
|
134 |
|