Spaces:
Sleeping
Sleeping
| 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() | |