BillBojangeles2000 commited on
Commit
c79abf3
β€’
1 Parent(s): ffa9454

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -27
app.py CHANGED
@@ -117,30 +117,31 @@ submit_button = Quiz.form_submit_button("Submit")
117
 
118
  if submit_button:
119
  st.toast("Calculating grade", icon='βœ…')
120
- st.spinner(text="Calculating Grade")
121
- for i, q in enumerate(questions):
122
- result = client.predict(
123
- 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.',
124
- 0.9,
125
- 256,
126
- 0.9,
127
- 1.2,
128
- api_name="/chat"
129
- )
130
-
131
- pattern = r'(\d+)%'
132
-
133
- match = re.search(pattern, result)
134
- if match:
135
- score = match.group(1)
136
- user_scores.append(int(score))
137
- else:
138
- user_scores.append(85) # You can set a default score if no score is found
139
-
140
- # Calculate the average score using the user_scores list
141
- average_score = sum(user_scores) / len(user_scores)
142
-
143
- st.info(f'Your average score for the answers is {average_score}%')
144
- st.write(f'Your average score for the answers is {average_score}%')
145
-
146
- st.balloons()
 
 
117
 
118
  if submit_button:
119
  st.toast("Calculating grade", icon='βœ…')
120
+ with st.spinner(text="Calculating Grade"):
121
+ for i, q in enumerate(questions):
122
+ st.toast(f'iteration {i} has begun', icon='βœ…')
123
+ result = client.predict(
124
+ 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.',
125
+ 0.9,
126
+ 256,
127
+ 0.9,
128
+ 1.2,
129
+ api_name="/chat"
130
+ )
131
+
132
+ pattern = r'(\d+)%'
133
+
134
+ match = re.search(pattern, result)
135
+ if match:
136
+ score = match.group(1)
137
+ user_scores.append(int(score))
138
+ else:
139
+ user_scores.append(85) # You can set a default score if no score is found
140
+
141
+ # Calculate the average score using the user_scores list
142
+ average_score = sum(user_scores) / len(user_scores)
143
+
144
+ st.info(f'Your average score for the answers is {average_score}%')
145
+ st.write(f'Your average score for the answers is {average_score}%')
146
+
147
+ st.balloons()