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