ssboost commited on
Commit
394327d
ยท
verified ยท
1 Parent(s): de6cbb8

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +162 -0
app.py ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #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)