Spaces:
Sleeping
Sleeping
File size: 2,737 Bytes
0115538 04352a1 3f73c86 04352a1 0115538 04352a1 0115538 04352a1 0115538 04352a1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
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()
|