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 |
-
for i in ["Third", "Final"]:
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
|
37 |
story_parts = []
|
38 |
for message in messages:
|
@@ -52,7 +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 |
-
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 |
|
57 |
|
58 |
# EXAMPLE
|
@@ -107,27 +108,27 @@ with gr.Blocks(title="StoryGPT", css="#button{background-color:#4CAF50} #title{t
|
|
107 |
illustration2 = gr.Image(
|
108 |
show_label=False, brush_radius=0, lines=9).style(height=200)
|
109 |
|
110 |
-
with gr.Row(variant="compact").style(equal_height=True):
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
|
119 |
-
with gr.Row(variant="compact").style(equal_height=True):
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
|
128 |
inputs = [key, name, situation, direction]
|
129 |
-
outputs = [story1, illustration1, story2,
|
130 |
-
|
131 |
|
132 |
Generate_btn.click(storyGPT, inputs=inputs, outputs=outputs)
|
133 |
|
|
|
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 5 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], illustration_parts[0], story_parts[1], illustration_parts[1], story_parts[2], illustration_parts[2])
|
57 |
|
58 |
|
59 |
# EXAMPLE
|
|
|
108 |
illustration2 = gr.Image(
|
109 |
show_label=False, brush_radius=0, lines=9).style(height=200)
|
110 |
|
111 |
+
# with gr.Row(variant="compact").style(equal_height=True):
|
112 |
+
# with gr.Column(scale=3):
|
113 |
+
# story3 = gr.Textbox(show_label=False, lines=9).style(
|
114 |
+
# container=False)
|
115 |
|
116 |
+
# with gr.Column(scale=1):
|
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]
|
132 |
|
133 |
Generate_btn.click(storyGPT, inputs=inputs, outputs=outputs)
|
134 |
|