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