Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,13 +13,12 @@ class BasicAgent:
|
|
| 13 |
print("BasicAgent initialized.")
|
| 14 |
|
| 15 |
def __call__(self, question: str) -> str:
|
| 16 |
-
|
| 17 |
-
return "This is a default answer." # TODO: Replace with real logic
|
| 18 |
|
| 19 |
# -------------------------
|
| 20 |
# Run & Submit Function
|
| 21 |
# -------------------------
|
| 22 |
-
def run_and_submit_all(profile
|
| 23 |
if not profile:
|
| 24 |
return "❌ Please login with your Hugging Face account.", None
|
| 25 |
|
|
@@ -88,15 +87,19 @@ with gr.Blocks() as demo:
|
|
| 88 |
"""
|
| 89 |
)
|
| 90 |
|
|
|
|
| 91 |
user_state = gr.State()
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
run_btn = gr.Button("🚀 Run Evaluation & Submit All Answers")
|
| 94 |
status_box = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
|
| 95 |
results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
|
| 96 |
|
| 97 |
-
# Run button
|
| 98 |
run_btn.click(run_and_submit_all, inputs=user_state, outputs=[status_box, results_table])
|
| 99 |
|
| 100 |
if __name__ == "__main__":
|
| 101 |
-
print("Launching GAIA Agent Evaluation App...")
|
| 102 |
demo.launch(debug=True, share=False)
|
|
|
|
| 13 |
print("BasicAgent initialized.")
|
| 14 |
|
| 15 |
def __call__(self, question: str) -> str:
|
| 16 |
+
return "This is a default answer."
|
|
|
|
| 17 |
|
| 18 |
# -------------------------
|
| 19 |
# Run & Submit Function
|
| 20 |
# -------------------------
|
| 21 |
+
def run_and_submit_all(profile):
|
| 22 |
if not profile:
|
| 23 |
return "❌ Please login with your Hugging Face account.", None
|
| 24 |
|
|
|
|
| 87 |
"""
|
| 88 |
)
|
| 89 |
|
| 90 |
+
# 使用 gr.State() 存使用者資訊
|
| 91 |
user_state = gr.State()
|
| 92 |
+
|
| 93 |
+
# Login button,沒有任何參數
|
| 94 |
+
login_btn = gr.LoginButton()
|
| 95 |
+
login_btn.click(lambda profile: profile, inputs=None, outputs=user_state)
|
| 96 |
+
|
| 97 |
run_btn = gr.Button("🚀 Run Evaluation & Submit All Answers")
|
| 98 |
status_box = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
|
| 99 |
results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
|
| 100 |
|
| 101 |
+
# Run button使用user_state當profile
|
| 102 |
run_btn.click(run_and_submit_all, inputs=user_state, outputs=[status_box, results_table])
|
| 103 |
|
| 104 |
if __name__ == "__main__":
|
|
|
|
| 105 |
demo.launch(debug=True, share=False)
|