Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,58 +1,62 @@
|
|
| 1 |
-
|
| 2 |
-
from
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
#
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
)
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from function import GetLLMResponse
|
| 3 |
+
|
| 4 |
+
# List of math topics and difficulty levels
|
| 5 |
+
math_topics = {
|
| 6 |
+
"Elementary School Level": ["Basic Arithmetic", "Place Value", "Fraction", "Decimals", "Geomerty"],
|
| 7 |
+
"Middle School Level": ["Algebra", "Ratio and Proportion", "Percentages", "Geometry", "Integers and Rational Numbers"],
|
| 8 |
+
"High School Level": ["Algebra II", "Trigonometry", "Pre-Calculus", "Calculus", "Statistics and Probability"]
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
# Page configuration
|
| 12 |
+
st.set_page_config(page_title="Generate Math Quizzes",
|
| 13 |
+
page_icon="🧮",
|
| 14 |
+
layout="centered",
|
| 15 |
+
initial_sidebar_state="collapsed")
|
| 16 |
+
|
| 17 |
+
# Header and description
|
| 18 |
+
st.title("Generate Math Quizzes 🧮")
|
| 19 |
+
st.text("Choose the difficulty level and topic for your math quizzes.")
|
| 20 |
+
|
| 21 |
+
# User input for quiz generation
|
| 22 |
+
## Layout in columns
|
| 23 |
+
col1, col2, col3 = st.columns([1, 1, 1])
|
| 24 |
+
|
| 25 |
+
with col1:
|
| 26 |
+
selected_topic_level = st.selectbox('Select Topic Level', list(math_topics.keys()))
|
| 27 |
+
|
| 28 |
+
with col2:
|
| 29 |
+
selected_topic = st.selectbox('Select Topic', math_topics[selected_topic_level])
|
| 30 |
+
|
| 31 |
+
with col3:
|
| 32 |
+
num_quizzes = st.slider('Number Quizzes', min_value=1, max_value= 5, value=1)
|
| 33 |
+
|
| 34 |
+
submit = st.button('Generate Quizzes')
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
# Final Response
|
| 38 |
+
if submit:
|
| 39 |
+
with st.spinner("Generating Quizzes..."):
|
| 40 |
+
response = GetLLMResponse(selected_topic_level, selected_topic, num_quizzes)
|
| 41 |
+
st.success("Quizzes Generated!")
|
| 42 |
+
|
| 43 |
+
# Display questions and answers in a table
|
| 44 |
+
if response:
|
| 45 |
+
st.subheader("Quiz Questions and Answers:")
|
| 46 |
+
# Prepare data for the table
|
| 47 |
+
col1, col2 = st.columns(2)
|
| 48 |
+
with col1:
|
| 49 |
+
st.subheader("Questions")
|
| 50 |
+
questions = response.get('questions')
|
| 51 |
+
st.write(questions)
|
| 52 |
+
|
| 53 |
+
with col2:
|
| 54 |
+
st.subheader("Answers")
|
| 55 |
+
answers = response.get('answer')
|
| 56 |
+
st.write(answers)
|
| 57 |
+
|
| 58 |
+
else:
|
| 59 |
+
st.warning("No Quiz Questions and Answers")
|
| 60 |
+
|
| 61 |
+
else:
|
| 62 |
+
st.warning("Click the 'Generate Quizzes' button to create quizzes.")
|