Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -64,7 +64,7 @@ def prefillBiasSpec(evt: gr.SelectData):
|
|
64 |
def updateErrorMsg(isError, text):
|
65 |
return gr.Markdown.update(visible=isError, value=text)
|
66 |
|
67 |
-
def generateSentences(gr1, gr2, att1, att2, openai_key, num_sent2gen,
|
68 |
global use_paper_sentences, G_NUM_SENTENCES
|
69 |
print(f"GENERATE SENTENCES CLICKED!, requested sentence number: {num_sent2gen}")
|
70 |
|
@@ -80,6 +80,7 @@ def generateSentences(gr1, gr2, att1, att2, openai_key, num_sent2gen, openai_sta
|
|
80 |
total_att_terms = len(a1)+len(a2)
|
81 |
all_terms_len = len(g1)+len(g2)+len(a1)+len(a2)
|
82 |
print(f"Length of all the terms: {all_terms_len}")
|
|
|
83 |
if all_terms_len == 0:
|
84 |
print("No terms entered!")
|
85 |
err_update = updateErrorMsg(True, NO_TERMS_ENTERED_ERROR)
|
@@ -92,7 +93,7 @@ def generateSentences(gr1, gr2, att1, att2, openai_key, num_sent2gen, openai_sta
|
|
92 |
print("Wrong length OpenAI key!!!")
|
93 |
err_update = updateErrorMsg(True, OPENAI_KEY_WRONG)
|
94 |
else:
|
95 |
-
|
96 |
progress(0, desc="ChatGPT generation...")
|
97 |
print(f"Using Online Generator LLM...")
|
98 |
|
@@ -576,6 +577,16 @@ with gr.Blocks(theme=soft, title="Social Bias Testing in Language Models",
|
|
576 |
inputs=[group1, group2, att1, att2, openai_key, num_sentences2gen, curr_openai_key],
|
577 |
outputs=[err_message, info_sentences_found, online_gen_row, #num_sentences2gen,
|
578 |
tested_model_name, acc_test_sentences, row_sentences, test_sentences, gen_btn, bias_btn ])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
579 |
|
580 |
# Test bias
|
581 |
bias_btn.click(fn=startBiasTest,
|
|
|
64 |
def updateErrorMsg(isError, text):
|
65 |
return gr.Markdown.update(visible=isError, value=text)
|
66 |
|
67 |
+
def generateSentences(gr1, gr2, att1, att2, openai_key, num_sent2gen, progress=gr.Progress()):
|
68 |
global use_paper_sentences, G_NUM_SENTENCES
|
69 |
print(f"GENERATE SENTENCES CLICKED!, requested sentence number: {num_sent2gen}")
|
70 |
|
|
|
80 |
total_att_terms = len(a1)+len(a2)
|
81 |
all_terms_len = len(g1)+len(g2)+len(a1)+len(a2)
|
82 |
print(f"Length of all the terms: {all_terms_len}")
|
83 |
+
new_openai_key = ""
|
84 |
if all_terms_len == 0:
|
85 |
print("No terms entered!")
|
86 |
err_update = updateErrorMsg(True, NO_TERMS_ENTERED_ERROR)
|
|
|
93 |
print("Wrong length OpenAI key!!!")
|
94 |
err_update = updateErrorMsg(True, OPENAI_KEY_WRONG)
|
95 |
else:
|
96 |
+
|
97 |
progress(0, desc="ChatGPT generation...")
|
98 |
print(f"Using Online Generator LLM...")
|
99 |
|
|
|
577 |
inputs=[group1, group2, att1, att2, openai_key, num_sentences2gen, curr_openai_key],
|
578 |
outputs=[err_message, info_sentences_found, online_gen_row, #num_sentences2gen,
|
579 |
tested_model_name, acc_test_sentences, row_sentences, test_sentences, gen_btn, bias_btn ])
|
580 |
+
|
581 |
+
|
582 |
+
def updateKey(openai_key, curr_openai_key):
|
583 |
+
if(len(openai_key) < 10):
|
584 |
+
return { curr_openai_key: "" }
|
585 |
+
return {curr_openai_key : openai_key}
|
586 |
+
|
587 |
+
gen_btn.click(fn=updateKey,
|
588 |
+
inputs=[openai_key, curr_openai_key],
|
589 |
+
outputs=[curr_openai_key])
|
590 |
|
591 |
# Test bias
|
592 |
bias_btn.click(fn=startBiasTest,
|