File size: 1,030 Bytes
3ee05fc e557b05 3ee05fc a0acc08 3ee05fc b19b35a 3ee05fc b19b35a 3ee05fc b19b35a 3ee05fc b19b35a 3ee05fc b19b35a 3ee05fc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# app.py — Gradio chat interface for EvoDecoder with optional RAG (web search)
import gradio as gr
from generate import generate_response
with gr.Blocks(title="🧠 EvoDecoder Chat with RAG") as app:
gr.Markdown("## 🧠 Chat with EvoDecoder — Now with 🔍 Web Context (RAG)")
chatbot = gr.Chatbot(label="Chat with Evo", type="messages")
msg = gr.Textbox(label="Ask Evo anything...", placeholder="e.g., What is quantum computing?")
use_web = gr.Checkbox(label="🔍 Use Web Context (RAG)", value=True)
clear = gr.Button("🧹 Clear Chat")
def chat_fn(user_message, history, web_flag):
response = generate_response(user_message, use_web=web_flag)
history = history or []
history.append({"role": "user", "content": user_message})
history.append({"role": "assistant", "content": response})
return history, ""
msg.submit(chat_fn, inputs=[msg, chatbot, use_web], outputs=[chatbot, msg])
clear.click(lambda: ([], ""), outputs=[chatbot, msg])
app.launch()
|