Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -80,7 +80,10 @@ def run_and_submit_all(username):
|
|
80 |
return status, pd.DataFrame(results)
|
81 |
|
82 |
|
83 |
-
def test_random_question():
|
|
|
|
|
|
|
84 |
try:
|
85 |
q = requests.get(f"{DEFAULT_API_URL}/random-question", timeout=15).json()
|
86 |
ans = BasicAgent()(q.get('question', ''))
|
@@ -94,7 +97,7 @@ with gr.Blocks() as demo:
|
|
94 |
gr.Markdown(
|
95 |
"""
|
96 |
**Instructions:**
|
97 |
-
1. Enter your Hugging Face username.
|
98 |
2. Use **Test Random Question** to check a single question.
|
99 |
3. Use **Run Evaluation & Submit All Answers** to evaluate on all questions.
|
100 |
"""
|
@@ -109,9 +112,8 @@ with gr.Blocks() as demo:
|
|
109 |
question_out = gr.Textbox(label="Random Question", lines=3, interactive=False)
|
110 |
answer_out = gr.Textbox(label="Agent Answer", lines=3, interactive=False)
|
111 |
|
112 |
-
|
113 |
-
test_btn.click(fn=test_random_question, outputs=[question_out, answer_out])
|
114 |
-
test_btn.click(fn=test_random_question, inputs=[], outputs=[question_out, answer_out])
|
115 |
|
116 |
if __name__ == "__main__":
|
117 |
demo.launch(debug=True, share=False)
|
|
|
80 |
return status, pd.DataFrame(results)
|
81 |
|
82 |
|
83 |
+
def test_random_question(username):
|
84 |
+
# Use provided username for auth consistency
|
85 |
+
if not username:
|
86 |
+
return "Please enter your Hugging Face username.", ""
|
87 |
try:
|
88 |
q = requests.get(f"{DEFAULT_API_URL}/random-question", timeout=15).json()
|
89 |
ans = BasicAgent()(q.get('question', ''))
|
|
|
97 |
gr.Markdown(
|
98 |
"""
|
99 |
**Instructions:**
|
100 |
+
1. Enter your Hugging Face username in the box.
|
101 |
2. Use **Test Random Question** to check a single question.
|
102 |
3. Use **Run Evaluation & Submit All Answers** to evaluate on all questions.
|
103 |
"""
|
|
|
112 |
question_out = gr.Textbox(label="Random Question", lines=3, interactive=False)
|
113 |
answer_out = gr.Textbox(label="Agent Answer", lines=3, interactive=False)
|
114 |
|
115 |
+
run_btn.click(fn=run_and_submit_all, inputs=[username_input], outputs=[status_out, table_out])
|
116 |
+
test_btn.click(fn=test_random_question, inputs=[username_input], outputs=[question_out, answer_out])
|
|
|
117 |
|
118 |
if __name__ == "__main__":
|
119 |
demo.launch(debug=True, share=False)
|