Spaces:
Running on T4
Running on T4
Update app.py
Browse files
app.py
CHANGED
|
@@ -50,9 +50,7 @@ CHAR_MAX = 600
|
|
| 50 |
SUBMISSIONS_PER_TASK = 5
|
| 51 |
|
| 52 |
# Column list for the history table
|
| 53 |
-
|
| 54 |
-
HIST_COLUMNS = ["Submission", "Response Preview",
|
| 55 |
-
"mpnet", "noinstruct", "gist", "Distinctiveness Score"]
|
| 56 |
|
| 57 |
OPENAI_MODEL = os.getenv("OPENAI_MODEL", "gpt-4o-mini")
|
| 58 |
EMB_MODELS = [
|
|
@@ -680,7 +678,7 @@ with gr.Blocks(theme=gr.themes.Soft(), analytics_enabled=False) as demo:
|
|
| 680 |
history_df = gr.Dataframe(
|
| 681 |
label="Submission History",
|
| 682 |
headers=HIST_COLUMNS,
|
| 683 |
-
datatype=["number", "str", "number"
|
| 684 |
interactive=False,
|
| 685 |
wrap=True,
|
| 686 |
)
|
|
@@ -752,7 +750,7 @@ with gr.Blocks(theme=gr.themes.Soft(), analytics_enabled=False) as demo:
|
|
| 752 |
cur_hist = pd.DataFrame(history) if history else empty_hist
|
| 753 |
return (cur_hist, "⚠️ Enter Prolific ID and click Start Study first.",
|
| 754 |
responses, submission, pidx, prompt_key, history, False,
|
| 755 |
-
|
| 756 |
gr.update(visible=True), gr.update(visible=False),
|
| 757 |
gr.update(), gr.update())
|
| 758 |
|
|
@@ -762,7 +760,7 @@ with gr.Blocks(theme=gr.themes.Soft(), analytics_enabled=False) as demo:
|
|
| 762 |
return (cur_hist,
|
| 763 |
"✅ Task complete! Click **Continue to Next Task** to proceed.",
|
| 764 |
responses, submission, pidx, prompt_key, history, True,
|
| 765 |
-
|
| 766 |
gr.update(visible=False), gr.update(visible=True),
|
| 767 |
gr.update(), gr.update())
|
| 768 |
|
|
@@ -770,7 +768,7 @@ with gr.Blocks(theme=gr.themes.Soft(), analytics_enabled=False) as demo:
|
|
| 770 |
cur_hist = pd.DataFrame(history) if history else empty_hist
|
| 771 |
return (cur_hist, char_count_status(text),
|
| 772 |
responses, submission, pidx, prompt_key, history, False,
|
| 773 |
-
|
| 774 |
gr.update(visible=True), gr.update(visible=False),
|
| 775 |
gr.update(), gr.update())
|
| 776 |
|
|
@@ -781,7 +779,7 @@ with gr.Blocks(theme=gr.themes.Soft(), analytics_enabled=False) as demo:
|
|
| 781 |
return (cur_hist,
|
| 782 |
f"⚠️ Too short: {n} characters. Please write at least {CHAR_MIN}.",
|
| 783 |
responses, submission, pidx, prompt_key, history, False,
|
| 784 |
-
|
| 785 |
gr.update(visible=True), gr.update(visible=False),
|
| 786 |
gr.update(), gr.update())
|
| 787 |
if n > CHAR_MAX:
|
|
@@ -789,7 +787,7 @@ with gr.Blocks(theme=gr.themes.Soft(), analytics_enabled=False) as demo:
|
|
| 789 |
return (cur_hist,
|
| 790 |
f"⚠️ Too long: {n} characters. Please keep to {CHAR_MAX} or fewer.",
|
| 791 |
responses, submission, pidx, prompt_key, history, False,
|
| 792 |
-
|
| 793 |
gr.update(visible=True), gr.update(visible=False),
|
| 794 |
gr.update(), gr.update())
|
| 795 |
|
|
@@ -802,8 +800,7 @@ with gr.Blocks(theme=gr.themes.Soft(), analytics_enabled=False) as demo:
|
|
| 802 |
# History row
|
| 803 |
preview = text[:80] + "…" if len(text) > 80 else text
|
| 804 |
row = {"Submission": submission, "Response Preview": preview,
|
| 805 |
-
"
|
| 806 |
-
"gist": scores["gist"], "Distinctiveness Score": sc}
|
| 807 |
new_history = history + [row]
|
| 808 |
new_responses = responses + [{"task_key": prompt_key, "submission": submission,
|
| 809 |
"response_text": text, "score": sc}]
|
|
@@ -851,7 +848,7 @@ with gr.Blocks(theme=gr.themes.Soft(), analytics_enabled=False) as demo:
|
|
| 851 |
return (hist_df, status_msg,
|
| 852 |
new_responses, new_submission, pidx, prompt_key,
|
| 853 |
new_history, False,
|
| 854 |
-
bar,
|
| 855 |
gr.update(visible=True), gr.update(visible=False),
|
| 856 |
"", "")
|
| 857 |
|
|
|
|
| 50 |
SUBMISSIONS_PER_TASK = 5
|
| 51 |
|
| 52 |
# Column list for the history table
|
| 53 |
+
HIST_COLUMNS = ["Submission", "Response Preview", "Distinctiveness Score"]
|
|
|
|
|
|
|
| 54 |
|
| 55 |
OPENAI_MODEL = os.getenv("OPENAI_MODEL", "gpt-4o-mini")
|
| 56 |
EMB_MODELS = [
|
|
|
|
| 678 |
history_df = gr.Dataframe(
|
| 679 |
label="Submission History",
|
| 680 |
headers=HIST_COLUMNS,
|
| 681 |
+
datatype=["number", "str", "number"],
|
| 682 |
interactive=False,
|
| 683 |
wrap=True,
|
| 684 |
)
|
|
|
|
| 750 |
cur_hist = pd.DataFrame(history) if history else empty_hist
|
| 751 |
return (cur_hist, "⚠️ Enter Prolific ID and click Start Study first.",
|
| 752 |
responses, submission, pidx, prompt_key, history, False,
|
| 753 |
+
gr.update(), gr.update(), gr.update(), gr.update(),
|
| 754 |
gr.update(visible=True), gr.update(visible=False),
|
| 755 |
gr.update(), gr.update())
|
| 756 |
|
|
|
|
| 760 |
return (cur_hist,
|
| 761 |
"✅ Task complete! Click **Continue to Next Task** to proceed.",
|
| 762 |
responses, submission, pidx, prompt_key, history, True,
|
| 763 |
+
gr.update(), gr.update(), gr.update(), gr.update(),
|
| 764 |
gr.update(visible=False), gr.update(visible=True),
|
| 765 |
gr.update(), gr.update())
|
| 766 |
|
|
|
|
| 768 |
cur_hist = pd.DataFrame(history) if history else empty_hist
|
| 769 |
return (cur_hist, char_count_status(text),
|
| 770 |
responses, submission, pidx, prompt_key, history, False,
|
| 771 |
+
gr.update(), gr.update(), gr.update(), gr.update(),
|
| 772 |
gr.update(visible=True), gr.update(visible=False),
|
| 773 |
gr.update(), gr.update())
|
| 774 |
|
|
|
|
| 779 |
return (cur_hist,
|
| 780 |
f"⚠️ Too short: {n} characters. Please write at least {CHAR_MIN}.",
|
| 781 |
responses, submission, pidx, prompt_key, history, False,
|
| 782 |
+
gr.update(), gr.update(), gr.update(), gr.update(),
|
| 783 |
gr.update(visible=True), gr.update(visible=False),
|
| 784 |
gr.update(), gr.update())
|
| 785 |
if n > CHAR_MAX:
|
|
|
|
| 787 |
return (cur_hist,
|
| 788 |
f"⚠️ Too long: {n} characters. Please keep to {CHAR_MAX} or fewer.",
|
| 789 |
responses, submission, pidx, prompt_key, history, False,
|
| 790 |
+
gr.update(), gr.update(), gr.update(), gr.update(),
|
| 791 |
gr.update(visible=True), gr.update(visible=False),
|
| 792 |
gr.update(), gr.update())
|
| 793 |
|
|
|
|
| 800 |
# History row
|
| 801 |
preview = text[:80] + "…" if len(text) > 80 else text
|
| 802 |
row = {"Submission": submission, "Response Preview": preview,
|
| 803 |
+
"Distinctiveness Score": sc}
|
|
|
|
| 804 |
new_history = history + [row]
|
| 805 |
new_responses = responses + [{"task_key": prompt_key, "submission": submission,
|
| 806 |
"response_text": text, "score": sc}]
|
|
|
|
| 848 |
return (hist_df, status_msg,
|
| 849 |
new_responses, new_submission, pidx, prompt_key,
|
| 850 |
new_history, False,
|
| 851 |
+
bar, gr.update(), visual_html, "",
|
| 852 |
gr.update(visible=True), gr.update(visible=False),
|
| 853 |
"", "")
|
| 854 |
|