Update app.py
Browse files
app.py
CHANGED
@@ -1,22 +1,22 @@
|
|
1 |
-
# app.py —
|
2 |
-
|
3 |
import gradio as gr
|
4 |
from generate import generate_response
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
return "", chat_history
|
18 |
|
19 |
-
msg.submit(chat_fn, [msg, chatbot,
|
20 |
-
|
21 |
|
22 |
demo.launch()
|
|
|
1 |
+
# app.py — EvoDecoder Chat UI with optional web search toggle
|
|
|
2 |
import gradio as gr
|
3 |
from generate import generate_response
|
4 |
|
5 |
+
def chat_fn(message, chat_history, web_flag):
|
6 |
+
response = generate_response(message, use_web=web_flag)
|
7 |
+
chat_history.append({"role": "user", "content": message})
|
8 |
+
chat_history.append({"role": "assistant", "content": response})
|
9 |
+
return "", chat_history
|
10 |
+
|
11 |
+
with gr.Blocks(title="EvoDecoder RAG Chatbot") as demo:
|
12 |
+
gr.Markdown("🧠 **Chat with EvoDecoder — Lightweight Conversational AI**")
|
13 |
|
14 |
+
chatbot = gr.Chatbot(label="Chat with Evo", type="messages", height=400)
|
15 |
+
msg = gr.Textbox(placeholder="Ask Evo anything...", label="Your message")
|
16 |
+
web_flag = gr.Checkbox(label="🔎 Use Web Search (RAG)", value=True)
|
17 |
+
clear_btn = gr.Button("Clear")
|
|
|
18 |
|
19 |
+
msg.submit(chat_fn, [msg, chatbot, web_flag], [msg, chatbot])
|
20 |
+
clear_btn.click(lambda: ([], ""), outputs=[chatbot, msg])
|
21 |
|
22 |
demo.launch()
|