BillBojangeles2000 commited on
Commit
82da3f3
β€’
1 Parent(s): 868089c

Update app.py

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