Spaces:
Running
Running
Jeff Myers II
commited on
Commit
·
b00c2e5
1
Parent(s):
c500843
Completed Prototype
Browse files
app.py
CHANGED
@@ -14,7 +14,7 @@ model = GemmaLLM() ##################################### Initialize the Gemma mo
|
|
14 |
|
15 |
# %%
|
16 |
with gr.Blocks() as demo:
|
17 |
-
gr.Markdown("#
|
18 |
|
19 |
######
|
20 |
###### State Variables and Components Initialization
|
@@ -22,7 +22,7 @@ with gr.Blocks() as demo:
|
|
22 |
|
23 |
init = ( ########################################### Initialize the Gradio interface with components and state variables
|
24 |
|
25 |
-
gr.Markdown("##
|
26 |
|
27 |
## State variables for news articles and quiz,
|
28 |
|
@@ -231,7 +231,7 @@ with gr.Blocks() as demo:
|
|
231 |
if missing: print(f"Multiple choice question object is missing keys: {missing}.")
|
232 |
else: multichoicequests.append(mcq)
|
233 |
|
234 |
-
return gr.Markdown("##
|
235 |
|
236 |
ready.click(get_quiz, inputs=[content], outputs=[
|
237 |
heading, num_headlines, category, get, headline, description, show, summarize, content, ready, submit, answers, *quiz])
|
@@ -243,17 +243,16 @@ with gr.Blocks() as demo:
|
|
243 |
elif not quiz: print("Quiz is empty.")
|
244 |
elif not isinstance(answers, list): print(f"Answers is a {type(answers)} but should be {type(list())}.")
|
245 |
else:
|
246 |
-
|
247 |
-
results =
|
248 |
-
percent = results / len(answers)
|
249 |
|
250 |
-
if 0.9 <=
|
251 |
-
elif 0.8 <=
|
252 |
-
elif 0.7 <=
|
253 |
-
elif 0.6 <=
|
254 |
-
elif 0.5 <=
|
255 |
-
elif
|
256 |
-
else: evaluation = f"You scored {results
|
257 |
|
258 |
return show_eval(evaluation)
|
259 |
|
|
|
14 |
|
15 |
# %%
|
16 |
with gr.Blocks() as demo:
|
17 |
+
gr.Markdown("# Reading & Quiz Application")
|
18 |
|
19 |
######
|
20 |
###### State Variables and Components Initialization
|
|
|
22 |
|
23 |
init = ( ########################################### Initialize the Gradio interface with components and state variables
|
24 |
|
25 |
+
gr.Markdown("## Read Articles"),
|
26 |
|
27 |
## State variables for news articles and quiz,
|
28 |
|
|
|
231 |
if missing: print(f"Multiple choice question object is missing keys: {missing}.")
|
232 |
else: multichoicequests.append(mcq)
|
233 |
|
234 |
+
return gr.Markdown("## Quiz"), *hide_news(), *show_quiz(multichoicequests)
|
235 |
|
236 |
ready.click(get_quiz, inputs=[content], outputs=[
|
237 |
heading, num_headlines, category, get, headline, description, show, summarize, content, ready, submit, answers, *quiz])
|
|
|
243 |
elif not quiz: print("Quiz is empty.")
|
244 |
elif not isinstance(answers, list): print(f"Answers is a {type(answers)} but should be {type(list())}.")
|
245 |
else:
|
246 |
+
results = sum(1 for ans, resp in zip(answers, list(quiz)) if ans == resp) / len(answers)
|
247 |
+
results = round(results, 4)
|
|
|
248 |
|
249 |
+
if 0.9 <= results <= 1.0: evaluation = f"Excellent! You scored {results * 100}%."
|
250 |
+
elif 0.8 <= results < 0.9: evaluation = f"Great job! You scored {results * 100}%."
|
251 |
+
elif 0.7 <= results < 0.8: evaluation = f"Good effort! You scored {results * 100}%."
|
252 |
+
elif 0.6 <= results < 0.7: evaluation = f"You scored {results * 100}%. Keep practicing!"
|
253 |
+
elif 0.5 <= results < 0.6: evaluation = f"You scored {results * 100}%. You can do better!"
|
254 |
+
elif results < 0: evaluation = f"Unable to evaluate. Please try again."
|
255 |
+
else: evaluation = f"You scored {results * 100}%. Keep trying!"
|
256 |
|
257 |
return show_eval(evaluation)
|
258 |
|