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()