upscale-frog / app.py
comfyri's picture
Update app.py
3f73c86 verified
import gradio as gr
import time
# ๊ฐœ๊ตฌ๋ฆฌ ์ ํ”„ GIF (์ƒ๋‹จ UI + ๋กœ๋”ฉ ์• ๋‹ˆ๋ฉ”์ด์…˜)
FROG_GIF = "https://media.giphy.com/media/ICOgUNjpvO0PC/giphy.gif"
gr.Image("frog_jump.gif", show_label=False)
# ----------------------------------------------------
# 1) LLM ์—”์ง„ ์„ ํƒ ์ฒ˜๋ฆฌ
# ----------------------------------------------------
def switch_engine(engine_name):
# ๊ฐœ๊ตฌ๋ฆฌ๊ฐ€ ์ ํ”„ํ•˜๋Š” ํšจ๊ณผ๋ฅผ ์ฃผ๊ธฐ ์œ„ํ•œ ์ถœ๋ ฅ
frog_html = f"""
<div style='text-align:center;'>
<img src="{FROG_GIF}" width="130"><br>
<p>๐Ÿธ ๊ฐœ๊ตฌ๋ฆฌ๊ฐ€ {engine_name} ์—”์ง„์œผ๋กœ ์ ํ”„ ์ค‘... gegulgegul...</p>
</div>
"""
return frog_html
# ----------------------------------------------------
# 2) ์ฑ— ๊ธฐ๋Šฅ
# ----------------------------------------------------
def chat(engine, history, message):
# ๋ฉ”์‹œ์ง€ ๋ณด๋‚ผ ๋•Œ ๊ฐœ๊ตฌ๋ฆฌ ์ ํ”„ ์• ๋‹ˆ๋ฉ”์ด์…˜ ์ถœ๋ ฅ
loading_html = f"""
<div style='text-align:center;'>
<img src="{FROG_GIF}" width="120">
<p>๐Ÿธ ๊ฐœ๊ตฌ๋ฆฌ๊ฐ€ ์ƒ๊ฐ ์ค‘... gegulgegul...</p>
</div>
"""
yield history + [(message, loading_html)]
# === LLM ์—ฐ๊ฒฐ์€ ๋‚˜์ค‘์— ํ‚ค ๋„ฃ์œผ๋ฉด ๋ณ€๊ฒฝ ๊ฐ€๋Šฅ ===
# ์ž„์‹œ๋กœ ๋ฐ˜์‘๋งŒ ์ถœ๋ ฅ
time.sleep(0.8)
response = f"{engine} ์—”์ง„ ์‘๋‹ต: {message} (์ž„์‹œ Mock ์‘๋‹ต)"
yield history + [(message, response)]
# ----------------------------------------------------
# 3) ์ตœ์ƒ๋‹จ ๊ฐœ๊ตฌ๋ฆฌ ํ—ค๋” HTML
# ----------------------------------------------------
header_html = f"""
<div style='text-align:center; margin-bottom:20px;'>
<img src="{FROG_GIF}" width="150"><br>
<h1>๐Ÿธ Upscale Frog โ€” Multi-LLM RAG Engine</h1>
<p>gegulgegul v1.0 โ€” Full Frog Edition</p>
</div>
"""
# ----------------------------------------------------
# 4) Gradio UI
# ----------------------------------------------------
def ui():
with gr.Blocks(css=".gradio-container {background-color: #101010;}") as demo:
# ์ƒ๋‹จ ๊ฐœ๊ตฌ๋ฆฌ ํ—ค๋”
gr.HTML(header_html)
# LLM ์„ ํƒ ๋ฐ•์Šค
engine_choice = gr.Dropdown(
["GPT-4o-mini", "Gemini-Pro", "Grok-Mixtral"],
label="LLM ์—”์ง„ ์„ ํƒ"
)
# ์—”์ง„ ๋ฐ”๊ฟ€ ๋•Œ ๊ฐœ๊ตฌ๋ฆฌ ์ ํ”„ ์ถœ๋ ฅ
engine_output = gr.HTML()
engine_choice.change(fn=switch_engine, inputs=engine_choice, outputs=engine_output)
chat_history = gr.Chatbot()
message_box = gr.Textbox(label="๋ฉ”์‹œ์ง€ ์ž…๋ ฅ")
# ์ „์†ก ๋ฒ„ํŠผ
send_btn = gr.Button("Send")
send_btn.click(
fn=chat,
inputs=[engine_choice, chat_history, message_box],
outputs=chat_history
)
return demo
demo = ui()
demo.launch()