Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -24,7 +24,6 @@ def get_user_id_from_url():
|
|
24 |
user_id = st.query_params.get("user_id", "")
|
25 |
return user_id
|
26 |
|
27 |
-
|
28 |
HF_TOKEN = os.environ.get("HF_TOKEN_WRITE")
|
29 |
print("is none?", HF_TOKEN is None)
|
30 |
hf_fs = HfFileSystem(token=HF_TOKEN)
|
@@ -38,6 +37,10 @@ quality_labels = ['very poor', 'poor', 'acceptable', 'good', 'very good']
|
|
38 |
priority_labels = ['not a priority', 'low priority', 'neutral', 'moderate priority', 'high priority']
|
39 |
default_labels = agreement_labels
|
40 |
|
|
|
|
|
|
|
|
|
41 |
fields: List[Field] = [
|
42 |
Field(name="topic", type="input_col", title="**Topic:**"),
|
43 |
Field(name="parent_comment", type="input_col", title="**Preceeding Comment:**"),
|
@@ -50,6 +53,13 @@ fields: List[Field] = [
|
|
50 |
Field(name="actions_clear", type="select_slider",
|
51 |
title="**Priority**: With what level of priority would you need to interact with this comment?", other_params={'labels': priority_labels}),
|
52 |
]),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
#Field(type="expander",
|
54 |
# title="Expand and fill-out this section if you see **issues in the original comment**",
|
55 |
# children=[
|
@@ -76,14 +86,15 @@ fields: List[Field] = [
|
|
76 |
# help="Welcoming, encouraging and acknowledging. Avoid Evaluative and/or Condescending Responses"),
|
77 |
#]),
|
78 |
#
|
79 |
-
Field(name="other_comments", type="text", title="Further comments: free text"),
|
80 |
]
|
81 |
INPUT_FIELD_DEFAULT_VALUES = {'slider': 0,
|
82 |
'text': None,
|
83 |
'textarea': None,
|
84 |
'checkbox': False,
|
85 |
-
'radio':
|
86 |
-
'select_slider': 0
|
|
|
87 |
SHOW_HELP_ICON = False
|
88 |
|
89 |
def read_data(_path):
|
@@ -165,11 +176,10 @@ def show_field(f: Field, index: int):
|
|
165 |
st.session_state.data_inputs[f.name] = st.radio(f.title,
|
166 |
["yes","no","other"],
|
167 |
key=key,
|
168 |
-
#value=value,
|
169 |
help=f.help)
|
170 |
case 'slider':
|
171 |
st.session_state.data_inputs[f.name] = st.slider(f.title,
|
172 |
-
min_value=
|
173 |
key=key,
|
174 |
value=value, help=f.help)
|
175 |
case 'select_slider':
|
@@ -179,6 +189,12 @@ def show_field(f: Field, index: int):
|
|
179 |
format_func=lambda x: labels[x // 25],
|
180 |
key=key,
|
181 |
value=value, help=f.help)
|
|
|
|
|
|
|
|
|
|
|
|
|
182 |
case 'text':
|
183 |
st.session_state.data_inputs[f.name] = st.text_input(f.title, key=key, value=value)
|
184 |
case 'textarea':
|
|
|
24 |
user_id = st.query_params.get("user_id", "")
|
25 |
return user_id
|
26 |
|
|
|
27 |
HF_TOKEN = os.environ.get("HF_TOKEN_WRITE")
|
28 |
print("is none?", HF_TOKEN is None)
|
29 |
hf_fs = HfFileSystem(token=HF_TOKEN)
|
|
|
37 |
priority_labels = ['not a priority', 'low priority', 'neutral', 'moderate priority', 'high priority']
|
38 |
default_labels = agreement_labels
|
39 |
|
40 |
+
function_choices = ['Broadening Discussion', 'Improving Comment Quality', 'Content Correction', 'Keeping Discussion on Topic', 'Organizing Discussion', 'Policing', 'Resolving Site Use Issues', 'Social Functions', 'Other (please specify)']
|
41 |
+
default_choices = function_choices
|
42 |
+
|
43 |
+
|
44 |
fields: List[Field] = [
|
45 |
Field(name="topic", type="input_col", title="**Topic:**"),
|
46 |
Field(name="parent_comment", type="input_col", title="**Preceeding Comment:**"),
|
|
|
53 |
Field(name="actions_clear", type="select_slider",
|
54 |
title="**Priority**: With what level of priority would you need to interact with this comment?", other_params={'labels': priority_labels}),
|
55 |
]),
|
56 |
+
|
57 |
+
Field(type="container", title="**Moderation Function**", children=[
|
58 |
+
Field(name="mod_function", type="multiselect",
|
59 |
+
title="**What type of moderation function is needed here?** (Multiple selection possible)")
|
60 |
+
])
|
61 |
+
|
62 |
+
|
63 |
#Field(type="expander",
|
64 |
# title="Expand and fill-out this section if you see **issues in the original comment**",
|
65 |
# children=[
|
|
|
86 |
# help="Welcoming, encouraging and acknowledging. Avoid Evaluative and/or Condescending Responses"),
|
87 |
#]),
|
88 |
#
|
89 |
+
Field(name="other_comments", type="text", title="Further comments: (free text)"),
|
90 |
]
|
91 |
INPUT_FIELD_DEFAULT_VALUES = {'slider': 0,
|
92 |
'text': None,
|
93 |
'textarea': None,
|
94 |
'checkbox': False,
|
95 |
+
'radio': False,
|
96 |
+
'select_slider': 0,
|
97 |
+
'multiselect': None}
|
98 |
SHOW_HELP_ICON = False
|
99 |
|
100 |
def read_data(_path):
|
|
|
176 |
st.session_state.data_inputs[f.name] = st.radio(f.title,
|
177 |
["yes","no","other"],
|
178 |
key=key,
|
|
|
179 |
help=f.help)
|
180 |
case 'slider':
|
181 |
st.session_state.data_inputs[f.name] = st.slider(f.title,
|
182 |
+
min_value=0, max_value=6, step=1,
|
183 |
key=key,
|
184 |
value=value, help=f.help)
|
185 |
case 'select_slider':
|
|
|
189 |
format_func=lambda x: labels[x // 25],
|
190 |
key=key,
|
191 |
value=value, help=f.help)
|
192 |
+
case 'multiselect':
|
193 |
+
choices = default_choices if not f.other_params.get('choices') else f.other_params.get('choices')
|
194 |
+
st.session_state.data_inputs[f.name] = st.multiselect(f.title,
|
195 |
+
options = choices,
|
196 |
+
key=key,
|
197 |
+
help=f.help)
|
198 |
case 'text':
|
199 |
st.session_state.data_inputs[f.name] = st.text_input(f.title, key=key, value=value)
|
200 |
case 'textarea':
|