Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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"
|
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(
|
56 |
"""Main function to run evaluation and submit answers"""
|
57 |
-
|
58 |
-
if not
|
59 |
return "Please Login to Hugging Face with the button.", None
|
60 |
|
61 |
-
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=[
|
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 |
|