Update app.py
Browse files
app.py
CHANGED
@@ -1,28 +1,41 @@
|
|
1 |
import gradio as gr
|
2 |
from generate import generate_response
|
3 |
|
4 |
-
def
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
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
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
gr.
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
)
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from generate import generate_response
|
3 |
|
4 |
+
def answer_question(question, context, use_rag, temperature):
|
5 |
+
if not question.strip():
|
6 |
+
return "❌ Please enter a question."
|
7 |
+
|
8 |
+
answer = generate_response(
|
9 |
+
question=question,
|
10 |
+
context=context.strip(),
|
11 |
+
use_rag=use_rag,
|
12 |
+
temperature=temperature
|
13 |
+
)
|
14 |
+
return answer or "(No meaningful response generated.)"
|
15 |
|
16 |
title = "🧠 EvoRAG — SQuAD-Tuned QA with Optional Web Retrieval"
|
17 |
+
description = "Ask a question with optional context. Evo was fine-tuned on SQuAD v2. Toggle RAG for live web search if no context is available."
|
18 |
+
|
19 |
+
with gr.Blocks() as demo:
|
20 |
+
gr.Markdown(f"# {title}")
|
21 |
+
gr.Markdown(description)
|
22 |
+
|
23 |
+
with gr.Row():
|
24 |
+
question = gr.Textbox(label="❓ Question", placeholder="e.g. What is the capital of Japan?")
|
25 |
+
|
26 |
+
context = gr.Textbox(label="📄 Context (Optional)", placeholder="Paste context or leave blank to use RAG", lines=4)
|
27 |
+
|
28 |
+
with gr.Row():
|
29 |
+
use_rag = gr.Checkbox(label="🔍 Use RAG (Live Web Search)", value=False)
|
30 |
+
temperature = gr.Slider(0.1, 1.5, value=1.0, step=0.1, label="🔥 Temperature")
|
31 |
+
|
32 |
+
with gr.Row():
|
33 |
+
submit = gr.Button("Submit")
|
34 |
+
clear = gr.Button("Clear")
|
35 |
+
|
36 |
+
output = gr.Textbox(label="🤖 Evo's Answer", lines=4)
|
37 |
+
|
38 |
+
submit.click(fn=answer_question, inputs=[question, context, use_rag, temperature], outputs=output)
|
39 |
+
clear.click(fn=lambda: ("", "", False, 1.0, ""), inputs=[], outputs=[question, context, use_rag, temperature, output])
|
40 |
+
|
41 |
+
demo.launch()
|