Imnotchis commited on
Commit
ac93ca7
·
verified ·
1 Parent(s): b855191

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -87
app.py CHANGED
@@ -181,7 +181,7 @@ class SmartWebSearchTool(Tool):
181
  try:
182
  results = DDGS(timeout=8).text(
183
  query,
184
- max_results=4
185
  )
186
  except Exception as e:
187
  return f"Search failed: {type(e).__name__}: {e}"
@@ -272,7 +272,7 @@ class SmartWebSearchTool(Tool):
272
  if text:
273
  output.append(
274
  "Extracted page content:\n"
275
- + text[:4500]
276
  )
277
  pages_read += 1
278
 
@@ -282,7 +282,7 @@ class SmartWebSearchTool(Tool):
282
  f"{type(e).__name__}\n"
283
  )
284
 
285
- return "\n".join(output)[:12000]
286
 
287
  class BasicAgent:
288
  def __init__(self):
@@ -295,6 +295,7 @@ class BasicAgent:
295
  "timeout": 60.0,
296
  "max_retries": 0
297
  },
 
298
  retry=False
299
  )
300
 
@@ -314,90 +315,19 @@ class BasicAgent:
314
  max_steps=5,
315
  verbosity_level=1,
316
  instructions="""
317
- You are an intelligent AI agent designed to solve GAIA benchmark questions accurately and efficiently.
318
-
319
- Your goal is to produce the correct final answer while minimizing unnecessary tool calls and token usage.
320
-
321
- GENERAL RULES:
322
- - Read the entire question carefully before taking any action.
323
- - Follow all constraints and output formatting requirements.
324
- - Reason carefully and verify uncertain information.
325
- - Never fabricate facts, sources, or tool results.
326
- - Use only information available to you and your tools.
327
- - Do not assume missing attachments or inaccessible content have been examined.
328
-
329
- TOOL SELECTION:
330
- - First determine whether the question requires external research.
331
- - If the answer is directly derivable from the question, do not search.
332
- - For external research, use a focused web_search query.
333
- - Search for the entity, source title, date, or exact phrase.
334
- - Do not paste the entire question into the search query.
335
- - Read the search results carefully before using another tool.
336
- - Search results provide snippets, not necessarily full documents.
337
- - If a result contains enough reliable evidence, answer immediately.
338
- - Otherwise, use visit_webpage on the most relevant source.
339
- - Prefer official sources, research papers, and primary documents.
340
- - For a named Wikipedia article, wikipedia_search may be used.
341
- - For Wikipedia history, nominations, or dated lists, prefer
342
- web_search to locate the exact historical page.
343
- - Never repeat the same or nearly identical search query.
344
- - If a website returns 403, switch to another accessible source.
345
- - Do not use visit_webpage to watch YouTube videos.
346
- - Do not claim to have inspected video, audio, or image content
347
- unless that content was actually supplied.
348
-
349
- TOOL CALLING RULES:
350
- - Call only tools listed in the available tool schemas.
351
- - To finish, call final_answer directly.
352
- - Never call a tool named "answer".
353
- - Never nest final_answer inside another tool call.
354
- - Use exactly the input arguments declared by each tool.
355
- - If evidence is insufficient, do not fabricate an answer.
356
- RESEARCH STRATEGY:
357
- - Use the first web search to identify the most likely primary source.
358
- - If needed, visit that source to extract the requested fact.
359
- - If the source is unavailable, use one different search strategy.
360
- - Avoid spending all available steps on increasingly similar searches.
361
- - When sufficient evidence is found, call final_answer immediately.
362
- - When evidence is insufficient, do not guess merely to finish.
363
-
364
- TOKEN EFFICIENCY:
365
- - Minimize unnecessary model calls and tool invocations.
366
- - Do not repeat information already available in tool observations.
367
- - Avoid redundant searches and excessive verification.
368
- - If the available evidence is sufficient, stop searching.
369
- - Prefer focused search queries over long keyword lists.
370
- - Do not spend additional steps researching an already resolved question.
371
-
372
- ERROR HANDLING:
373
- - If a tool returns no results, reconsider the search strategy.
374
- - If a website returns HTTP 403, consider another accessible source.
375
- - Do not repeatedly call a tool that is consistently failing.
376
- - Do not invent an answer to compensate for failed tools.
377
-
378
- FINAL ANSWER:
379
- - When the answer is determined, invoke the final_answer tool.
380
- - Use the native tool calling mechanism to invoke final_answer.
381
- - Do not output a textual JSON representation of a tool call.
382
- - The final answer must directly answer the question.
383
- - Return only the requested answer without explanations, citations, or extra commentary.
384
- - If the answer is a number, return only the number.
385
- - If the answer is a city, return its full city name.
386
- - If the answer is a person, return only the person's name.
387
- - If the question requires a specific format, follow it exactly.
388
- - Do not include markdown formatting unless requested.
389
- - Do not call additional tools after obtaining sufficient evidence.
390
-
391
- PYTHON TOOL RULES:
392
- - The python_interpreter tool requires exactly one argument named "code".
393
- - The "code" argument must contain Python source code as a JSON string.
394
- - Never put raw Python code directly inside "arguments".
395
- - All tool calls must contain valid JSON arguments.
396
- - Call final_answer directly when finished.
397
-
398
- Example:
399
- {"name": "python_interpreter",
400
- "arguments": {"code": "print(sum([10, 20, 30]))"}}
401
  """
402
  )
403
 
 
181
  try:
182
  results = DDGS(timeout=8).text(
183
  query,
184
+ max_results=3
185
  )
186
  except Exception as e:
187
  return f"Search failed: {type(e).__name__}: {e}"
 
272
  if text:
273
  output.append(
274
  "Extracted page content:\n"
275
+ + text[:2500]
276
  )
277
  pages_read += 1
278
 
 
282
  f"{type(e).__name__}\n"
283
  )
284
 
285
+ return "\n".join(output)[:7000]
286
 
287
  class BasicAgent:
288
  def __init__(self):
 
295
  "timeout": 60.0,
296
  "max_retries": 0
297
  },
298
+ max_tokens=700,
299
  retry=False
300
  )
301
 
 
315
  max_steps=5,
316
  verbosity_level=1,
317
  instructions="""
318
+ Solve GAIA questions accurately with minimal tool calls.
319
+
320
+ - Follow the exact answer format requested.
321
+ - Answer directly when no research is needed.
322
+ - For research, use smart_web_search with focused keywords.
323
+ - Read all returned evidence before searching again.
324
+ - Do not repeat searches or visit inaccessible sources.
325
+ - Use wikipedia_search for Wikipedia-specific questions.
326
+ - Use python_interpreter for calculations when necessary.
327
+ - Never invent facts or claim to have inspected missing media.
328
+ - Call final_answer as soon as sufficient evidence exists.
329
+ - Return only the requested answer without explanations.
330
+ - Use only tools and arguments defined in their schemas.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
331
  """
332
  )
333