ATK20 commited on
Commit
9efd6bd
·
verified ·
1 Parent(s): 4e281a3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -6,7 +6,7 @@ from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM
6
 
7
  # --- Constants ---
8
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
9
- DEFAULT_HF_MODEL = "mistralai/Mistral-7B-Instruct-v0.1" # Free model on Hugging Face
10
 
11
  # --- Basic Agent Definition ---
12
  class BasicAgent:
@@ -52,13 +52,14 @@ class BasicAgent:
52
  print(f"Error generating answer: {e}")
53
  return f"Error generating answer: {e}"
54
 
55
- def run_and_submit_all(profile: gr.OAuthProfile | None, hf_token: str):
56
  """Main function to run evaluation and submit answers"""
57
- space_id = os.getenv("SPACE_ID")
58
- if not profile:
59
  return "Please Login to Hugging Face with the button.", None
60
 
61
- username = profile.username
 
62
  api_url = DEFAULT_API_URL
63
  questions_url = f"{api_url}/questions"
64
  submit_url = f"{api_url}/submit"
@@ -149,7 +150,7 @@ with gr.Blocks() as demo:
149
 
150
  run_button.click(
151
  fn=run_and_submit_all,
152
- inputs=[gr.OAuthProfile(), hf_token_input],
153
  outputs=[status_output, results_table]
154
  )
155
 
 
6
 
7
  # --- Constants ---
8
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
9
+ DEFAULT_HF_MODEL = "mistralai/Mistral-7B-Instruct-v0.1"
10
 
11
  # --- Basic Agent Definition ---
12
  class BasicAgent:
 
52
  print(f"Error generating answer: {e}")
53
  return f"Error generating answer: {e}"
54
 
55
+ def run_and_submit_all(hf_token: str, request: gr.Request):
56
  """Main function to run evaluation and submit answers"""
57
+ # Get user info from the request
58
+ if not request.username:
59
  return "Please Login to Hugging Face with the button.", None
60
 
61
+ username = request.username
62
+ space_id = os.getenv("SPACE_ID")
63
  api_url = DEFAULT_API_URL
64
  questions_url = f"{api_url}/questions"
65
  submit_url = f"{api_url}/submit"
 
150
 
151
  run_button.click(
152
  fn=run_and_submit_all,
153
+ inputs=[hf_token_input],
154
  outputs=[status_output, results_table]
155
  )
156