Spaces:
Configuration error
Configuration error
Tristan Thrush
commited on
Commit
Β·
344dcb5
1
Parent(s):
9de6dce
fixed saving bug
Browse files- app.py +6 -7
- requirements.txt +0 -1
app.py
CHANGED
@@ -92,19 +92,18 @@ with demo:
|
|
92 |
state["data"].append({"cnt": state["cnt"], "text": txt, "response_1": response_1, "response_2": response_2})
|
93 |
state["past_user_inputs"].append(txt)
|
94 |
|
|
|
|
|
|
|
|
|
|
|
95 |
if state["cnt"] == TOTAL_CNT:
|
96 |
# Write the HIT data to our local dataset because the worker has
|
97 |
# submitted everything now.
|
98 |
with open(DATA_FILE, "a") as jsonlfile:
|
99 |
json_data_with_assignment_id =\
|
100 |
-
[json.dumps(dict({"assignmentId": state["assignmentId"]}, **datum)) for datum in state["data"]]
|
101 |
jsonlfile.write("\n".join(json_data_with_assignment_id) + "\n")
|
102 |
-
|
103 |
-
past_conversation_string = "<br />".join(["<br />".join(["π: " + user_input, "π€: " + model_response]) for user_input, model_response in zip(state["past_user_inputs"], state["generated_responses"] + [""])])
|
104 |
-
return gr.update(visible=False), gr.update(visible=True), gr.update(visible=True, choices=[response_1, response_2], interactive=True, value=response_1), gr.update(value=past_conversation_string), state, gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), new_state_md, dummy
|
105 |
-
|
106 |
-
def _select_response(selected_response, state, dummy):
|
107 |
-
done = state["cnt"] == TOTAL_CNT
|
108 |
toggle_example_submit = gr.update(visible=not done)
|
109 |
state["generated_responses"].append(selected_response)
|
110 |
state["data"][-1]["selected_response"] = selected_response
|
|
|
92 |
state["data"].append({"cnt": state["cnt"], "text": txt, "response_1": response_1, "response_2": response_2})
|
93 |
state["past_user_inputs"].append(txt)
|
94 |
|
95 |
+
past_conversation_string = "<br />".join(["<br />".join(["π: " + user_input, "π€: " + model_response]) for user_input, model_response in zip(state["past_user_inputs"], state["generated_responses"] + [""])])
|
96 |
+
return gr.update(visible=False), gr.update(visible=True), gr.update(visible=True, choices=[response_1, response_2], interactive=True, value=response_1), gr.update(value=past_conversation_string), state, gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), new_state_md, dummy
|
97 |
+
|
98 |
+
def _select_response(selected_response, state, dummy):
|
99 |
+
done = state["cnt"] == TOTAL_CNT
|
100 |
if state["cnt"] == TOTAL_CNT:
|
101 |
# Write the HIT data to our local dataset because the worker has
|
102 |
# submitted everything now.
|
103 |
with open(DATA_FILE, "a") as jsonlfile:
|
104 |
json_data_with_assignment_id =\
|
105 |
+
[json.dumps(dict({"assignmentId": state["assignmentId"]. "conversation_id": state["conversation_id"]}, **datum)) for datum in state["data"]]
|
106 |
jsonlfile.write("\n".join(json_data_with_assignment_id) + "\n")
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
toggle_example_submit = gr.update(visible=not done)
|
108 |
state["generated_responses"].append(selected_response)
|
109 |
state["data"][-1]["selected_response"] = selected_response
|
requirements.txt
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
torch==1.12.0
|
2 |
transformers==4.20.1
|
3 |
-
gradio==3.0.26
|
4 |
boto3==1.24.32
|
5 |
huggingface_hub==0.8.1
|
6 |
python-dotenv==0.20.0
|
|
|
1 |
torch==1.12.0
|
2 |
transformers==4.20.1
|
|
|
3 |
boto3==1.24.32
|
4 |
huggingface_hub==0.8.1
|
5 |
python-dotenv==0.20.0
|