Spaces:
Runtime error
Runtime error
BillBojangeles2000
commited on
Commit
β’
82da3f3
1
Parent(s):
868089c
Update app.py
Browse files
app.py
CHANGED
@@ -68,7 +68,7 @@ Quiz_Gen = st.form("Quiz Generation")
|
|
68 |
res = Quiz_Gen.text_input("What topic do you want to get quizzed on?")
|
69 |
sub = Quiz_Gen.form_submit_button("Submit")
|
70 |
|
71 |
-
if
|
72 |
entity = res
|
73 |
prefix = "https://wiki.kidzsearch.com/wiki/"
|
74 |
page = requests.get(f'{prefix}{entity}')
|
@@ -101,7 +101,7 @@ if sub:
|
|
101 |
|
102 |
Quiz = st.form("Quiz")
|
103 |
st.toast("Filtering Questions", icon='β
')
|
104 |
-
|
105 |
# Check if questions are generated in session state
|
106 |
if 'questions' in st.session_state:
|
107 |
question_index = 0
|
@@ -121,34 +121,35 @@ if 'questions' in st.session_state:
|
|
121 |
question_index += 1
|
122 |
|
123 |
submit_button = Quiz.form_submit_button("Submit")
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
|
|
|
68 |
res = Quiz_Gen.text_input("What topic do you want to get quizzed on?")
|
69 |
sub = Quiz_Gen.form_submit_button("Submit")
|
70 |
|
71 |
+
if not res:
|
72 |
entity = res
|
73 |
prefix = "https://wiki.kidzsearch.com/wiki/"
|
74 |
page = requests.get(f'{prefix}{entity}')
|
|
|
101 |
|
102 |
Quiz = st.form("Quiz")
|
103 |
st.toast("Filtering Questions", icon='β
')
|
104 |
+
submit_button = False
|
105 |
# Check if questions are generated in session state
|
106 |
if 'questions' in st.session_state:
|
107 |
question_index = 0
|
|
|
121 |
question_index += 1
|
122 |
|
123 |
submit_button = Quiz.form_submit_button("Submit")
|
124 |
+
while not submit_button:
|
125 |
+
x=1
|
126 |
+
if submit_button:
|
127 |
+
st.toast("Calculating grade", icon='β
')
|
128 |
+
with st.spinner(text="Calculating Grade"):
|
129 |
+
for i, q in enumerate(st.session_state.questions):
|
130 |
+
st.toast(f'iteration {i} has begun', icon='β
')
|
131 |
+
result = client.predict(
|
132 |
+
f'What would you rate this answer to the question: "{q}" as a percentage? Here is the answer: {ans[i]}. Your percentage grade cannot be negative or over 100%. Additionally, you should also assume that the user is of a 5-7th grade level of intellect.',
|
133 |
+
0.9,
|
134 |
+
256,
|
135 |
+
0.9,
|
136 |
+
1.2,
|
137 |
+
api_name="/chat"
|
138 |
+
)
|
139 |
+
|
140 |
+
pattern = r'(\d+)%'
|
141 |
+
|
142 |
+
match = re.search(pattern, result)
|
143 |
+
if match:
|
144 |
+
score = match.group(1)
|
145 |
+
user_scores.append(int(score))
|
146 |
+
else:
|
147 |
+
user_scores.append(85) # You can set a default score if no score is found
|
148 |
+
|
149 |
+
# Calculate the average score using the user_scores list
|
150 |
+
average_score = sum(user_scores) / len(user_scores)
|
151 |
+
|
152 |
+
st.info(f'Your average score for the answers is {average_score}%')
|
153 |
+
st.write(f'Your average score for the answers is {average_score}%')
|
154 |
+
|
155 |
+
st.balloons()
|