Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import os
|
3 |
+
|
4 |
+
def calculator(num1, operation, num2):
|
5 |
+
if operation == "add":
|
6 |
+
return num1 + num2
|
7 |
+
elif operation == "subtract":
|
8 |
+
return num1 - num2
|
9 |
+
elif operation == "multiply":
|
10 |
+
return num1 * num2
|
11 |
+
elif operation == "divide":
|
12 |
+
return num1 / num2
|
13 |
+
|
14 |
+
HF_TOKEN = os.getenv('HF_TOKEN')
|
15 |
+
hf_writer = gr.HuggingFaceDatasetSaver(HF_TOKEN, "crowdsourced-calculator-demo")
|
16 |
+
|
17 |
+
iface = gr.Interface(
|
18 |
+
calculator,
|
19 |
+
["number", gr.inputs.Radio(["add", "subtract", "multiply", "divide"]), "number"],
|
20 |
+
"number",
|
21 |
+
allow_flagging="manual",
|
22 |
+
flagging_options=["wrong sign", "off by one", "other"],
|
23 |
+
flagging_callback=hf_writer
|
24 |
+
)
|
25 |
+
|
26 |
+
|
27 |
+
iface.launch()
|