EWV2DDWEE / app.py
ssboost's picture
Update app.py
dbaa5c5 verified
import gradio as gr
import os
import sys
import tempfile
from io import StringIO
import traceback
import inspect
# ๊ฐ ๋ชจ๋“ˆ์˜ ํ•จ์ˆ˜๋“ค์„ ์ €์žฅํ•  ๋”•์…”๋„ˆ๋ฆฌ
module_functions = {}
# ํ™˜๊ฒฝ๋ณ€์ˆ˜์—์„œ ๊ฐ ๋ชจ๋“ˆ ์ฝ”๋“œ๋ฅผ ๋ถˆ๋Ÿฌ์™€์„œ ์‹คํ–‰
def load_and_execute_module(module_name, module_key):
"""ํ™˜๊ฒฝ๋ณ€์ˆ˜์—์„œ ๋ชจ๋“ˆ ์ฝ”๋“œ๋ฅผ ๋ถˆ๋Ÿฌ์™€์„œ ์‹คํ–‰ํ•˜๊ณ  ํ•จ์ˆ˜๋“ค์„ ์ €์žฅ"""
try:
module_code = os.getenv(module_name)
if not module_code:
raise ValueError(f"ํ™˜๊ฒฝ๋ณ€์ˆ˜ {module_name}์ด ์„ค์ •๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค.")
# ๋ชจ๋“ˆ ์‹คํ–‰ ์ „ ํ˜„์žฌ globals ์ƒํƒœ ์ €์žฅ
before_globals = set(globals().keys())
# ๋ชจ๋“ˆ ์ฝ”๋“œ ์‹คํ–‰
exec(module_code, globals())
# ๋ชจ๋“ˆ ์‹คํ–‰ ํ›„ ์ƒˆ๋กœ ์ถ”๊ฐ€๋œ ํ•จ์ˆ˜๋“ค ์ฐพ๊ธฐ
after_globals = set(globals().keys())
new_functions = after_globals - before_globals
# ์ƒˆ๋กœ ์ถ”๊ฐ€๋œ ํ•จ์ˆ˜๋“ค์„ ๋ชจ๋“ˆ๋ณ„๋กœ ์ €์žฅ
module_functions[module_key] = {}
for func_name in new_functions:
if callable(globals()[func_name]) and not func_name.startswith('_'):
module_functions[module_key][func_name] = globals()[func_name]
print(f"{module_name} ๋ชจ๋“ˆ์ด ์„ฑ๊ณต์ ์œผ๋กœ ๋กœ๋“œ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.")
print(f"๋กœ๋“œ๋œ ํ•จ์ˆ˜๋“ค: {list(module_functions[module_key].keys())}")
except Exception as e:
print(f"{module_name} ๋ชจ๋“ˆ ๋กœ๋“œ ์ค‘ ์˜ค๋ฅ˜: {str(e)}")
traceback.print_exc()
module_functions[module_key] = {}
# ๊ฐ ๋ชจ๋“ˆ ๋กœ๋“œ
print("๋ชจ๋“ˆ๋“ค์„ ๋กœ๋“œํ•˜๋Š” ์ค‘...")
# ์ •๋ณด์„ฑ ๋ธ”๋กœ๊ทธ ๋ชจ๋“ˆ ๋กœ๋“œ
load_and_execute_module("INFO_BLOG_CODE", "info_blog")
# ์—ฌํ–‰ ๋ธ”๋กœ๊ทธ ๋ชจ๋“ˆ ๋กœ๋“œ
load_and_execute_module("TRAVEL_BLOG_CODE", "travel_blog")
# ์ƒํ’ˆํ›„๊ธฐ ๋ธ”๋กœ๊ทธ ๋ชจ๋“ˆ ๋กœ๋“œ
load_and_execute_module("PRODUCT_REVIEW_BLOG_CODE", "product_review_blog")
# ํ•ต์‹ฌ๊ธฐ๋Šฅ์ง‘์ค‘ํ˜• ๋ธ”๋กœ๊ทธ ๋ชจ๋“ˆ ๋กœ๋“œ
load_and_execute_module("FEATURE_FOCUS_BLOG_CODE", "feature_focus_blog")
# ๋ฐฉ๋ฌธํ›„๊ธฐํ˜• ๋ธ”๋กœ๊ทธ ๋ชจ๋“ˆ ๋กœ๋“œ
load_and_execute_module("VISIT_REVIEW_BLOG_CODE", "visit_review_blog")
print("๋ชจ๋“  ๋ชจ๋“ˆ ๋กœ๋“œ ์™„๋ฃŒ!")
# ๊ฐ ๋ชจ๋“ˆ์˜ ํ•จ์ˆ˜ ํ™•์ธ
for module_key, functions in module_functions.items():
print(f"{module_key}: {list(functions.keys())}")
# ๋ž˜ํผ ํ•จ์ˆ˜๋“ค ์ •์˜
# ์ •๋ณด์„ฑ ๋ธ”๋กœ๊ทธ ๋ž˜ํผ ํ•จ์ˆ˜๋“ค
def generate_outline_1_wrapper(category, style, ref1, ref2, ref3):
"""์ •๋ณด์„ฑ ๋ธ”๋กœ๊ทธ ์•„์›ƒ๋ผ์ธ ์ƒ์„ฑ ๋ž˜ํผ"""
try:
# ์ •๋ณด์„ฑ ๋ธ”๋กœ๊ทธ ๋ชจ๋“ˆ์—์„œ ํ•จ์ˆ˜ ์ฐพ๊ธฐ
if 'generate_outline_1' in module_functions.get('info_blog', {}):
return module_functions['info_blog']['generate_outline_1'](category, style, ref1, ref2, ref3)
elif 'generate_outline' in module_functions.get('info_blog', {}):
return module_functions['info_blog']['generate_outline'](category, style, ref1, ref2, ref3)
else:
return "์ •๋ณด์„ฑ ๋ธ”๋กœ๊ทธ ์•„์›ƒ๋ผ์ธ ์ƒ์„ฑ ํ•จ์ˆ˜๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค."
except Exception as e:
return f"์ •๋ณด์„ฑ ๋ธ”๋กœ๊ทธ ์•„์›ƒ๋ผ์ธ ์ƒ์„ฑ ์ค‘ ์˜ค๋ฅ˜: {str(e)}"
def generate_blog_post_1_wrapper(category, style, ref1, ref2, ref3, outline):
"""์ •๋ณด์„ฑ ๋ธ”๋กœ๊ทธ ๊ธ€ ์ƒ์„ฑ ๋ž˜ํผ"""
try:
if 'generate_blog_post_1' in module_functions.get('info_blog', {}):
return module_functions['info_blog']['generate_blog_post_1'](category, style, ref1, ref2, ref3, outline)
elif 'generate_blog_post' in module_functions.get('info_blog', {}):
return module_functions['info_blog']['generate_blog_post'](category, style, outline, ref1, ref2, ref3)
else:
return "์ •๋ณด์„ฑ ๋ธ”๋กœ๊ทธ ๊ธ€ ์ƒ์„ฑ ํ•จ์ˆ˜๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค."
except Exception as e:
return f"์ •๋ณด์„ฑ ๋ธ”๋กœ๊ทธ ๊ธ€ ์ƒ์„ฑ ์ค‘ ์˜ค๋ฅ˜: {str(e)}"
# ์—ฌํ–‰ ๋ธ”๋กœ๊ทธ ๋ž˜ํผ ํ•จ์ˆ˜๋“ค
def generate_outline_2_wrapper(category, style, ref1, ref2, ref3):
"""์—ฌํ–‰ ๋ธ”๋กœ๊ทธ ์•„์›ƒ๋ผ์ธ ์ƒ์„ฑ ๋ž˜ํผ"""
try:
if 'generate_outline_2' in module_functions.get('travel_blog', {}):
return module_functions['travel_blog']['generate_outline_2'](category, style, ref1, ref2, ref3)
elif 'generate_outline' in module_functions.get('travel_blog', {}):
return module_functions['travel_blog']['generate_outline'](category, style, ref1, ref2, ref3)
else:
return "์—ฌํ–‰ ๋ธ”๋กœ๊ทธ ์•„์›ƒ๋ผ์ธ ์ƒ์„ฑ ํ•จ์ˆ˜๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค."
except Exception as e:
return f"์—ฌํ–‰ ๋ธ”๋กœ๊ทธ ์•„์›ƒ๋ผ์ธ ์ƒ์„ฑ ์ค‘ ์˜ค๋ฅ˜: {str(e)}"
def generate_blog_post_2_wrapper(category, style, ref1, ref2, ref3, outline):
"""์—ฌํ–‰ ๋ธ”๋กœ๊ทธ ๊ธ€ ์ƒ์„ฑ ๋ž˜ํผ"""
try:
if 'generate_blog_post_2' in module_functions.get('travel_blog', {}):
return module_functions['travel_blog']['generate_blog_post_2'](category, style, ref1, ref2, ref3, outline)
elif 'generate_blog_post' in module_functions.get('travel_blog', {}):
return module_functions['travel_blog']['generate_blog_post'](category, style, outline, ref1, ref2, ref3)
else:
return "์—ฌํ–‰ ๋ธ”๋กœ๊ทธ ๊ธ€ ์ƒ์„ฑ ํ•จ์ˆ˜๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค."
except Exception as e:
return f"์—ฌํ–‰ ๋ธ”๋กœ๊ทธ ๊ธ€ ์ƒ์„ฑ ์ค‘ ์˜ค๋ฅ˜: {str(e)}"
# ์ƒํ’ˆํ›„๊ธฐ ๋ธ”๋กœ๊ทธ ๋ž˜ํผ ํ•จ์ˆ˜๋“ค
def generate_outline_3_wrapper(category, style, ref1, ref2, ref3):
"""์ƒํ’ˆํ›„๊ธฐ ๋ธ”๋กœ๊ทธ ์•„์›ƒ๋ผ์ธ ์ƒ์„ฑ ๋ž˜ํผ"""
try:
if 'generate_outline_3' in module_functions.get('product_review_blog', {}):
return module_functions['product_review_blog']['generate_outline_3'](category, style, ref1, ref2, ref3)
elif 'generate_outline' in module_functions.get('product_review_blog', {}):
return module_functions['product_review_blog']['generate_outline'](category, style, ref1, ref2, ref3)
else:
return "์ƒํ’ˆํ›„๊ธฐ ๋ธ”๋กœ๊ทธ ์•„์›ƒ๋ผ์ธ ์ƒ์„ฑ ํ•จ์ˆ˜๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค."
except Exception as e:
return f"์ƒํ’ˆํ›„๊ธฐ ๋ธ”๋กœ๊ทธ ์•„์›ƒ๋ผ์ธ ์ƒ์„ฑ ์ค‘ ์˜ค๋ฅ˜: {str(e)}"
def generate_blog_post_3_wrapper(category, style, ref1, ref2, ref3, outline):
"""์ƒํ’ˆํ›„๊ธฐ ๋ธ”๋กœ๊ทธ ๊ธ€ ์ƒ์„ฑ ๋ž˜ํผ"""
try:
if 'generate_blog_post_3' in module_functions.get('product_review_blog', {}):
return module_functions['product_review_blog']['generate_blog_post_3'](category, style, ref1, ref2, ref3, outline)
elif 'generate_blog_post' in module_functions.get('product_review_blog', {}):
return module_functions['product_review_blog']['generate_blog_post'](category, style, outline, ref1, ref2, ref3)
else:
return "์ƒํ’ˆํ›„๊ธฐ ๋ธ”๋กœ๊ทธ ๊ธ€ ์ƒ์„ฑ ํ•จ์ˆ˜๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค."
except Exception as e:
return f"์ƒํ’ˆํ›„๊ธฐ ๋ธ”๋กœ๊ทธ ๊ธ€ ์ƒ์„ฑ ์ค‘ ์˜ค๋ฅ˜: {str(e)}"
# ํ•ต์‹ฌ๊ธฐ๋Šฅ์ง‘์ค‘ํ˜• ๋ธ”๋กœ๊ทธ ๋ž˜ํผ ํ•จ์ˆ˜๋“ค
def generate_outline_4_wrapper(category, style, ref1, ref2, ref3):
"""ํ•ต์‹ฌ๊ธฐ๋Šฅ์ง‘์ค‘ํ˜• ๋ธ”๋กœ๊ทธ ์•„์›ƒ๋ผ์ธ ์ƒ์„ฑ ๋ž˜ํผ"""
try:
if 'generate_outline_4' in module_functions.get('feature_focus_blog', {}):
result = module_functions['feature_focus_blog']['generate_outline_4'](category, style, ref1, ref2, ref3)
if isinstance(result, tuple) and len(result) == 3:
return result
else:
return (str(result), "", "")
elif 'generate_outline' in module_functions.get('feature_focus_blog', {}):
result = module_functions['feature_focus_blog']['generate_outline'](category, style, ref1, ref2, ref3)
return (str(result), "", "")
else:
return ("ํ•ต์‹ฌ๊ธฐ๋Šฅ์ง‘์ค‘ํ˜• ๋ธ”๋กœ๊ทธ ์•„์›ƒ๋ผ์ธ ์ƒ์„ฑ ํ•จ์ˆ˜๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.", "", "")
except Exception as e:
return (f"ํ•ต์‹ฌ๊ธฐ๋Šฅ์ง‘์ค‘ํ˜• ๋ธ”๋กœ๊ทธ ์•„์›ƒ๋ผ์ธ ์ƒ์„ฑ ์ค‘ ์˜ค๋ฅ˜: {str(e)}", "", "")
def generate_blog_post_4_wrapper(category, style, ref1, ref2, ref3, outline):
"""ํ•ต์‹ฌ๊ธฐ๋Šฅ์ง‘์ค‘ํ˜• ๋ธ”๋กœ๊ทธ ๊ธ€ ์ƒ์„ฑ ๋ž˜ํผ"""
try:
if 'generate_blog_post_4' in module_functions.get('feature_focus_blog', {}):
return module_functions['feature_focus_blog']['generate_blog_post_4'](category, style, ref1, ref2, ref3, outline)
elif 'generate_blog_post' in module_functions.get('feature_focus_blog', {}):
return module_functions['feature_focus_blog']['generate_blog_post'](category, style, outline, ref1, ref2, ref3)
else:
return "ํ•ต์‹ฌ๊ธฐ๋Šฅ์ง‘์ค‘ํ˜• ๋ธ”๋กœ๊ทธ ๊ธ€ ์ƒ์„ฑ ํ•จ์ˆ˜๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค."
except Exception as e:
return f"ํ•ต์‹ฌ๊ธฐ๋Šฅ์ง‘์ค‘ํ˜• ๋ธ”๋กœ๊ทธ ๊ธ€ ์ƒ์„ฑ ์ค‘ ์˜ค๋ฅ˜: {str(e)}"
# ๋ฐฉ๋ฌธํ›„๊ธฐํ˜• ๋ธ”๋กœ๊ทธ ๋ž˜ํผ ํ•จ์ˆ˜๋“ค
def generate_outline_5_wrapper(category, style, ref1, ref2, ref3, photo_recommendations):
"""๋ฐฉ๋ฌธํ›„๊ธฐํ˜• ๋ธ”๋กœ๊ทธ ์•„์›ƒ๋ผ์ธ ์ƒ์„ฑ ๋ž˜ํผ"""
try:
if 'generate_outline_5' in module_functions.get('visit_review_blog', {}):
return module_functions['visit_review_blog']['generate_outline_5'](category, style, ref1, ref2, ref3, photo_recommendations)
elif 'generate_outline' in module_functions.get('visit_review_blog', {}):
return module_functions['visit_review_blog']['generate_outline'](category, style, ref1, ref2, ref3, photo_recommendations)
else:
return "๋ฐฉ๋ฌธํ›„๊ธฐํ˜• ๋ธ”๋กœ๊ทธ ์•„์›ƒ๋ผ์ธ ์ƒ์„ฑ ํ•จ์ˆ˜๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค."
except Exception as e:
return f"๋ฐฉ๋ฌธํ›„๊ธฐํ˜• ๋ธ”๋กœ๊ทธ ์•„์›ƒ๋ผ์ธ ์ƒ์„ฑ ์ค‘ ์˜ค๋ฅ˜: {str(e)}"
def generate_blog_post_5_wrapper(category, style, ref1, ref2, ref3, outline, photo_recommendations):
"""๋ฐฉ๋ฌธํ›„๊ธฐํ˜• ๋ธ”๋กœ๊ทธ ๊ธ€ ์ƒ์„ฑ ๋ž˜ํผ"""
try:
if 'generate_blog_post_5' in module_functions.get('visit_review_blog', {}):
return module_functions['visit_review_blog']['generate_blog_post_5'](category, style, ref1, ref2, ref3, outline, photo_recommendations)
elif 'generate_blog_post' in module_functions.get('visit_review_blog', {}):
return module_functions['visit_review_blog']['generate_blog_post'](category, style, ref1, ref2, ref3, outline, photo_recommendations)
else:
return "๋ฐฉ๋ฌธํ›„๊ธฐํ˜• ๋ธ”๋กœ๊ทธ ๊ธ€ ์ƒ์„ฑ ํ•จ์ˆ˜๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค."
except Exception as e:
return f"๋ฐฉ๋ฌธํ›„๊ธฐํ˜• ๋ธ”๋กœ๊ทธ ๊ธ€ ์ƒ์„ฑ ์ค‘ ์˜ค๋ฅ˜: {str(e)}"
print("๋ž˜ํผ ํ•จ์ˆ˜๋“ค ์ •์˜ ์™„๋ฃŒ!")
# Gradio ์ธํ„ฐํŽ˜์ด์Šค ์„ค๊ณ„ (Gradio 5.0 ์ด์ƒ)
def interface():
with gr.Blocks() as demo:
gr.Markdown("# ๋ธ”๋กœ๊ทธ ํฌ์ŠคํŒ…")
# ์ฒซ ๋ฒˆ์งธ ํƒญ: ์ •๋ณด์„ฑ
with gr.Tab("์ •๋ณด์„ฑ"):
category_1 = gr.Radio(choices=['์ผ๋ฐ˜', '์ƒํ™œ๊ฑด๊ฐ•'], label="ํฌ์ŠคํŒ… ์นดํ…Œ๊ณ ๋ฆฌ", value="์ผ๋ฐ˜")
style_1 = gr.Radio(choices=['์นœ๊ทผํ•œ', '์ผ๋ฐ˜', '์ „๋ฌธ์ ์ธ'], label="ํฌ์ŠคํŒ… ์Šคํƒ€์ผ", value="์นœ๊ทผํ•œ")
ref1_1 = gr.Textbox(label="์ฐธ๊ณ  ๊ธ€ 1", placeholder="์ฐธ๊ณ ํ•  ๊ธ€์„ ์ž…๋ ฅํ•˜์„ธ์š”")
ref2_1 = gr.Textbox(label="์ฐธ๊ณ  ๊ธ€ 2", placeholder="์ฐธ๊ณ ํ•  ๊ธ€์„ ์ž…๋ ฅํ•˜์„ธ์š”")
ref3_1 = gr.Textbox(label="์ฐธ๊ณ  ๊ธ€ 3", placeholder="์ฐธ๊ณ ํ•  ๊ธ€์„ ์ž…๋ ฅํ•˜์„ธ์š”")
outline_button_1 = gr.Button("์•„์›ƒ๋ผ์ธ ์ƒ์„ฑ")
outline_output_1 = gr.Textbox(label="์ƒ์„ฑ๋œ ์•„์›ƒ๋ผ์ธ")
outline_1 = gr.Textbox(label="์ž‘์„ฑํ•  ์•„์›ƒ๋ผ์ธ", placeholder="์ƒ์„ฑ๋œ ์•„์›ƒ๋ผ์ธ์„ ์ž…๋ ฅํ•˜์„ธ์š”")
blog_button_1 = gr.Button("๋ธ”๋กœ๊ทธ ๊ธ€ ์ƒ์„ฑ")
blog_output_1 = gr.HTML(label="์ƒ์„ฑ๋œ ๋ธ”๋กœ๊ทธ ๊ธ€ (HTML ํ˜•์‹)")
outline_button_1.click(generate_outline_1_wrapper, inputs=[category_1, style_1, ref1_1, ref2_1, ref3_1], outputs=outline_output_1)
blog_button_1.click(generate_blog_post_1_wrapper, inputs=[category_1, style_1, ref1_1, ref2_1, ref3_1, outline_1], outputs=blog_output_1)
# ๋‘ ๋ฒˆ์งธ ํƒญ: ์—ฌํ–‰
with gr.Tab("์—ฌํ–‰"):
category_2 = gr.Radio(choices=['์—ฌํ–‰ ๋‹จ์ผ', '์—ฌํ–‰ ์ฝ”์Šค'], label="ํฌ์ŠคํŒ… ์นดํ…Œ๊ณ ๋ฆฌ", value="์—ฌํ–‰ ๋‹จ์ผ")
style_2 = gr.Radio(choices=['์นœ๊ทผํ•œ', '์ผ๋ฐ˜', '์ „๋ฌธ์ ์ธ'], label="ํฌ์ŠคํŒ… ์Šคํƒ€์ผ", value="์นœ๊ทผํ•œ")
ref1_2 = gr.Textbox(label="์ฐธ๊ณ  ๊ธ€ 1", placeholder="์ฐธ๊ณ ํ•  ๊ธ€์„ ์ž…๋ ฅํ•˜์„ธ์š”")
ref2_2 = gr.Textbox(label="์ฐธ๊ณ  ๊ธ€ 2", placeholder="์ฐธ๊ณ ํ•  ๊ธ€์„ ์ž…๋ ฅํ•˜์„ธ์š”")
ref3_2 = gr.Textbox(label="์ฐธ๊ณ  ๊ธ€ 3", placeholder="์ฐธ๊ณ ํ•  ๊ธ€์„ ์ž…๋ ฅํ•˜์„ธ์š”")
outline_button_2 = gr.Button("์•„์›ƒ๋ผ์ธ ์ƒ์„ฑ")
outline_output_2 = gr.Textbox(label="์ƒ์„ฑ๋œ ์•„์›ƒ๋ผ์ธ")
outline_2 = gr.Textbox(label="์ž‘์„ฑํ•  ์•„์›ƒ๋ผ์ธ", placeholder="์ƒ์„ฑ๋œ ์•„์›ƒ๋ผ์ธ์„ ์ž…๋ ฅํ•˜์„ธ์š”")
blog_button_2 = gr.Button("๋ธ”๋กœ๊ทธ ๊ธ€ ์ƒ์„ฑ")
blog_output_2 = gr.HTML(label="์ƒ์„ฑ๋œ ๋ธ”๋กœ๊ทธ ๊ธ€ (HTML ํ˜•์‹)")
outline_button_2.click(generate_outline_2_wrapper, inputs=[category_2, style_2, ref1_2, ref2_2, ref3_2], outputs=outline_output_2)
blog_button_2.click(generate_blog_post_2_wrapper, inputs=[category_2, style_2, ref1_2, ref2_2, ref3_2, outline_2], outputs=blog_output_2)
# ์„ธ ๋ฒˆ์งธ ํƒญ: ์ƒํ’ˆํ›„๊ธฐ
with gr.Tab("์ƒํ’ˆํ›„๊ธฐ"):
category_3 = gr.Radio(choices=['์ผ๋ฐ˜', '๊ธฐ๋Šฅ์ง‘์ค‘ํ˜•', '๊ณ ๊ฐ๋ฐ˜์‘ํ˜•'], label="ํฌ์ŠคํŒ… ์นดํ…Œ๊ณ ๋ฆฌ", value="์ผ๋ฐ˜")
style_3 = gr.Radio(choices=['์นœ๊ทผํ•œ', '์ผ๋ฐ˜', '์ „๋ฌธ์ ์ธ'], label="ํฌ์ŠคํŒ… ์Šคํƒ€์ผ", value="์นœ๊ทผํ•œ")
ref1_3 = gr.Textbox(label="์ฐธ๊ณ  ๊ธ€ 1", placeholder="์ฐธ๊ณ ํ•  ๊ธ€์„ ์ž…๋ ฅํ•˜์„ธ์š”")
ref2_3 = gr.Textbox(label="์ฐธ๊ณ  ๊ธ€ 2", placeholder="์ฐธ๊ณ ํ•  ๊ธ€์„ ์ž…๋ ฅํ•˜์„ธ์š”")
ref3_3 = gr.Textbox(label="์ฐธ๊ณ  ๊ธ€ 3", placeholder="์ฐธ๊ณ ํ•  ๊ธ€์„ ์ž…๋ ฅํ•˜์„ธ์š”")
outline_button_3 = gr.Button("์•„์›ƒ๋ผ์ธ ์ƒ์„ฑ")
outline_output_3 = gr.Textbox(label="์ƒ์„ฑ๋œ ์•„์›ƒ๋ผ์ธ")
outline_3 = gr.Textbox(label="์ž‘์„ฑํ•  ์•„์›ƒ๋ผ์ธ", placeholder="์ƒ์„ฑ๋œ ์•„์›ƒ๋ผ์ธ์„ ์ž…๋ ฅํ•˜์„ธ์š”")
blog_button_3 = gr.Button("๋ธ”๋กœ๊ทธ ๊ธ€ ์ƒ์„ฑ")
blog_output_3 = gr.HTML(label="์ƒ์„ฑ๋œ ๋ธ”๋กœ๊ทธ ๊ธ€ (HTML ํ˜•์‹)")
outline_button_3.click(generate_outline_3_wrapper, inputs=[category_3, style_3, ref1_3, ref2_3, ref3_3], outputs=outline_output_3)
blog_button_3.click(generate_blog_post_3_wrapper, inputs=[category_3, style_3, ref1_3, ref2_3, ref3_3, outline_3], outputs=blog_output_3)
# ๋„ค ๋ฒˆ์งธ ํƒญ: ํ•ต์‹ฌ๊ธฐ๋Šฅ์ง‘์ค‘ํ˜•
with gr.Tab("ํ•ต์‹ฌ๊ธฐ๋Šฅ์ง‘์ค‘ํ˜•"):
category_4 = gr.Radio(choices=['ํ•ต์‹ฌ๊ธฐ๋Šฅ์ง‘์ค‘ํ˜•'], label="ํฌ์ŠคํŒ… ์นดํ…Œ๊ณ ๋ฆฌ", value="ํ•ต์‹ฌ๊ธฐ๋Šฅ์ง‘์ค‘ํ˜•")
style_4 = gr.Radio(choices=['์นœ๊ทผํ•œ', '์ผ๋ฐ˜', '์ „๋ฌธ์ ์ธ'], label="ํฌ์ŠคํŒ… ์Šคํƒ€์ผ", value="์นœ๊ทผํ•œ")
ref1_4 = gr.Textbox(label="์ฐธ๊ณ  ๊ธ€ 1", placeholder="์ฐธ๊ณ ํ•  ๊ธ€์„ ์ž…๋ ฅํ•˜์„ธ์š”")
ref2_4 = gr.Textbox(label="์ฐธ๊ณ  ๊ธ€ 2", placeholder="์ฐธ๊ณ ํ•  ๊ธ€์„ ์ž…๋ ฅํ•˜์„ธ์š”")
ref3_4 = gr.Textbox(label="์ฐธ๊ณ  ๊ธ€ 3", placeholder="์ฐธ๊ณ ํ•  ๊ธ€์„ ์ž…๋ ฅํ•˜์„ธ์š”")
outline_button_4 = gr.Button("ํ•ต์‹ฌ๊ธฐ๋Šฅ ์„ ์ •ํ•˜๊ธฐ")
outline_result1 = gr.Textbox(label="ํ•ต์‹ฌ๊ธฐ๋Šฅ 1")
outline_result2 = gr.Textbox(label="ํ•ต์‹ฌ๊ธฐ๋Šฅ 2")
outline_result3 = gr.Textbox(label="ํ•ต์‹ฌ๊ธฐ๋Šฅ 3")
outline_4 = gr.Textbox(label="์ž‘์„ฑํ•  ํ•ต์‹ฌ๊ธฐ๋Šฅ ์ฃผ์ œ ์ค‘์— 1๊ฐœ๋งŒ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”", placeholder="ํ•ต์‹ฌ๊ธฐ๋Šฅ 1๊ฐœ๋งŒ ์ž…๋ ฅํ•˜์„ธ์š”")
blog_button_4 = gr.Button("๋ธ”๋กœ๊ทธ ๊ธ€ ์ƒ์„ฑ")
blog_output_4 = gr.HTML(label="์ƒ์„ฑ๋œ ๋ธ”๋กœ๊ทธ ๊ธ€ (HTML ํ˜•์‹)")
outline_button_4.click(generate_outline_4_wrapper, inputs=[category_4, style_4, ref1_4, ref2_4, ref3_4], outputs=[outline_result1, outline_result2, outline_result3])
blog_button_4.click(generate_blog_post_4_wrapper, inputs=[category_4, style_4, ref1_4, ref2_4, ref3_4, outline_4], outputs=blog_output_4)
# ๋‹ค์„ฏ ๋ฒˆ์งธ ํƒญ: ๋ฐฉ๋ฌธํ›„๊ธฐํ˜•
with gr.Tab("๋ฐฉ๋ฌธํ›„๊ธฐํ˜•"):
category_5 = gr.Radio(choices=['๋ฐฉ๋ฌธํ›„๊ธฐํ˜•'], label="ํฌ์ŠคํŒ… ์นดํ…Œ๊ณ ๋ฆฌ", value="๋ฐฉ๋ฌธํ›„๊ธฐํ˜•")
style_5 = gr.Radio(choices=['์นœ๊ทผํ•œ', '์ผ๋ฐ˜', '์ „๋ฌธ์ ์ธ'], label="ํฌ์ŠคํŒ… ์Šคํƒ€์ผ", value="์นœ๊ทผํ•œ")
ref1_5 = gr.Textbox(label="์ฐธ๊ณ  ๊ธ€ 1", placeholder="์ฐธ๊ณ ํ•  ๊ธ€์„ ์ž…๋ ฅํ•˜์„ธ์š”")
ref2_5 = gr.Textbox(label="์ฐธ๊ณ  ๊ธ€ 2", placeholder="์ฐธ๊ณ ํ•  ๊ธ€์„ ์ž…๋ ฅํ•˜์„ธ์š”")
ref3_5 = gr.Textbox(label="์ฐธ๊ณ  ๊ธ€ 3", placeholder="์ฐธ๊ณ ํ•  ๊ธ€์„ ์ž…๋ ฅํ•˜์„ธ์š”")
photo_recommendations_5 = gr.Textbox(label="์‚ฌ์ง„ ํ˜•ํƒœ ํ‚ค์›Œ๋“œ", placeholder="์‚ฌ์ง„ ์ถ”์ฒœ ํ‚ค์›Œ๋“œ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”")
outline_button_5 = gr.Button("์•„์›ƒ๋ผ์ธ ์ƒ์„ฑ")
outline_output_5 = gr.Textbox(label="์ƒ์„ฑ๋œ ์•„์›ƒ๋ผ์ธ")
outline_5 = gr.Textbox(label="์ž‘์„ฑํ•  ์•„์›ƒ๋ผ์ธ", placeholder="์ƒ์„ฑ๋œ ์•„์›ƒ๋ผ์ธ์„ ์ž…๋ ฅํ•˜์„ธ์š”")
blog_button_5 = gr.Button("๋ธ”๋กœ๊ทธ ๊ธ€ ์ƒ์„ฑ")
blog_output_5 = gr.HTML(label="์ƒ์„ฑ๋œ ๋ธ”๋กœ๊ทธ ๊ธ€ (HTML ํ˜•์‹)")
outline_button_5.click(
generate_outline_5_wrapper,
inputs=[category_5, style_5, ref1_5, ref2_5, ref3_5, photo_recommendations_5],
outputs=outline_output_5
)
blog_button_5.click(
generate_blog_post_5_wrapper,
inputs=[category_5, style_5, ref1_5, ref2_5, ref3_5, outline_5, photo_recommendations_5],
outputs=blog_output_5
)
return demo
# ์ธํ„ฐํŽ˜์ด์Šค ์‹คํ–‰
if __name__ == "__main__":
interface().launch(share=True)