Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -138,7 +138,7 @@ class BasicAgent:
|
|
| 138 |
|
| 139 |
# Groq model
|
| 140 |
self.model = RetryOpenAIModel(
|
| 141 |
-
model_id="openai/gpt-oss-
|
| 142 |
api_base="https://api.groq.com/openai/v1",
|
| 143 |
api_key=os.environ["GROQ_API_KEY"],
|
| 144 |
client_kwargs={
|
|
@@ -151,6 +151,7 @@ class BasicAgent:
|
|
| 151 |
# Tools
|
| 152 |
self.tools = [
|
| 153 |
WebSearchTool(),
|
|
|
|
| 154 |
PythonInterpreterTool(
|
| 155 |
authorized_imports=["math", "re", "datetime", "collections"]
|
| 156 |
),
|
|
@@ -186,6 +187,14 @@ class BasicAgent:
|
|
| 186 |
- Do not repeat the same search query if it has already failed.
|
| 187 |
- If a search fails, try a shorter or broader query.
|
| 188 |
- Use additional tools only when necessary to obtain missing evidence.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
|
| 190 |
TOKEN EFFICIENCY:
|
| 191 |
- Minimize unnecessary model calls and tool invocations.
|
|
@@ -228,6 +237,17 @@ class BasicAgent:
|
|
| 228 |
question,
|
| 229 |
return_full_result=True
|
| 230 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 231 |
|
| 232 |
# Structured output
|
| 233 |
tool_steps = result.steps
|
|
@@ -375,12 +395,6 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 375 |
print("Agent did not produce any answers to submit.")
|
| 376 |
return "Agent did not produce any answers to submit.", pd.DataFrame(results_log)
|
| 377 |
|
| 378 |
-
if len(answers_payload) != len(questions_data):
|
| 379 |
-
print(f"Only {len(answers_payload)}/{len(questions_data)} valid answers.")
|
| 380 |
-
return (
|
| 381 |
-
f"Evaluation incomplete: {len(answers_payload)}/{len(questions_data)} valid answers. Submission cancelled.",
|
| 382 |
-
pd.DataFrame(results_log)
|
| 383 |
-
)
|
| 384 |
|
| 385 |
# 4. Prepare Submission
|
| 386 |
submission_data = {"username": username.strip(), "agent_code": agent_code, "answers": answers_payload}
|
|
|
|
| 138 |
|
| 139 |
# Groq model
|
| 140 |
self.model = RetryOpenAIModel(
|
| 141 |
+
model_id="openai/gpt-oss-20b",
|
| 142 |
api_base="https://api.groq.com/openai/v1",
|
| 143 |
api_key=os.environ["GROQ_API_KEY"],
|
| 144 |
client_kwargs={
|
|
|
|
| 151 |
# Tools
|
| 152 |
self.tools = [
|
| 153 |
WebSearchTool(),
|
| 154 |
+
VisitWebpageTool(),
|
| 155 |
PythonInterpreterTool(
|
| 156 |
authorized_imports=["math", "re", "datetime", "collections"]
|
| 157 |
),
|
|
|
|
| 187 |
- Do not repeat the same search query if it has already failed.
|
| 188 |
- If a search fails, try a shorter or broader query.
|
| 189 |
- Use additional tools only when necessary to obtain missing evidence.
|
| 190 |
+
|
| 191 |
+
TOOL CALLING RULES:
|
| 192 |
+
- Call only tools listed in the available tool schemas.
|
| 193 |
+
- To finish, call final_answer directly.
|
| 194 |
+
- Never call a tool named "answer".
|
| 195 |
+
- Never nest final_answer inside another tool call.
|
| 196 |
+
- Use exactly the input arguments declared by each tool.
|
| 197 |
+
- If evidence is insufficient, do not fabricate an answer.
|
| 198 |
|
| 199 |
TOKEN EFFICIENCY:
|
| 200 |
- Minimize unnecessary model calls and tool invocations.
|
|
|
|
| 237 |
question,
|
| 238 |
return_full_result=True
|
| 239 |
)
|
| 240 |
+
for i, step in enumerate(result.steps):
|
| 241 |
+
print(f"STEP {i + 1}")
|
| 242 |
+
|
| 243 |
+
if isinstance(step, dict):
|
| 244 |
+
print("Tool calls:", step.get("tool_calls"))
|
| 245 |
+
print("Observation:", step.get("observations"))
|
| 246 |
+
print("Error:", step.get("error"))
|
| 247 |
+
else:
|
| 248 |
+
print("Tool calls:", getattr(step, "tool_calls", None))
|
| 249 |
+
print("Observation:", getattr(step, "observations", None))
|
| 250 |
+
print("Error:", getattr(step, "error", None))
|
| 251 |
|
| 252 |
# Structured output
|
| 253 |
tool_steps = result.steps
|
|
|
|
| 395 |
print("Agent did not produce any answers to submit.")
|
| 396 |
return "Agent did not produce any answers to submit.", pd.DataFrame(results_log)
|
| 397 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 398 |
|
| 399 |
# 4. Prepare Submission
|
| 400 |
submission_data = {"username": username.strip(), "agent_code": agent_code, "answers": answers_payload}
|