Jofthomas commited on
Commit
7e4a06b
·
verified ·
1 Parent(s): d123508

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -11
app.py CHANGED
@@ -42,17 +42,19 @@ class BasicAgent:
42
 
43
  # --- Gradio UI and Logic ---
44
 
45
- def run_and_submit_all(api_url: str, username: str):
46
  """
47
  Fetches all questions, runs the BasicAgent on them, submits all answers,
48
  and displays the results.
49
  """
50
- if not api_url:
51
- return "Please enter the API URL.", None # Status, DataFrame
52
- if not username:
53
- return "Please enter your Hugging Face username.", None # Status, DataFrame
54
-
55
- api_url = api_url.strip('/')
 
 
56
  questions_url = f"{api_url}/questions"
57
  submit_url = f"{api_url}/submit"
58
 
@@ -179,9 +181,7 @@ with gr.Blocks() as demo:
179
  "submit all answers at once, and display the results."
180
  )
181
 
182
- with gr.Row():
183
- api_url_input = gr.Textbox(label="FastAPI API URL", value=DEFAULT_API_URL)
184
- hf_username_input = gr.Textbox(label="Hugging Face Username")
185
 
186
  run_button = gr.Button("Run Evaluation & Submit All Answers")
187
 
@@ -191,7 +191,6 @@ with gr.Blocks() as demo:
191
  # --- Component Interaction ---
192
  run_button.click(
193
  fn=run_and_submit_all,
194
- inputs=[api_url_input, hf_username_input],
195
  outputs=[status_output, results_table]
196
  )
197
 
 
42
 
43
  # --- Gradio UI and Logic ---
44
 
45
+ def run_and_submit_all( profile gr.OAuthProfile , api_url: str):
46
  """
47
  Fetches all questions, runs the BasicAgent on them, submits all answers,
48
  and displays the results.
49
  """
50
+
51
+ if profile:
52
+ username= f"{profile.name}"
53
+
54
+ else:
55
+ return "Please Login to Hugging Face with the button.", None
56
+
57
+ api_url = DEFAULT_API_URL
58
  questions_url = f"{api_url}/questions"
59
  submit_url = f"{api_url}/submit"
60
 
 
181
  "submit all answers at once, and display the results."
182
  )
183
 
184
+ gr.LoginButton()
 
 
185
 
186
  run_button = gr.Button("Run Evaluation & Submit All Answers")
187
 
 
191
  # --- Component Interaction ---
192
  run_button.click(
193
  fn=run_and_submit_all,
 
194
  outputs=[status_output, results_table]
195
  )
196