Update app.py
Browse files
app.py
CHANGED
@@ -1,31 +1,28 @@
|
|
1 |
import gradio as gr
|
2 |
from generate import generate_response
|
3 |
-
from web_search import web_search
|
4 |
|
5 |
-
def
|
6 |
try:
|
7 |
-
|
8 |
-
|
9 |
-
return response if response else "(No meaningful response generated.)"
|
10 |
except Exception as e:
|
11 |
-
return f"Error: {str(e)}"
|
12 |
|
13 |
-
|
14 |
-
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
-
|
21 |
-
|
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()
|
|
|
1 |
import gradio as gr
|
2 |
from generate import generate_response
|
|
|
3 |
|
4 |
+
def chat_interface(question, context, use_rag, temperature):
|
5 |
try:
|
6 |
+
answer = generate_response(question, context, use_rag=use_rag, temperature=temperature)
|
7 |
+
return answer if answer else "(No meaningful response generated.)"
|
|
|
8 |
except Exception as e:
|
9 |
+
return f"(Error: {str(e)})"
|
10 |
|
11 |
+
title = "🧠 EvoRAG — SQuAD-Tuned QA with Optional Web Retrieval"
|
12 |
+
description = "Ask a question with optional context. Evo was fine-tuned on SQuAD v2.\nToggle RAG for live web search if no context is available."
|
13 |
|
14 |
+
iface = gr.Interface(
|
15 |
+
fn=chat_interface,
|
16 |
+
inputs=[
|
17 |
+
gr.Textbox(label="❓ Question"),
|
18 |
+
gr.Textbox(label="📄 Context (Optional)", lines=5, placeholder="Paste context or leave blank to use RAG"),
|
19 |
+
gr.Checkbox(label="🔍 Use RAG (Live Web Search)"),
|
20 |
+
gr.Slider(0.1, 1.5, value=1.0, label="🔥 Temperature")
|
21 |
+
],
|
22 |
+
outputs=gr.Textbox(label="🤖 Evo's Answer"),
|
23 |
+
title=title,
|
24 |
+
description=description,
|
25 |
+
)
|
26 |
|
27 |
+
if __name__ == "__main__":
|
28 |
+
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|