Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -15,7 +15,7 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
15 |
# ON A SUPPRIMÉ L'ANCIENNE CLASSE BasicAgent D'ICI.
|
16 |
# C'EST MAINTENANT GÉRÉ PAR L'IMPORT CI-DESSUS.
|
17 |
|
18 |
-
def run_and_submit_all(
|
19 |
"""
|
20 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|
21 |
and displays the results.
|
@@ -138,7 +138,7 @@ with gr.Blocks() as demo:
|
|
138 |
"""
|
139 |
)
|
140 |
|
141 |
-
#
|
142 |
login_button = gr.LoginButton()
|
143 |
|
144 |
run_button = gr.Button("Run Evaluation & Submit All Answers")
|
@@ -146,10 +146,17 @@ with gr.Blocks() as demo:
|
|
146 |
status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
|
147 |
results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
|
148 |
|
149 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
run_button.click(
|
151 |
fn=run_and_submit_all,
|
152 |
-
inputs=
|
153 |
outputs=[status_output, results_table]
|
154 |
)
|
155 |
|
|
|
15 |
# ON A SUPPRIMÉ L'ANCIENNE CLASSE BasicAgent D'ICI.
|
16 |
# C'EST MAINTENANT GÉRÉ PAR L'IMPORT CI-DESSUS.
|
17 |
|
18 |
+
def run_and_submit_all(profile: gr.OAuthProfile | None):
|
19 |
"""
|
20 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|
21 |
and displays the results.
|
|
|
138 |
"""
|
139 |
)
|
140 |
|
141 |
+
# Create the login button
|
142 |
login_button = gr.LoginButton()
|
143 |
|
144 |
run_button = gr.Button("Run Evaluation & Submit All Answers")
|
|
|
146 |
status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
|
147 |
results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
|
148 |
|
149 |
+
# Create a state to store the profile
|
150 |
+
profile_state = gr.State()
|
151 |
+
|
152 |
+
# Update the profile state when login status changes
|
153 |
+
login_button.login(lambda profile: profile, outputs=profile_state)
|
154 |
+
login_button.logout(lambda: None, outputs=profile_state)
|
155 |
+
|
156 |
+
# Use the profile state as input
|
157 |
run_button.click(
|
158 |
fn=run_and_submit_all,
|
159 |
+
inputs=profile_state,
|
160 |
outputs=[status_output, results_table]
|
161 |
)
|
162 |
|