Updated run functions
Browse files
app.py
CHANGED
@@ -31,18 +31,9 @@ tracer = trace.get_tracer(__name__)
|
|
31 |
# Instrument smolagents with the configured provider
|
32 |
SmolagentsInstrumentor().instrument(tracer_provider=trace_provider)
|
33 |
|
34 |
-
def user_logged_in(profile: gr.OAuthProfile):
|
35 |
-
if profile:
|
36 |
-
username= f"{profile.username}"
|
37 |
-
print(f"User logged in: {username}")
|
38 |
-
return True
|
39 |
-
else:
|
40 |
-
print("User not logged in.")
|
41 |
-
return False
|
42 |
-
|
43 |
LOGIN_MESSAGE = "Please Login to Hugging Face with the button."
|
44 |
EMPTY_RESULTS_TABLE = pd.DataFrame(columns=['task_id', 'question', 'answer'])
|
45 |
-
|
46 |
def _format_elapsed_time(elapsed_time):
|
47 |
minutes = int(elapsed_time // 60) # Get the whole number of minutes
|
48 |
seconds = elapsed_time % 60 # Get the remaining seconds
|
@@ -60,24 +51,22 @@ def _run(questions: list, username: str) -> pd.DataFrame:
|
|
60 |
return message, question_answer_pairs
|
61 |
|
62 |
def run_one(profile: gr.OAuthProfile | None) -> pd.DataFrame:
|
63 |
-
if
|
|
|
|
|
64 |
return LOGIN_MESSAGE, EMPTY_RESULTS_TABLE
|
65 |
-
return _run([evaluator.get_one_question()], profile.username)
|
66 |
|
67 |
def run_all(profile: gr.OAuthProfile | None) -> pd.DataFrame:
|
68 |
-
if
|
|
|
|
|
69 |
return LOGIN_MESSAGE, EMPTY_RESULTS_TABLE
|
70 |
-
questions = evaluator.get_questions()
|
71 |
-
start_time = time.time()
|
72 |
-
question_answer_pairs = runner.run_agent(questions, profile.username)
|
73 |
-
end_time = time.time()
|
74 |
-
message = f"Complete. {_format_elapsed_time(end_time - start_time)}"
|
75 |
-
return message, question_answer_pairs
|
76 |
|
77 |
def submit(profile: gr.OAuthProfile | None) -> str:
|
78 |
-
if
|
|
|
|
|
79 |
return LOGIN_MESSAGE
|
80 |
-
return evaluator.submit_answers(profile.username)
|
81 |
|
82 |
|
83 |
# --- Build Gradio Interface using Blocks ---
|
|
|
31 |
# Instrument smolagents with the configured provider
|
32 |
SmolagentsInstrumentor().instrument(tracer_provider=trace_provider)
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
LOGIN_MESSAGE = "Please Login to Hugging Face with the button."
|
35 |
EMPTY_RESULTS_TABLE = pd.DataFrame(columns=['task_id', 'question', 'answer'])
|
36 |
+
|
37 |
def _format_elapsed_time(elapsed_time):
|
38 |
minutes = int(elapsed_time // 60) # Get the whole number of minutes
|
39 |
seconds = elapsed_time % 60 # Get the remaining seconds
|
|
|
51 |
return message, question_answer_pairs
|
52 |
|
53 |
def run_one(profile: gr.OAuthProfile | None) -> pd.DataFrame:
|
54 |
+
if profile:
|
55 |
+
return _run([evaluator.get_one_question()], profile.username)
|
56 |
+
else:
|
57 |
return LOGIN_MESSAGE, EMPTY_RESULTS_TABLE
|
|
|
58 |
|
59 |
def run_all(profile: gr.OAuthProfile | None) -> pd.DataFrame:
|
60 |
+
if profile:
|
61 |
+
return _run(evaluator.get_questions(), profile.username)
|
62 |
+
else:
|
63 |
return LOGIN_MESSAGE, EMPTY_RESULTS_TABLE
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
def submit(profile: gr.OAuthProfile | None) -> str:
|
66 |
+
if profile:
|
67 |
+
return evaluator.submit_answers(profile.username)
|
68 |
+
else:
|
69 |
return LOGIN_MESSAGE
|
|
|
70 |
|
71 |
|
72 |
# --- Build Gradio Interface using Blocks ---
|