Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -25,13 +25,13 @@ def get_answer(question, ans_a, ans_b, ans_c, ans_d):
|
|
| 25 |
# Parse the final answer
|
| 26 |
try:
|
| 27 |
final_answer = answer_text.split("Answer:")[1].strip().split('\n')[0]
|
| 28 |
-
if final_answer
|
| 29 |
return ans_a
|
| 30 |
-
elif final_answer
|
| 31 |
return ans_b
|
| 32 |
-
elif final_answer
|
| 33 |
return ans_c
|
| 34 |
-
elif final_answer
|
| 35 |
return ans_d
|
| 36 |
else:
|
| 37 |
return final_answer
|
|
@@ -42,7 +42,11 @@ def get_answer(question, ans_a, ans_b, ans_c, ans_d):
|
|
| 42 |
return final_answer
|
| 43 |
|
| 44 |
# --- Gradio Interface ---
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
gr.Markdown("# EdNA: MCQ Answering App")
|
| 47 |
gr.Markdown("Enter a multiple-choice question and four possible answers, then click 'Get Answer' to see the model's prediction.")
|
| 48 |
|
|
@@ -53,8 +57,8 @@ with gr.Blocks() as demo:
|
|
| 53 |
answer_c_input = gr.Textbox(label="Answer C", placeholder="Enter answer C")
|
| 54 |
answer_d_input = gr.Textbox(label="Answer D", placeholder="Enter answer D")
|
| 55 |
|
| 56 |
-
get_answer_button = gr.Button("Get Answer")
|
| 57 |
-
final_answer_output = gr.Textbox(label="The Model's Answer")
|
| 58 |
|
| 59 |
get_answer_button.click(
|
| 60 |
fn=get_answer,
|
|
|
|
| 25 |
# Parse the final answer
|
| 26 |
try:
|
| 27 |
final_answer = answer_text.split("Answer:")[1].strip().split('\n')[0]
|
| 28 |
+
if final_answer.startswith("A)"):
|
| 29 |
return ans_a
|
| 30 |
+
elif final_answer.startswith("B)"):
|
| 31 |
return ans_b
|
| 32 |
+
elif final_answer.startswith("C)"):
|
| 33 |
return ans_c
|
| 34 |
+
elif final_answer.startswith("D)"):
|
| 35 |
return ans_d
|
| 36 |
else:
|
| 37 |
return final_answer
|
|
|
|
| 42 |
return final_answer
|
| 43 |
|
| 44 |
# --- Gradio Interface ---
|
| 45 |
+
|
| 46 |
+
# Define a soft theme with a green primary color for a more modern look
|
| 47 |
+
theme = gr.themes.Soft(primary_hue="green")
|
| 48 |
+
|
| 49 |
+
with gr.Blocks(theme=theme) as demo:
|
| 50 |
gr.Markdown("# EdNA: MCQ Answering App")
|
| 51 |
gr.Markdown("Enter a multiple-choice question and four possible answers, then click 'Get Answer' to see the model's prediction.")
|
| 52 |
|
|
|
|
| 57 |
answer_c_input = gr.Textbox(label="Answer C", placeholder="Enter answer C")
|
| 58 |
answer_d_input = gr.Textbox(label="Answer D", placeholder="Enter answer D")
|
| 59 |
|
| 60 |
+
get_answer_button = gr.Button("Get Answer", variant="primary")
|
| 61 |
+
final_answer_output = gr.Textbox(label="The Model's Answer", interactive=False)
|
| 62 |
|
| 63 |
get_answer_button.click(
|
| 64 |
fn=get_answer,
|