Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -71,14 +71,25 @@ def majority_vote_with_steps(question, num_iterations=10):
|
|
| 71 |
|
| 72 |
return majority_voted_ans, steps_solution
|
| 73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
# Gradio interface for user input and output
|
| 75 |
-
def gradio_interface(question
|
| 76 |
final_answer, steps_solution = majority_vote_with_steps(question, iterations)
|
|
|
|
| 77 |
return {
|
| 78 |
"Question": question,
|
| 79 |
"Majority-Voted Answer": final_answer,
|
| 80 |
"Steps to Solve": steps_solution,
|
| 81 |
-
"Correct Solution":
|
| 82 |
}
|
| 83 |
|
| 84 |
# Custom CSS for enhanced design (unchanged)
|
|
@@ -120,7 +131,7 @@ custom_css = """
|
|
| 120 |
background-color: #f1f8ff;
|
| 121 |
margin-bottom: 15px;
|
| 122 |
}
|
| 123 |
-
#math_question
|
| 124 |
font-size: 20px;
|
| 125 |
font-family: 'Poppins', sans-serif;
|
| 126 |
font-weight: 500px;
|
|
@@ -175,14 +186,12 @@ interface = gr.Interface(
|
|
| 175 |
fn=gradio_interface,
|
| 176 |
inputs=[
|
| 177 |
gr.Textbox(label="π§ Math Question", placeholder="Enter your math question here...", elem_id="math_question"),
|
| 178 |
-
|
| 179 |
],
|
| 180 |
outputs=[
|
| 181 |
gr.JSON(label="π Results"), # Display the results in a JSON format
|
| 182 |
-
|
| 183 |
],
|
| 184 |
title="π’ Math Question Solver",
|
| 185 |
-
description="Enter a math question to get the model's majority-voted answer
|
| 186 |
css=custom_css # Apply custom CSS
|
| 187 |
)
|
| 188 |
|
|
|
|
| 71 |
|
| 72 |
return majority_voted_ans, steps_solution
|
| 73 |
|
| 74 |
+
# Correct solution for the problem (programmatically or hardcoded)
|
| 75 |
+
def fetch_correct_solution(question):
|
| 76 |
+
# You can define or fetch the correct solution here
|
| 77 |
+
# For example, for demonstration, I'll hardcode it
|
| 78 |
+
correct_solution_map = {
|
| 79 |
+
"What is 2 + 2?": "4",
|
| 80 |
+
"Solve for x in 2x + 3 = 7.": "x = 2",
|
| 81 |
+
}
|
| 82 |
+
return correct_solution_map.get(question, "Correct solution not available.")
|
| 83 |
+
|
| 84 |
# Gradio interface for user input and output
|
| 85 |
+
def gradio_interface(question):
|
| 86 |
final_answer, steps_solution = majority_vote_with_steps(question, iterations)
|
| 87 |
+
correct_solution = fetch_correct_solution(question)
|
| 88 |
return {
|
| 89 |
"Question": question,
|
| 90 |
"Majority-Voted Answer": final_answer,
|
| 91 |
"Steps to Solve": steps_solution,
|
| 92 |
+
"Correct Solution": correct_solution # Include the correct solution in the output
|
| 93 |
}
|
| 94 |
|
| 95 |
# Custom CSS for enhanced design (unchanged)
|
|
|
|
| 131 |
background-color: #f1f8ff;
|
| 132 |
margin-bottom: 15px;
|
| 133 |
}
|
| 134 |
+
#math_question {
|
| 135 |
font-size: 20px;
|
| 136 |
font-family: 'Poppins', sans-serif;
|
| 137 |
font-weight: 500px;
|
|
|
|
| 186 |
fn=gradio_interface,
|
| 187 |
inputs=[
|
| 188 |
gr.Textbox(label="π§ Math Question", placeholder="Enter your math question here...", elem_id="math_question"),
|
|
|
|
| 189 |
],
|
| 190 |
outputs=[
|
| 191 |
gr.JSON(label="π Results"), # Display the results in a JSON format
|
|
|
|
| 192 |
],
|
| 193 |
title="π’ Math Question Solver",
|
| 194 |
+
description="Enter a math question to get the model's majority-voted answer, steps to solve the problem, and the correct solution.",
|
| 195 |
css=custom_css # Apply custom CSS
|
| 196 |
)
|
| 197 |
|