s1123725 commited on
Commit
c2e410c
·
verified ·
1 Parent(s): bd0a28e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -16
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 (new 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.
122
  2. Click 'Run Evaluation & Submit All Answers'.
123
- 3. View your results below.
124
  """
125
  )
126
 
127
- # Login 按鈕
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
- # 當登入成功時,將 profile 放入 State
138
- login_btn.change(lambda profile: profile, inputs=[login_btn], outputs=[user_state])
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)