Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -66,7 +66,7 @@ class HybridAgent65:
|
|
| 66 |
def run_and_submit_all(profile):
|
| 67 |
if profile is None:
|
| 68 |
return "❌ Please login with your Hugging Face account.", None
|
| 69 |
-
username = profile.username
|
| 70 |
space_id = os.getenv("SPACE_ID", "unknown")
|
| 71 |
agent_code = f"https://huggingface.co/spaces/{space_id}/tree/main"
|
| 72 |
|
|
@@ -111,34 +111,26 @@ def run_and_submit_all(profile):
|
|
| 111 |
return f"❌ Submission failed: {e}", pd.DataFrame(results_log)
|
| 112 |
|
| 113 |
# ===========================
|
| 114 |
-
# Gradio Interface (
|
| 115 |
# ===========================
|
| 116 |
with gr.Blocks() as demo:
|
| 117 |
gr.Markdown("# 🎯 Hybrid GAIA Agent (65% Version)")
|
| 118 |
gr.Markdown(
|
| 119 |
"""
|
| 120 |
**Instructions:**
|
| 121 |
-
1. Log in to your Hugging Face account.
|
| 122 |
2. Click 'Run Evaluation & Submit All Answers'.
|
| 123 |
-
3. View your results below.
|
| 124 |
"""
|
| 125 |
)
|
| 126 |
|
| 127 |
-
|
| 128 |
-
login_btn = gr.LoginButton() # 直接產生 HF OAuth
|
| 129 |
-
# 將 profile 放到狀態容器
|
| 130 |
-
user_state = gr.State()
|
| 131 |
-
|
| 132 |
-
# Run 按鈕
|
| 133 |
run_button = gr.Button("🚀 Run Evaluation & Submit All Answers")
|
| 134 |
status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
|
| 135 |
results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
|
| 136 |
-
|
| 137 |
-
#
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
# Run 按鈕點擊
|
| 141 |
-
run_button.click(fn=run_and_submit_all, inputs=[user_state], outputs=[status_output, results_table])
|
| 142 |
|
| 143 |
if __name__ == "__main__":
|
| 144 |
demo.launch(debug=True, share=False)
|
|
|
|
| 66 |
def run_and_submit_all(profile):
|
| 67 |
if profile is None:
|
| 68 |
return "❌ Please login with your Hugging Face account.", None
|
| 69 |
+
username = profile["username"] if isinstance(profile, dict) else profile.username
|
| 70 |
space_id = os.getenv("SPACE_ID", "unknown")
|
| 71 |
agent_code = f"https://huggingface.co/spaces/{space_id}/tree/main"
|
| 72 |
|
|
|
|
| 111 |
return f"❌ Submission failed: {e}", pd.DataFrame(results_log)
|
| 112 |
|
| 113 |
# ===========================
|
| 114 |
+
# Gradio Interface (compatible with latest HF login)
|
| 115 |
# ===========================
|
| 116 |
with gr.Blocks() as demo:
|
| 117 |
gr.Markdown("# 🎯 Hybrid GAIA Agent (65% Version)")
|
| 118 |
gr.Markdown(
|
| 119 |
"""
|
| 120 |
**Instructions:**
|
| 121 |
+
1. Log in to your Hugging Face account below.
|
| 122 |
2. Click 'Run Evaluation & Submit All Answers'.
|
| 123 |
+
3. View your results in the table below.
|
| 124 |
"""
|
| 125 |
)
|
| 126 |
|
| 127 |
+
login_btn = gr.LoginButton()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
run_button = gr.Button("🚀 Run Evaluation & Submit All Answers")
|
| 129 |
status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
|
| 130 |
results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
|
| 131 |
+
|
| 132 |
+
# HF login returns profile dict,直接作為 run 函數輸入
|
| 133 |
+
run_button.click(fn=run_and_submit_all, inputs=[login_btn], outputs=[status_output, results_table])
|
|
|
|
|
|
|
|
|
|
| 134 |
|
| 135 |
if __name__ == "__main__":
|
| 136 |
demo.launch(debug=True, share=False)
|