Update app.py
Browse files
app.py
CHANGED
@@ -12,12 +12,12 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
12 |
# --- Basic Agent Definition ---
|
13 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
14 |
class BasicAgent:
|
15 |
-
def __init__(self):
|
16 |
print("BasicAgent initialized.")
|
17 |
# Initialize the model
|
18 |
#model = HfApiModel()
|
19 |
-
|
20 |
-
model = HfApiModel(model_id="Alibaba-NLP/gte-Qwen1.5-7B-instruct", api_token=
|
21 |
|
22 |
# Initialize the search tool
|
23 |
search_tool = DuckDuckGoSearchTool()
|
@@ -32,7 +32,7 @@ class BasicAgent:
|
|
32 |
print(f"Agent returning fixed answer: {fixed_answer}")
|
33 |
return fixed_answer
|
34 |
|
35 |
-
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
36 |
"""
|
37 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|
38 |
and displays the results.
|
@@ -53,7 +53,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
53 |
|
54 |
# 1. Instantiate Agent ( modify this part to create your agent)
|
55 |
try:
|
56 |
-
agent = BasicAgent()
|
57 |
except Exception as e:
|
58 |
print(f"Error instantiating agent: {e}")
|
59 |
return f"Error initializing agent: {e}", None
|
@@ -170,7 +170,9 @@ with gr.Blocks() as demo:
|
|
170 |
)
|
171 |
|
172 |
gr.LoginButton()
|
173 |
-
|
|
|
|
|
174 |
run_button = gr.Button("Run Evaluation & Submit All Answers")
|
175 |
|
176 |
status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
|
@@ -179,6 +181,9 @@ with gr.Blocks() as demo:
|
|
179 |
|
180 |
run_button.click(
|
181 |
fn=run_and_submit_all,
|
|
|
|
|
|
|
182 |
outputs=[status_output, results_table]
|
183 |
)
|
184 |
|
|
|
12 |
# --- Basic Agent Definition ---
|
13 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
14 |
class BasicAgent:
|
15 |
+
def __init__(self, HF_API_TOKEN):
|
16 |
print("BasicAgent initialized.")
|
17 |
# Initialize the model
|
18 |
#model = HfApiModel()
|
19 |
+
self.HF_API_TOKEN = HF_API_TOKEN
|
20 |
+
model = HfApiModel(model_id="Alibaba-NLP/gte-Qwen1.5-7B-instruct", api_token=self.HF_API_TOKEN)
|
21 |
|
22 |
# Initialize the search tool
|
23 |
search_tool = DuckDuckGoSearchTool()
|
|
|
32 |
print(f"Agent returning fixed answer: {fixed_answer}")
|
33 |
return fixed_answer
|
34 |
|
35 |
+
def run_and_submit_all( profile: gr.OAuthProfile | None, HF_API_TOKEN : str):
|
36 |
"""
|
37 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|
38 |
and displays the results.
|
|
|
53 |
|
54 |
# 1. Instantiate Agent ( modify this part to create your agent)
|
55 |
try:
|
56 |
+
agent = BasicAgent(HF_API_TOKEN)
|
57 |
except Exception as e:
|
58 |
print(f"Error instantiating agent: {e}")
|
59 |
return f"Error initializing agent: {e}", None
|
|
|
170 |
)
|
171 |
|
172 |
gr.LoginButton()
|
173 |
+
|
174 |
+
HF_API_TOKEN_box = gr.Textbox(label="HF_API_TOKEN", type="password", placeholder="sk-...", lines=1)
|
175 |
+
|
176 |
run_button = gr.Button("Run Evaluation & Submit All Answers")
|
177 |
|
178 |
status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
|
|
|
181 |
|
182 |
run_button.click(
|
183 |
fn=run_and_submit_all,
|
184 |
+
inputs=[HF_API_TOKEN_box],
|
185 |
+
|
186 |
+
|
187 |
outputs=[status_output, results_table]
|
188 |
)
|
189 |
|