LamiaYT commited on
Commit
789c39e
ยท
1 Parent(s): 2362dfa

Deploy GAIA agent

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -11,9 +11,10 @@ from PIL import Image
11
  import matplotlib.pyplot as plt
12
  import numpy as np
13
  from pathlib import Path
 
14
 
15
  # SmolaAgent imports
16
- from smolagents import CodeAgent, tool, DuckDuckGoSearchTool, PythonInterpreterTool
17
  from smolagents.models import LiteLLMModel
18
 
19
  # --- Constants ---
@@ -21,7 +22,6 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
21
 
22
  # --- Enhanced Tools for GAIA ---
23
 
24
- # Replace the web_search_tool implementation with this updated version
25
  @tool
26
  def web_search_tool(query: str) -> str:
27
  """
@@ -33,11 +33,10 @@ def web_search_tool(query: str) -> str:
33
  """
34
  try:
35
  # Use duckduckgo_search directly with the current API
36
- from duckduckgo_search import DDGS
37
-
38
  results = []
39
  with DDGS() as ddgs:
40
- for r in ddgs.text(query, max_results=3):
 
41
  results.append(f"Title: {r['title']}\nURL: {r['href']}\nSnippet: {r['body']}")
42
 
43
  if not results:
@@ -46,6 +45,7 @@ def web_search_tool(query: str) -> str:
46
  return "\n\n".join(results)
47
  except Exception as e:
48
  return f"Search failed: {str(e)}"
 
49
  @tool
50
  def calculator_tool(expression: str) -> str:
51
  """
@@ -469,7 +469,7 @@ with gr.Blocks() as demo:
469
  **Enhanced GAIA Agent with SmolaAgent Framework**
470
 
471
  This agent is equipped with:
472
- - ๐Ÿ” Web search capabilities (DuckDuckGo)
473
  - ๐Ÿงฎ Mathematical calculator
474
  - ๐Ÿ–ผ๏ธ Image analysis
475
  - ๐Ÿ“ File processing (CSV, JSON, text files)
 
11
  import matplotlib.pyplot as plt
12
  import numpy as np
13
  from pathlib import Path
14
+ from duckduckgo_search import DDGS
15
 
16
  # SmolaAgent imports
17
+ from smolagents import CodeAgent, tool, PythonInterpreterTool
18
  from smolagents.models import LiteLLMModel
19
 
20
  # --- Constants ---
 
22
 
23
  # --- Enhanced Tools for GAIA ---
24
 
 
25
  @tool
26
  def web_search_tool(query: str) -> str:
27
  """
 
33
  """
34
  try:
35
  # Use duckduckgo_search directly with the current API
 
 
36
  results = []
37
  with DDGS() as ddgs:
38
+ search_results = ddgs.text(query, max_results=5)
39
+ for r in search_results:
40
  results.append(f"Title: {r['title']}\nURL: {r['href']}\nSnippet: {r['body']}")
41
 
42
  if not results:
 
45
  return "\n\n".join(results)
46
  except Exception as e:
47
  return f"Search failed: {str(e)}"
48
+
49
  @tool
50
  def calculator_tool(expression: str) -> str:
51
  """
 
469
  **Enhanced GAIA Agent with SmolaAgent Framework**
470
 
471
  This agent is equipped with:
472
+ - ๐Ÿ” Web search capabilities (DuckDuckGo) - **FIXED**
473
  - ๐Ÿงฎ Mathematical calculator
474
  - ๐Ÿ–ผ๏ธ Image analysis
475
  - ๐Ÿ“ File processing (CSV, JSON, text files)