LamiaYT commited on
Commit
7397662
·
1 Parent(s): ec78692

Deploy GAIA agent

Browse files
Files changed (1) hide show
  1. app.py +5 -12
app.py CHANGED
@@ -22,10 +22,11 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
22
 
23
  # --- Enhanced Tools for GAIA ---
24
 
25
- @tool
 
26
  def web_search_tool(query: str) -> str:
27
  """
28
- Searches the web using DuckDuckGo and returns relevant results.
29
 
30
  Args:
31
  query (str): The search query string.
@@ -34,24 +35,17 @@ def web_search_tool(query: str) -> str:
34
  str: A formatted string of search results.
35
  """
36
  try:
37
- from duckduckgo_search import DDGS
38
  with DDGS() as ddgs:
39
  results = ddgs.text(query, max_results=5)
40
- if not results:
41
- return "No search results found."
42
-
43
  output = []
44
  for result in results:
45
- output.append(
46
- f"Title: {result.get('title', 'No title')}\n"
47
- f"URL: {result.get('href', 'No URL')}\n"
48
- f"Snippet: {result.get('body', 'No snippet')}\n"
49
- )
50
  return "\n\n".join(output)
51
  except Exception as e:
52
  return f"Web search failed: {str(e)}"
53
 
54
 
 
55
  @tool
56
  def calculator_tool(expression: str) -> str:
57
  """
@@ -230,7 +224,6 @@ class GAIAAgent:
230
  self.agent = CodeAgent(
231
  tools=self.tools,
232
  model=self.model,
233
- max_iterations=5,
234
  verbosity_level=1
235
  )
236
  except Exception as e:
 
22
 
23
  # --- Enhanced Tools for GAIA ---
24
 
25
+ from duckduckgo_search import DDGS
26
+
27
  def web_search_tool(query: str) -> str:
28
  """
29
+ Performs a web search using DuckDuckGo.
30
 
31
  Args:
32
  query (str): The search query string.
 
35
  str: A formatted string of search results.
36
  """
37
  try:
 
38
  with DDGS() as ddgs:
39
  results = ddgs.text(query, max_results=5)
 
 
 
40
  output = []
41
  for result in results:
42
+ output.append(f"Title: {result['title']}\nURL: {result['href']}\nSnippet: {result['body']}")
 
 
 
 
43
  return "\n\n".join(output)
44
  except Exception as e:
45
  return f"Web search failed: {str(e)}"
46
 
47
 
48
+
49
  @tool
50
  def calculator_tool(expression: str) -> str:
51
  """
 
224
  self.agent = CodeAgent(
225
  tools=self.tools,
226
  model=self.model,
 
227
  verbosity_level=1
228
  )
229
  except Exception as e: