HemanM commited on
Commit
5a8590e
·
verified ·
1 Parent(s): ec74c4d

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