HemanM commited on
Commit
51e5b61
·
verified ·
1 Parent(s): bf86bb3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -15
app.py CHANGED
@@ -1,22 +1,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()
 
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()