Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -80,11 +80,10 @@ def generateSentences(gr1, gr2, att1, att2, openai_key, num_sent2gen, progress=g
|
|
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)
|
87 |
-
#raise gr.Error(NO_TERMS_ENTERED_ERROR)
|
88 |
else:
|
89 |
if len(openai_key) == 0:
|
90 |
print("Empty OpenAI key!!!")
|
@@ -93,7 +92,6 @@ def generateSentences(gr1, gr2, att1, att2, openai_key, num_sent2gen, progress=g
|
|
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 |
|
@@ -413,7 +411,6 @@ css_adds = "#group_row {background: white; border-color: white;} \
|
|
413 |
#'bethecloud/storj_theme'
|
414 |
with gr.Blocks(theme=soft, title="Social Bias Testing in Language Models",
|
415 |
css=css_adds) as iface:
|
416 |
-
curr_openai_key = gr.State("")
|
417 |
with gr.Row():
|
418 |
with gr.Group():
|
419 |
s1_btn = gr.Button(value="Step 1: Bias Specification", variant="primary", visible=True, interactive=True).style(size='sm')
|
@@ -477,10 +474,7 @@ with gr.Blocks(theme=soft, title="Social Bias Testing in Language Models",
|
|
477 |
# elem_id="gen_model_check")
|
478 |
with gr.Row(visible=False) as online_gen_row:
|
479 |
# OpenAI Key for generator
|
480 |
-
|
481 |
-
if((curr_openai_key != "") and (curr_openai_key != "state")):
|
482 |
-
value = curr_openai_key
|
483 |
-
openai_key = gr.Textbox(value=value, lines=1, label="OpenAI API Key",
|
484 |
placeholder="starts with sk-",
|
485 |
info="Please provide the key for an Open AI account to generate new test sentences",
|
486 |
visible=True,
|
@@ -579,16 +573,6 @@ with gr.Blocks(theme=soft, title="Social Bias Testing in Language Models",
|
|
579 |
inputs=[group1, group2, att1, att2, openai_key, num_sentences2gen],
|
580 |
outputs=[err_message, info_sentences_found, online_gen_row, #num_sentences2gen,
|
581 |
tested_model_name, acc_test_sentences, row_sentences, test_sentences, gen_btn, bias_btn ])
|
582 |
-
|
583 |
-
|
584 |
-
def updateKey(openai_key, curr_openai_key):
|
585 |
-
if(len(openai_key) < 10):
|
586 |
-
return { curr_openai_key: "" }
|
587 |
-
return {curr_openai_key : openai_key}
|
588 |
-
|
589 |
-
gen_btn.click(fn=updateKey,
|
590 |
-
inputs=[openai_key, curr_openai_key],
|
591 |
-
outputs=[curr_openai_key])
|
592 |
|
593 |
# Test bias
|
594 |
bias_btn.click(fn=startBiasTest,
|
|
|
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)
|
86 |
+
#raise gr.Error(NO_TERMS_ENTERED_ERROR)
|
87 |
else:
|
88 |
if len(openai_key) == 0:
|
89 |
print("Empty OpenAI key!!!")
|
|
|
92 |
print("Wrong length OpenAI key!!!")
|
93 |
err_update = updateErrorMsg(True, OPENAI_KEY_WRONG)
|
94 |
else:
|
|
|
95 |
progress(0, desc="ChatGPT generation...")
|
96 |
print(f"Using Online Generator LLM...")
|
97 |
|
|
|
411 |
#'bethecloud/storj_theme'
|
412 |
with gr.Blocks(theme=soft, title="Social Bias Testing in Language Models",
|
413 |
css=css_adds) as iface:
|
|
|
414 |
with gr.Row():
|
415 |
with gr.Group():
|
416 |
s1_btn = gr.Button(value="Step 1: Bias Specification", variant="primary", visible=True, interactive=True).style(size='sm')
|
|
|
474 |
# elem_id="gen_model_check")
|
475 |
with gr.Row(visible=False) as online_gen_row:
|
476 |
# OpenAI Key for generator
|
477 |
+
openai_key = gr.Textbox(lines=1, label="OpenAI API Key",
|
|
|
|
|
|
|
478 |
placeholder="starts with sk-",
|
479 |
info="Please provide the key for an Open AI account to generate new test sentences",
|
480 |
visible=True,
|
|
|
573 |
inputs=[group1, group2, att1, att2, openai_key, num_sentences2gen],
|
574 |
outputs=[err_message, info_sentences_found, online_gen_row, #num_sentences2gen,
|
575 |
tested_model_name, acc_test_sentences, row_sentences, test_sentences, gen_btn, bias_btn ])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
576 |
|
577 |
# Test bias
|
578 |
bias_btn.click(fn=startBiasTest,
|