Update app.py
Browse files
app.py
CHANGED
@@ -1,37 +1,31 @@
|
|
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 |
-
# Prepare full conversation context
|
15 |
-
context = "\n".join(chat_history)
|
16 |
-
evo_reply = generate_response(context)
|
17 |
-
|
18 |
-
# Append Evo's response
|
19 |
-
chat_history.append(f"Evo: {evo_reply}")
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
chat_history = chat_history[-20:]
|
24 |
|
25 |
-
|
|
|
|
|
26 |
|
27 |
-
with gr.
|
28 |
-
|
29 |
-
|
30 |
-
user_input = gr.Textbox(label="Your Message")
|
31 |
|
32 |
-
|
33 |
-
|
|
|
34 |
|
35 |
-
|
|
|
36 |
|
37 |
demo.launch()
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from generate import generate_response
|
3 |
+
from web_search import web_search
|
4 |
|
5 |
+
def chat_with_evo(prompt, temperature=1.0, use_rag=False):
|
6 |
+
try:
|
7 |
+
context = web_search(prompt) if use_rag else ""
|
8 |
+
response = generate_response(prompt, temperature=temperature, external_context=context)
|
9 |
+
return response if response else "(No meaningful response generated.)"
|
10 |
+
except Exception as e:
|
11 |
+
return f"Error: {str(e)}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
+
with gr.Blocks(title="EvoRAG Chatbot") as demo:
|
14 |
+
gr.Markdown("## 🧠 EvoRAG — Lightweight Chatbot with Real-Time Retrieval")
|
|
|
15 |
|
16 |
+
with gr.Row():
|
17 |
+
prompt = gr.Textbox(label="💬 Ask Anything", placeholder="Type your question here...", lines=2)
|
18 |
+
response = gr.Textbox(label="🤖 Evo's Answer", interactive=False)
|
19 |
|
20 |
+
with gr.Row():
|
21 |
+
temp = gr.Slider(0.1, 1.5, step=0.1, value=1.0, label="🔥 Temperature")
|
22 |
+
use_rag = gr.Checkbox(label="🔍 Use RAG (live web context)", value=True)
|
|
|
23 |
|
24 |
+
with gr.Row():
|
25 |
+
clear_btn = gr.Button("🧹 Clear")
|
26 |
+
send_btn = gr.Button("🚀 Ask Evo")
|
27 |
|
28 |
+
send_btn.click(fn=chat_with_evo, inputs=[prompt, temp, use_rag], outputs=response)
|
29 |
+
clear_btn.click(fn=lambda: ("", ""), inputs=[], outputs=[prompt, response])
|
30 |
|
31 |
demo.launch()
|