File size: 1,093 Bytes
315a5d2
e557b05
 
 
315a5d2
51e5b61
315a5d2
 
51e5b61
315a5d2
 
 
 
 
 
 
b19b35a
315a5d2
 
 
b19b35a
315a5d2
 
 
 
 
b19b35a
5a8590e
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
# app.py — Gradio Chat UI for EvoDecoder + Web Search (RAG)
import gradio as gr
from generate import generate_response

def chat_fn(message, history, web_flag):
    response = generate_response(message, use_web=web_flag)
    history.append((message, response))
    return "", history

with gr.Blocks(title="EvoDecoder RAG Chat") as demo:
    gr.Markdown("# 🤖 EvoDecoder RAG Chatbot")
    with gr.Row():
        chatbot = gr.Chatbot(height=450)
        with gr.Column(scale=0.3):
            web_toggle = gr.Checkbox(label="Use Web Search (RAG)", value=True)
            clear_btn = gr.Button("🧹 Clear Chat")

    with gr.Row():
        msg_box = gr.Textbox(placeholder="Ask Evo something...", scale=4)
        submit_btn = gr.Button("Send", scale=1)

    history_state = gr.State([])

    submit_btn.click(fn=chat_fn, inputs=[msg_box, history_state, web_toggle], outputs=[msg_box, chatbot])
    msg_box.submit(fn=chat_fn, inputs=[msg_box, history_state, web_toggle], outputs=[msg_box, chatbot])
    clear_btn.click(fn=lambda: ([], ""), outputs=[chatbot, history_state])

demo.launch()