Spaces:
Runtime error
Runtime error
update ui
Browse files
app.py
CHANGED
@@ -76,7 +76,7 @@ def line_generator(dataset):
|
|
76 |
line_generators = {dataset: line_generator(dataset) for dataset in datasets}
|
77 |
|
78 |
|
79 |
-
def send_report(sample, dataset, reason, annotator):
|
80 |
text = sample["text"]
|
81 |
sample.pop("text")
|
82 |
|
@@ -96,6 +96,7 @@ def send_report(sample, dataset, reason, annotator):
|
|
96 |
"metadata": sample,
|
97 |
"reason": reason,
|
98 |
"annotator": annotator,
|
|
|
99 |
"timestamp": str(datetime.now()),
|
100 |
}
|
101 |
)
|
@@ -108,6 +109,7 @@ def send_report(sample, dataset, reason, annotator):
|
|
108 |
"metadata": sample,
|
109 |
"reason": reason,
|
110 |
"annotator": annotator,
|
|
|
111 |
"timestamp": str(datetime.now()),
|
112 |
}
|
113 |
)
|
@@ -122,24 +124,34 @@ def send_report(sample, dataset, reason, annotator):
|
|
122 |
)
|
123 |
|
124 |
|
|
|
|
|
|
|
|
|
|
|
125 |
if __name__ == "__main__":
|
126 |
demo = gr.Blocks()
|
127 |
|
128 |
with demo:
|
129 |
current_sample_state = gr.State(dict())
|
130 |
|
|
|
131 |
with gr.Row():
|
132 |
annotator = gr.Textbox(
|
133 |
lines=1,
|
134 |
max_lines=1,
|
135 |
-
placeholder="
|
136 |
label="Annotator",
|
137 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
with gr.Row():
|
139 |
dataset = gr.Dropdown(
|
140 |
-
choices=datasets,
|
141 |
-
value="Pick a dataset below",
|
142 |
-
label="Dataset",
|
143 |
)
|
144 |
with gr.Row():
|
145 |
reason_txt = gr.Textbox(
|
@@ -163,8 +175,8 @@ if __name__ == "__main__":
|
|
163 |
gr.update(visible=True),
|
164 |
]
|
165 |
|
166 |
-
def bad_line(current_sample, dataset, reason, annotator):
|
167 |
-
send_report(current_sample, dataset, reason, annotator)
|
168 |
next_line = next(line_generators[dataset])
|
169 |
return [
|
170 |
"<pre>" + next_line["text"] + "</pre>",
|
@@ -187,7 +199,7 @@ if __name__ == "__main__":
|
|
187 |
)
|
188 |
bad_btn.click(
|
189 |
bad_line,
|
190 |
-
inputs=[current_sample_state, dataset, reason_txt, annotator],
|
191 |
outputs=[text, reason_txt, current_sample_state],
|
192 |
)
|
193 |
|
|
|
76 |
line_generators = {dataset: line_generator(dataset) for dataset in datasets}
|
77 |
|
78 |
|
79 |
+
def send_report(sample, dataset, reason, annotator, campaign):
|
80 |
text = sample["text"]
|
81 |
sample.pop("text")
|
82 |
|
|
|
96 |
"metadata": sample,
|
97 |
"reason": reason,
|
98 |
"annotator": annotator,
|
99 |
+
"campaign": campaign,
|
100 |
"timestamp": str(datetime.now()),
|
101 |
}
|
102 |
)
|
|
|
109 |
"metadata": sample,
|
110 |
"reason": reason,
|
111 |
"annotator": annotator,
|
112 |
+
"campaign": campaign,
|
113 |
"timestamp": str(datetime.now()),
|
114 |
}
|
115 |
)
|
|
|
124 |
)
|
125 |
|
126 |
|
127 |
+
description = """
|
128 |
+
GecLM annotations. All annotations are recorded in the [data_feedback](https://huggingface.co/datasets/HuggingFaceGECLM/data_feedback) dataset.
|
129 |
+
"""
|
130 |
+
|
131 |
+
|
132 |
if __name__ == "__main__":
|
133 |
demo = gr.Blocks()
|
134 |
|
135 |
with demo:
|
136 |
current_sample_state = gr.State(dict())
|
137 |
|
138 |
+
description = gr.Markdown(value=description)
|
139 |
with gr.Row():
|
140 |
annotator = gr.Textbox(
|
141 |
lines=1,
|
142 |
max_lines=1,
|
143 |
+
placeholder="Optionally provide your name here if you'd like it to be recorded.",
|
144 |
label="Annotator",
|
145 |
)
|
146 |
+
campaign = gr.Textbox(
|
147 |
+
lines=1,
|
148 |
+
max_lines=1,
|
149 |
+
placeholder="Optionally provide the name of the annotation campagin for ease of filtering the reports.",
|
150 |
+
label="Annotation campaign",
|
151 |
+
)
|
152 |
with gr.Row():
|
153 |
dataset = gr.Dropdown(
|
154 |
+
choices=datasets, value="Pick a dataset below", label="Dataset",
|
|
|
|
|
155 |
)
|
156 |
with gr.Row():
|
157 |
reason_txt = gr.Textbox(
|
|
|
175 |
gr.update(visible=True),
|
176 |
]
|
177 |
|
178 |
+
def bad_line(current_sample, dataset, reason, annotator, campaign):
|
179 |
+
send_report(current_sample, dataset, reason, annotator, campaign)
|
180 |
next_line = next(line_generators[dataset])
|
181 |
return [
|
182 |
"<pre>" + next_line["text"] + "</pre>",
|
|
|
199 |
)
|
200 |
bad_btn.click(
|
201 |
bad_line,
|
202 |
+
inputs=[current_sample_state, dataset, reason_txt, annotator, campaign],
|
203 |
outputs=[text, reason_txt, current_sample_state],
|
204 |
)
|
205 |
|