Spaces:
Sleeping
Sleeping
added quiz to view
Browse files
app.py
CHANGED
|
@@ -49,6 +49,32 @@ questions_europe = [
|
|
| 49 |
])
|
| 50 |
]
|
| 51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
| 53 |
# change the LLM
|
| 54 |
|
|
|
|
| 49 |
])
|
| 50 |
]
|
| 51 |
|
| 52 |
+
def create_quiz(questions, match_func):
|
| 53 |
+
answers = []
|
| 54 |
+
with gr.Column():
|
| 55 |
+
for q, opts in questions:
|
| 56 |
+
choices = [opt[1] for opt in opts]
|
| 57 |
+
answers.append(gr.Radio(choices=choices, label=q))
|
| 58 |
+
result = gr.Textbox(label="In Europe you should travel to...")
|
| 59 |
+
btn = gr.Button("Find My Match")
|
| 60 |
+
|
| 61 |
+
def evaluate(*vals):
|
| 62 |
+
codes = []
|
| 63 |
+
for i, val in enumerate(vals):
|
| 64 |
+
if val is None:
|
| 65 |
+
codes.append("C")
|
| 66 |
+
else:
|
| 67 |
+
codes.append(next(opt[0] for opt in questions[i][1] if opt[1] == val))
|
| 68 |
+
return match_func(codes)
|
| 69 |
+
|
| 70 |
+
btn.click(evaluate, inputs=answers, outputs=result)
|
| 71 |
+
return answers, result, btn
|
| 72 |
+
|
| 73 |
+
with gr.Blocks() as demo:
|
| 74 |
+
gr.Markdown("Where Should I Travel Quiz?")
|
| 75 |
+
|
| 76 |
+
demo.launch()
|
| 77 |
+
|
| 78 |
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
| 79 |
# change the LLM
|
| 80 |
|