EvoConvo / app.py
HemanM's picture
Update app.py
315a5d2 verified
raw
history blame
1.09 kB
# 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()