Update app.py
Browse filesRestored the original profile check for login
app.py
CHANGED
@@ -30,20 +30,36 @@ tracer = trace.get_tracer(__name__)
|
|
30 |
# Instrument smolagents with the configured provider
|
31 |
SmolagentsInstrumentor().instrument(tracer_provider=trace_provider)
|
32 |
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
else:
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
# return runner.run_agent(questions)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
return pd.DataFrame(columns=['task_id', 'question', 'answer'])
|
44 |
-
|
45 |
|
46 |
def submit():
|
|
|
|
|
47 |
# evaluator.submit_answers()
|
48 |
logger.info("submit")
|
49 |
|
@@ -55,14 +71,15 @@ with gr.Blocks() as demo:
|
|
55 |
"""
|
56 |
**Instructions:**
|
57 |
|
58 |
-
1.
|
59 |
-
2.
|
60 |
-
3. Click '
|
61 |
|
62 |
---
|
63 |
**Disclaimers:**
|
64 |
-
Once clicking
|
65 |
-
|
|
|
66 |
"""
|
67 |
)
|
68 |
|
@@ -78,12 +95,10 @@ with gr.Blocks() as demo:
|
|
78 |
label="Questions and Agent Answers", wrap=True)
|
79 |
|
80 |
run_one_button.click(
|
81 |
-
fn=
|
82 |
-
outputs=[results_table]
|
83 |
)
|
84 |
run_all_button.click(
|
85 |
-
fn=
|
86 |
-
outputs=[results_table]
|
87 |
)
|
88 |
submit_button.click(
|
89 |
fn=submit,
|
|
|
30 |
# Instrument smolagents with the configured provider
|
31 |
SmolagentsInstrumentor().instrument(tracer_provider=trace_provider)
|
32 |
|
33 |
+
def user_logged_in(profile: gr.OAuthProfile):
|
34 |
+
if profile:
|
35 |
+
username= f"{profile.username}"
|
36 |
+
print(f"User logged in: {username}")
|
37 |
+
return True
|
38 |
else:
|
39 |
+
print("User not logged in.")
|
40 |
+
return False
|
41 |
+
|
42 |
+
LOGIN_MESSAGE = "Please Login to Hugging Face with the button."
|
43 |
+
|
44 |
+
def run_one(profile: gr.OAuthProfile | None) -> pd.DataFrame:
|
45 |
+
if not user_logged_in(profile):
|
46 |
+
return LOGIN_MESSAGE
|
47 |
+
# questions = [evaluator.get_one_question()]
|
48 |
# return runner.run_agent(questions)
|
49 |
+
logger.info("test_mode")
|
50 |
+
return pd.DataFrame(columns=['task_id', 'question', 'answer'])
|
51 |
+
|
52 |
+
def run_all(profile: gr.OAuthProfile | None) -> pd.DataFrame:
|
53 |
+
if not user_logged_in:
|
54 |
+
return LOGIN_MESSAGE
|
55 |
+
# questions = evaluator.get_questions()
|
56 |
+
# return runner.run_agent(questions)
|
57 |
+
logger.info("not test_mode")
|
58 |
return pd.DataFrame(columns=['task_id', 'question', 'answer'])
|
|
|
59 |
|
60 |
def submit():
|
61 |
+
if not user_logged_in:
|
62 |
+
return LOGIN_MESSAGE
|
63 |
# evaluator.submit_answers()
|
64 |
logger.info("submit")
|
65 |
|
|
|
71 |
"""
|
72 |
**Instructions:**
|
73 |
|
74 |
+
1. Click 'Get One Answer' to fetch a ranodom question, run the agent, and see the question-answer pair below
|
75 |
+
2. Click 'Run Full Evaluation' to fetch all question, run the agent, and see the question-answer pairs below
|
76 |
+
3. Click 'Submit All Answers' to fetch questions, run your agent, submit answers, and see the score.
|
77 |
|
78 |
---
|
79 |
**Disclaimers:**
|
80 |
+
Once clicking 'Submit All Answers', it can take quite some time (this is the time for the agent to go through all the questions).
|
81 |
+
The agent will run questions in parallel for the full evaluation, making observability tools a must.
|
82 |
+
The submit button will use the most recent agent answers cached in the space.
|
83 |
"""
|
84 |
)
|
85 |
|
|
|
95 |
label="Questions and Agent Answers", wrap=True)
|
96 |
|
97 |
run_one_button.click(
|
98 |
+
fn=run_one, outputs=[results_table]
|
|
|
99 |
)
|
100 |
run_all_button.click(
|
101 |
+
fn=run_all, outputs=[results_table]
|
|
|
102 |
)
|
103 |
submit_button.click(
|
104 |
fn=submit,
|