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+
#app.py
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from gradio_client import Client
|
| 4 |
+
import os
|
| 5 |
+
|
| 6 |
+
# ๊ฐ ๋ชจ๋์์ ํจ์ import (PDF ํจ์ ์ ๊ฑฐ)
|
| 7 |
+
from info_blog import generate_outline_1, generate_blog_post_1
|
| 8 |
+
from travel_blog import generate_outline_2, generate_blog_post_2
|
| 9 |
+
from product_review_blog import generate_outline_3, generate_blog_post_3
|
| 10 |
+
from feature_focus_blog import generate_outline_4, generate_blog_post_4
|
| 11 |
+
from visit_review_blog import generate_outline_5, generate_blog_post_5
|
| 12 |
+
|
| 13 |
+
# ๊ธฐ์กด API ํจ์ ์ ์ (์ ๋ณด์ฑ)
|
| 14 |
+
def generate_outline_1_api(category, style, ref1, ref2, ref3):
|
| 15 |
+
result = generate_outline_1(category, style, ref1, ref2, ref3)
|
| 16 |
+
return result
|
| 17 |
+
|
| 18 |
+
def generate_blog_post_1_api(category, style, ref1, ref2, ref3, outline_input):
|
| 19 |
+
result = generate_blog_post_1(category, style, ref1, ref2, ref3, outline_input)
|
| 20 |
+
return result
|
| 21 |
+
|
| 22 |
+
# ๊ธฐ์กด API ํจ์ ์ ์ (์ฌํ)
|
| 23 |
+
def generate_outline_2_api(category, style, ref1, ref2, ref3):
|
| 24 |
+
result = generate_outline_2(category, style, ref1, ref2, ref3)
|
| 25 |
+
return result
|
| 26 |
+
|
| 27 |
+
def generate_blog_post_2_api(category, style, ref1, ref2, ref3, outline_input):
|
| 28 |
+
result = generate_blog_post_2(category, style, ref1, ref2, ref3, outline_input)
|
| 29 |
+
return result
|
| 30 |
+
|
| 31 |
+
# ๊ธฐ์กด API ํจ์ ์ ์ (์ํํ๊ธฐ)
|
| 32 |
+
def generate_outline_3_api(category, style, ref1, ref2, ref3):
|
| 33 |
+
result = generate_outline_3(category, style, ref1, ref2, ref3)
|
| 34 |
+
return result
|
| 35 |
+
|
| 36 |
+
def generate_blog_post_3_api(category, style, ref1, ref2, ref3, outline_input):
|
| 37 |
+
result = generate_blog_post_3(category, style, ref1, ref2, ref3, outline_input)
|
| 38 |
+
return result
|
| 39 |
+
|
| 40 |
+
# ์๋ก์ด API ํจ์ ์ ์ (ํต์ฌ๊ธฐ๋ฅ์ง์คํ)
|
| 41 |
+
def generate_outline_4_api(category, style, ref1, ref2, ref3):
|
| 42 |
+
result = generate_outline_4(category, style, ref1, ref2, ref3)
|
| 43 |
+
return result
|
| 44 |
+
|
| 45 |
+
def generate_blog_post_4_api(category, style, ref1, ref2, ref3, selected_feature):
|
| 46 |
+
result = generate_blog_post_4(category, style, ref1, ref2, ref3, selected_feature)
|
| 47 |
+
return result
|
| 48 |
+
|
| 49 |
+
# ์๋ก์ด API ํจ์ ์ ์ (๋ฐฉ๋ฌธํ๊ธฐํ)
|
| 50 |
+
def generate_outline_5_api(category, style, ref1, ref2, ref3, photo_recommendations):
|
| 51 |
+
result = generate_outline_5(category, style, ref1, ref2, ref3, photo_recommendations)
|
| 52 |
+
return result
|
| 53 |
+
|
| 54 |
+
def generate_blog_post_5_api(category, style, ref1, ref2, ref3, outline_input, photo_recommendations):
|
| 55 |
+
result = generate_blog_post_5(category, style, ref1, ref2, ref3, outline_input, photo_recommendations)
|
| 56 |
+
return result
|
| 57 |
+
|
| 58 |
+
# Gradio ์ธํฐํ์ด์ค ์ค๊ณ (Gradio 5.0 ์ด์)
|
| 59 |
+
def interface():
|
| 60 |
+
with gr.Blocks() as demo:
|
| 61 |
+
gr.Markdown("# ๋ธ๋ก๊ทธ ํฌ์คํ
")
|
| 62 |
+
|
| 63 |
+
# ์ฒซ ๋ฒ์งธ ํญ: ์ ๋ณด์ฑ
|
| 64 |
+
with gr.Tab("์ ๋ณด์ฑ"):
|
| 65 |
+
category_1 = gr.Radio(choices=['์ผ๋ฐ', '์ํ๊ฑด๊ฐ'], label="ํฌ์คํ
์นดํ
๊ณ ๋ฆฌ", value="์ผ๋ฐ")
|
| 66 |
+
style_1 = gr.Radio(choices=['์น๊ทผํ', '์ผ๋ฐ', '์ ๋ฌธ์ ์ธ'], label="ํฌ์คํ
์คํ์ผ", value="์น๊ทผํ")
|
| 67 |
+
ref1_1 = gr.Textbox(label="์ฐธ๊ณ ๊ธ 1", placeholder="์ฐธ๊ณ ํ ๊ธ์ ์
๋ ฅํ์ธ์")
|
| 68 |
+
ref2_1 = gr.Textbox(label="์ฐธ๊ณ ๊ธ 2", placeholder="์ฐธ๊ณ ํ ๊ธ์ ์
๋ ฅํ์ธ์")
|
| 69 |
+
ref3_1 = gr.Textbox(label="์ฐธ๊ณ ๊ธ 3", placeholder="์ฐธ๊ณ ํ ๊ธ์ ์
๋ ฅํ์ธ์")
|
| 70 |
+
outline_button_1 = gr.Button("์์๋ผ์ธ ์์ฑ")
|
| 71 |
+
outline_output_1 = gr.Textbox(label="์์ฑ๋ ์์๋ผ์ธ")
|
| 72 |
+
|
| 73 |
+
outline_1 = gr.Textbox(label="์์ฑํ ์์๋ผ์ธ", placeholder="์์ฑ๋ ์์๋ผ์ธ์ ์
๋ ฅํ์ธ์")
|
| 74 |
+
blog_button_1 = gr.Button("๋ธ๋ก๊ทธ ๊ธ ์์ฑ")
|
| 75 |
+
blog_output_1 = gr.HTML(label="์์ฑ๋ ๋ธ๋ก๊ทธ ๊ธ (HTML ํ์)")
|
| 76 |
+
|
| 77 |
+
outline_button_1.click(generate_outline_1_api, inputs=[category_1, style_1, ref1_1, ref2_1, ref3_1], outputs=outline_output_1)
|
| 78 |
+
blog_button_1.click(generate_blog_post_1_api, inputs=[category_1, style_1, ref1_1, ref2_1, ref3_1, outline_1], outputs=blog_output_1)
|
| 79 |
+
|
| 80 |
+
# ๋ ๋ฒ์งธ ํญ: ์ฌํ
|
| 81 |
+
with gr.Tab("์ฌํ"):
|
| 82 |
+
category_2 = gr.Radio(choices=['์ฌํ ๋จ์ผ', '์ฌํ ์ฝ์ค'], label="ํฌ์คํ
์นดํ
๊ณ ๋ฆฌ", value="์ฌํ ๋จ์ผ")
|
| 83 |
+
style_2 = gr.Radio(choices=['์น๊ทผํ', '์ผ๋ฐ', '์ ๋ฌธ์ ์ธ'], label="ํฌ์คํ
์คํ์ผ", value="์น๊ทผํ")
|
| 84 |
+
ref1_2 = gr.Textbox(label="์ฐธ๊ณ ๊ธ 1", placeholder="์ฐธ๊ณ ํ ๊ธ์ ์
๋ ฅํ์ธ์")
|
| 85 |
+
ref2_2 = gr.Textbox(label="์ฐธ๊ณ ๊ธ 2", placeholder="์ฐธ๊ณ ํ ๊ธ์ ์
๋ ฅํ์ธ์")
|
| 86 |
+
ref3_2 = gr.Textbox(label="์ฐธ๊ณ ๊ธ 3", placeholder="์ฐธ๊ณ ํ ๊ธ์ ์
๋ ฅํ์ธ์")
|
| 87 |
+
outline_button_2 = gr.Button("์์๋ผ์ธ ์์ฑ")
|
| 88 |
+
outline_output_2 = gr.Textbox(label="์์ฑ๋ ์์๋ผ์ธ")
|
| 89 |
+
|
| 90 |
+
outline_2 = gr.Textbox(label="์์ฑํ ์์๋ผ์ธ", placeholder="์์ฑ๋ ์์๋ผ์ธ์ ์
๋ ฅํ์ธ์")
|
| 91 |
+
blog_button_2 = gr.Button("๋ธ๋ก๊ทธ ๊ธ ์์ฑ")
|
| 92 |
+
blog_output_2 = gr.HTML(label="์์ฑ๋ ๋ธ๋ก๊ทธ ๊ธ (HTML ํ์)")
|
| 93 |
+
|
| 94 |
+
outline_button_2.click(generate_outline_2_api, inputs=[category_2, style_2, ref1_2, ref2_2, ref3_2], outputs=outline_output_2)
|
| 95 |
+
blog_button_2.click(generate_blog_post_2_api, inputs=[category_2, style_2, ref1_2, ref2_2, ref3_2, outline_2], outputs=blog_output_2)
|
| 96 |
+
|
| 97 |
+
# ์ธ ๋ฒ์งธ ํญ: ์ํํ๊ธฐ
|
| 98 |
+
with gr.Tab("์ํํ๊ธฐ"):
|
| 99 |
+
category_3 = gr.Radio(choices=['์ผ๋ฐ', '๊ธฐ๋ฅ์ง์คํ', '๊ณ ๊ฐ๋ฐ์ํ'], label="ํฌ์คํ
์นดํ
๊ณ ๋ฆฌ", value="์ผ๋ฐ")
|
| 100 |
+
style_3 = gr.Radio(choices=['์น๊ทผํ', '์ผ๋ฐ', '์ ๋ฌธ์ ์ธ'], label="ํฌ์คํ
์คํ์ผ", value="์น๊ทผํ")
|
| 101 |
+
ref1_3 = gr.Textbox(label="์ฐธ๊ณ ๊ธ 1", placeholder="์ฐธ๊ณ ํ ๊ธ์ ์
๋ ฅํ์ธ์")
|
| 102 |
+
ref2_3 = gr.Textbox(label="์ฐธ๊ณ ๊ธ 2", placeholder="์ฐธ๊ณ ํ ๊ธ์ ์
๋ ฅํ์ธ์")
|
| 103 |
+
ref3_3 = gr.Textbox(label="์ฐธ๊ณ ๊ธ 3", placeholder="์ฐธ๊ณ ํ ๊ธ์ ์
๋ ฅํ์ธ์")
|
| 104 |
+
outline_button_3 = gr.Button("์์๋ผ์ธ ์์ฑ")
|
| 105 |
+
outline_output_3 = gr.Textbox(label="์์ฑ๋ ์์๋ผ์ธ")
|
| 106 |
+
|
| 107 |
+
outline_3 = gr.Textbox(label="์์ฑํ ์์๋ผ์ธ", placeholder="์์ฑ๋ ์์๋ผ์ธ์ ์
๋ ฅํ์ธ์")
|
| 108 |
+
blog_button_3 = gr.Button("๋ธ๋ก๊ทธ ๊ธ ์์ฑ")
|
| 109 |
+
blog_output_3 = gr.HTML(label="์์ฑ๋ ๋ธ๋ก๊ทธ ๊ธ (HTML ํ์)")
|
| 110 |
+
|
| 111 |
+
outline_button_3.click(generate_outline_3_api, inputs=[category_3, style_3, ref1_3, ref2_3, ref3_3], outputs=outline_output_3)
|
| 112 |
+
blog_button_3.click(generate_blog_post_3_api, inputs=[category_3, style_3, ref1_3, ref2_3, ref3_3, outline_3], outputs=blog_output_3)
|
| 113 |
+
|
| 114 |
+
# ๋ค ๋ฒ์งธ ํญ: ํต์ฌ๊ธฐ๋ฅ์ง์คํ
|
| 115 |
+
with gr.Tab("ํต์ฌ๊ธฐ๋ฅ์ง์คํ"):
|
| 116 |
+
category_4 = gr.Radio(choices=['ํต์ฌ๊ธฐ๋ฅ์ง์คํ'], label="ํฌ์คํ
์นดํ
๊ณ ๋ฆฌ", value="ํต์ฌ๊ธฐ๋ฅ์ง์คํ")
|
| 117 |
+
style_4 = gr.Radio(choices=['์น๊ทผํ', '์ผ๋ฐ', '์ ๋ฌธ์ ์ธ'], label="ํฌ์คํ
์คํ์ผ", value="์น๊ทผํ")
|
| 118 |
+
ref1_4 = gr.Textbox(label="์ฐธ๊ณ ๊ธ 1", placeholder="์ฐธ๊ณ ํ ๊ธ์ ์
๋ ฅํ์ธ์")
|
| 119 |
+
ref2_4 = gr.Textbox(label="์ฐธ๊ณ ๊ธ 2", placeholder="์ฐธ๊ณ ํ ๊ธ์ ์
๋ ฅํ์ธ์")
|
| 120 |
+
ref3_4 = gr.Textbox(label="์ฐธ๊ณ ๊ธ 3", placeholder="์ฐธ๊ณ ํ ๊ธ์ ์
๋ ฅํ์ธ์")
|
| 121 |
+
outline_button_4 = gr.Button("ํต์ฌ๊ธฐ๋ฅ ์ ์ ํ๊ธฐ")
|
| 122 |
+
outline_result1 = gr.Textbox(label="ํต์ฌ๊ธฐ๋ฅ 1")
|
| 123 |
+
outline_result2 = gr.Textbox(label="ํต์ฌ๊ธฐ๋ฅ 2")
|
| 124 |
+
outline_result3 = gr.Textbox(label="ํต์ฌ๊ธฐ๋ฅ 3")
|
| 125 |
+
outline_4 = gr.Textbox(label="์์ฑํ ํต์ฌ๊ธฐ๋ฅ ์ฃผ์ ์ค์ 1๊ฐ๋ง ์
๋ ฅํด์ฃผ์ธ์", placeholder="ํต์ฌ๊ธฐ๋ฅ 1๊ฐ๋ง ์
๋ ฅํ์ธ์")
|
| 126 |
+
blog_button_4 = gr.Button("๋ธ๋ก๊ทธ ๊ธ ์์ฑ")
|
| 127 |
+
blog_output_4 = gr.HTML(label="์์ฑ๋ ๋ธ๋ก๊ทธ ๊ธ (HTML ํ์)")
|
| 128 |
+
|
| 129 |
+
outline_button_4.click(generate_outline_4_api, inputs=[category_4, style_4, ref1_4, ref2_4, ref3_4], outputs=[outline_result1, outline_result2, outline_result3])
|
| 130 |
+
blog_button_4.click(generate_blog_post_4_api, inputs=[category_4, style_4, ref1_4, ref2_4, ref3_4, outline_4], outputs=blog_output_4)
|
| 131 |
+
|
| 132 |
+
# ๋ค์ฏ ๋ฒ์งธ ํญ: ๋ฐฉ๋ฌธํ๊ธฐํ
|
| 133 |
+
with gr.Tab("๋ฐฉ๋ฌธํ๊ธฐํ"):
|
| 134 |
+
category_5 = gr.Radio(choices=['๋ฐฉ๋ฌธํ๊ธฐํ'], label="ํฌ์คํ
์นดํ
๊ณ ๋ฆฌ", value="๋ฐฉ๋ฌธํ๊ธฐํ")
|
| 135 |
+
style_5 = gr.Radio(choices=['์น๊ทผํ', '์ผ๋ฐ', '์ ๋ฌธ์ ์ธ'], label="ํฌ์คํ
์คํ์ผ", value="์น๊ทผํ")
|
| 136 |
+
ref1_5 = gr.Textbox(label="์ฐธ๊ณ ๊ธ 1", placeholder="์ฐธ๊ณ ํ ๊ธ์ ์
๋ ฅํ์ธ์")
|
| 137 |
+
ref2_5 = gr.Textbox(label="์ฐธ๊ณ ๊ธ 2", placeholder="์ฐธ๊ณ ํ ๊ธ์ ์
๋ ฅํ์ธ์")
|
| 138 |
+
ref3_5 = gr.Textbox(label="์ฐธ๊ณ ๊ธ 3", placeholder="์ฐธ๊ณ ํ ๊ธ์ ์
๋ ฅํ์ธ์")
|
| 139 |
+
photo_recommendations_5 = gr.Textbox(label="์ฌ์ง ํํ ํค์๋", placeholder="์ฌ์ง ์ถ์ฒ ํค์๋๋ฅผ ์
๋ ฅํ์ธ์")
|
| 140 |
+
outline_button_5 = gr.Button("์์๋ผ์ธ ์์ฑ")
|
| 141 |
+
outline_output_5 = gr.Textbox(label="์์ฑ๋ ์์๋ผ์ธ")
|
| 142 |
+
|
| 143 |
+
outline_5 = gr.Textbox(label="์์ฑํ ์์๋ผ์ธ", placeholder="์์ฑ๋ ์์๋ผ์ธ์ ์
๋ ฅํ์ธ์")
|
| 144 |
+
blog_button_5 = gr.Button("๋ธ๋ก๊ทธ ๊ธ ์์ฑ")
|
| 145 |
+
blog_output_5 = gr.HTML(label="์์ฑ๋ ๋ธ๋ก๊ทธ ๊ธ (HTML ํ์)")
|
| 146 |
+
|
| 147 |
+
outline_button_5.click(
|
| 148 |
+
generate_outline_5_api,
|
| 149 |
+
inputs=[category_5, style_5, ref1_5, ref2_5, ref3_5, photo_recommendations_5],
|
| 150 |
+
outputs=outline_output_5
|
| 151 |
+
)
|
| 152 |
+
blog_button_5.click(
|
| 153 |
+
generate_blog_post_5_api,
|
| 154 |
+
inputs=[category_5, style_5, ref1_5, ref2_5, ref3_5, outline_5, photo_recommendations_5],
|
| 155 |
+
outputs=blog_output_5
|
| 156 |
+
)
|
| 157 |
+
|
| 158 |
+
return demo
|
| 159 |
+
|
| 160 |
+
# ์ธํฐํ์ด์ค ์คํ
|
| 161 |
+
if __name__ == "__main__":
|
| 162 |
+
interface().launch(share=True)
|