Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -15,12 +15,11 @@ current_image_url = ""
|
|
15 |
|
16 |
def generate_image_url(keywords):
|
17 |
return f"https://image.pollinations.ai/prompt/{quote(keywords)}"
|
18 |
-
|
19 |
-
def next_chapter():
|
20 |
global chapter_num, current_story, current_image_url
|
21 |
current_image_url = generate_image_url(current_story) # ๋ค์ ์ฅ์ ์ด๋ฏธ์ง URL์ ์์ฑํฉ๋๋ค.
|
22 |
gr.Info(f'Chapter {chapter_num}๋ฅผ ์์ฑํ๊ณ ์์ต๋๋ค...')
|
23 |
-
chapter_prompt = f"{story_intro}\n\n\n\nChapter {chapter_num} ๋ด์ฉ์ ๋ง๋ค์ด์ค."
|
24 |
chat_completion = openai.ChatCompletion.create(model="gpt-3.5-turbo-16k", messages=[{"role": "user", "content": chapter_prompt}])
|
25 |
current_story = chat_completion.choices[0].message.content
|
26 |
chapter_num += 1
|
@@ -72,8 +71,9 @@ with gr.Blocks(css=css) as demo:
|
|
72 |
|
73 |
submit_btn.click(fn=infer, inputs=[image_in, audience, keyword_in, protagonist_in],
|
74 |
outputs=[chapter_story, chapter_image])
|
75 |
-
|
76 |
-
|
77 |
-
|
|
|
78 |
|
79 |
demo.queue(max_size=12).launch()
|
|
|
15 |
|
16 |
def generate_image_url(keywords):
|
17 |
return f"https://image.pollinations.ai/prompt/{quote(keywords)}"
|
18 |
+
def next_chapter(audience, keyword, protagonist):
|
|
|
19 |
global chapter_num, current_story, current_image_url
|
20 |
current_image_url = generate_image_url(current_story) # ๋ค์ ์ฅ์ ์ด๋ฏธ์ง URL์ ์์ฑํฉ๋๋ค.
|
21 |
gr.Info(f'Chapter {chapter_num}๋ฅผ ์์ฑํ๊ณ ์์ต๋๋ค...')
|
22 |
+
chapter_prompt = f"{story_intro}\n\nKeyword: {keyword}\nProtagonist: {protagonist}\n\n\n\nChapter {chapter_num} ๋ด์ฉ์ ๋ง๋ค์ด์ค."
|
23 |
chat_completion = openai.ChatCompletion.create(model="gpt-3.5-turbo-16k", messages=[{"role": "user", "content": chapter_prompt}])
|
24 |
current_story = chat_completion.choices[0].message.content
|
25 |
chapter_num += 1
|
|
|
71 |
|
72 |
submit_btn.click(fn=infer, inputs=[image_in, audience, keyword_in, protagonist_in],
|
73 |
outputs=[chapter_story, chapter_image])
|
74 |
+
next_chapter_btn.click(fn=lambda: next_chapter(audience=audience.value, keyword=keyword_in.value, protagonist=protagonist_in.value),
|
75 |
+
outputs=[chapter_story, chapter_image])
|
76 |
+
# next_chapter_btn.click(fn=next_chapter,
|
77 |
+
# outputs=[chapter_story, chapter_image])
|
78 |
|
79 |
demo.queue(max_size=12).launch()
|