Commit
·
16f921a
1
Parent(s):
7ccbe37
update css to show dropdown options
Browse files- app/app.py +14 -12
app/app.py
CHANGED
@@ -223,8 +223,10 @@ def wrangle_edit_data(
|
|
223 |
|
224 |
if history[index]["role"] == "user":
|
225 |
# Add feedback on original and corrected message
|
226 |
-
add_fake_like_data(history[: index + 2], session_id, liked=True)
|
227 |
-
add_fake_like_data(
|
|
|
|
|
228 |
history = respond_system_message(
|
229 |
history[: index + 1],
|
230 |
temperature=random.randint(1, 100) / 100,
|
@@ -233,8 +235,8 @@ def wrangle_edit_data(
|
|
233 |
return history
|
234 |
else:
|
235 |
# Add feedback on original and corrected message
|
236 |
-
add_fake_like_data(history[: index + 1], session_id, liked=True)
|
237 |
-
add_fake_like_data(history[:index] + [original_message], session_id)
|
238 |
history = history[: index + 1]
|
239 |
# add chosen and rejected options
|
240 |
history[-1]["options"] = [
|
@@ -263,15 +265,15 @@ def wrangle_retry_data(
|
|
263 |
|
264 |
def submit_conversation(dataframe, session_id, language):
|
265 |
""" "Submit the conversation to dataset repo"""
|
266 |
-
if "role" in dataframe.columns:
|
267 |
-
dataframe = dataframe[dataframe["role"] != "system"]
|
268 |
if dataframe.empty or len(dataframe) < 2:
|
269 |
gr.Info("No feedback to submit.")
|
270 |
return (gr.Dataframe(value=None, interactive=False), [])
|
271 |
|
272 |
dataframe["content"] = dataframe["content"].apply(_process_content)
|
|
|
|
|
273 |
conversation_data = {
|
274 |
-
"conversation":
|
275 |
"timestamp": datetime.now().isoformat(),
|
276 |
"session_id": session_id,
|
277 |
"conversation_id": str(uuid.uuid4()),
|
@@ -283,12 +285,14 @@ def submit_conversation(dataframe, session_id, language):
|
|
283 |
|
284 |
|
285 |
css = """
|
286 |
-
.options {
|
|
|
|
|
|
|
287 |
display: none !important;
|
288 |
}
|
289 |
"""
|
290 |
|
291 |
-
|
292 |
with gr.Blocks(css=css) as demo:
|
293 |
##############################
|
294 |
# Chatbot
|
@@ -299,9 +303,7 @@ with gr.Blocks(css=css) as demo:
|
|
299 |
visible=False,
|
300 |
)
|
301 |
|
302 |
-
language = gr.Dropdown(
|
303 |
-
label="Language", choices=LANGUAGES, value=LANGUAGES[0], interactive=True
|
304 |
-
)
|
305 |
|
306 |
chatbot = gr.Chatbot(
|
307 |
elem_id="chatbot",
|
|
|
223 |
|
224 |
if history[index]["role"] == "user":
|
225 |
# Add feedback on original and corrected message
|
226 |
+
add_fake_like_data(history[: index + 2], session_id, language, liked=True)
|
227 |
+
add_fake_like_data(
|
228 |
+
history[: index + 1] + [original_message], session_id, language
|
229 |
+
)
|
230 |
history = respond_system_message(
|
231 |
history[: index + 1],
|
232 |
temperature=random.randint(1, 100) / 100,
|
|
|
235 |
return history
|
236 |
else:
|
237 |
# Add feedback on original and corrected message
|
238 |
+
add_fake_like_data(history[: index + 1], session_id, language, liked=True)
|
239 |
+
add_fake_like_data(history[:index] + [original_message], session_id, language)
|
240 |
history = history[: index + 1]
|
241 |
# add chosen and rejected options
|
242 |
history[-1]["options"] = [
|
|
|
265 |
|
266 |
def submit_conversation(dataframe, session_id, language):
|
267 |
""" "Submit the conversation to dataset repo"""
|
|
|
|
|
268 |
if dataframe.empty or len(dataframe) < 2:
|
269 |
gr.Info("No feedback to submit.")
|
270 |
return (gr.Dataframe(value=None, interactive=False), [])
|
271 |
|
272 |
dataframe["content"] = dataframe["content"].apply(_process_content)
|
273 |
+
conversation = dataframe.to_dict(orient="records")
|
274 |
+
conversation = conversation[1:] # remove system message
|
275 |
conversation_data = {
|
276 |
+
"conversation": conversation,
|
277 |
"timestamp": datetime.now().isoformat(),
|
278 |
"session_id": session_id,
|
279 |
"conversation_id": str(uuid.uuid4()),
|
|
|
285 |
|
286 |
|
287 |
css = """
|
288 |
+
.options.svelte-pcaovb {
|
289 |
+
display: none !important;
|
290 |
+
}
|
291 |
+
.option.svelte-pcaovb {
|
292 |
display: none !important;
|
293 |
}
|
294 |
"""
|
295 |
|
|
|
296 |
with gr.Blocks(css=css) as demo:
|
297 |
##############################
|
298 |
# Chatbot
|
|
|
303 |
visible=False,
|
304 |
)
|
305 |
|
306 |
+
language = gr.Dropdown(choices=LANGUAGES, label="Language", interactive=True)
|
|
|
|
|
307 |
|
308 |
chatbot = gr.Chatbot(
|
309 |
elem_id="chatbot",
|