AlanRocha commited on
Commit
4694a9d
·
verified ·
1 Parent(s): a364cf1

Update tools/tools.py

Browse files
Files changed (1) hide show
  1. tools/tools.py +35 -0
tools/tools.py CHANGED
@@ -13,11 +13,46 @@ from dotenv import load_dotenv
13
  from smolagents import tool, LiteLLMModel
14
  import google.generativeai as genai
15
  from pytesseract import image_to_string
 
16
 
17
  load_dotenv()
18
 
19
  MODEL_ID = "groq/meta-llama/llama-4-scout-17b-16e-instruct"
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  # Vision Tool
22
  @tool
23
  def vision_tool(prompt: str, image_list: List[Image.Image]) -> str:
 
13
  from smolagents import tool, LiteLLMModel
14
  import google.generativeai as genai
15
  from pytesseract import image_to_string
16
+ from smolagents import WikipediaSearchTool, tool
17
 
18
  load_dotenv()
19
 
20
  MODEL_ID = "groq/meta-llama/llama-4-scout-17b-16e-instruct"
21
 
22
+ _wiki_tool = WikipediaSearchTool(
23
+ user_agent="GAIA-Agent (alandiogo200@gmail.com)", # troque pelo seu email real
24
+ content_type="summary",
25
+ )
26
+
27
+ @tool
28
+ def wikipedia_search(query: str, max_chars: int = 2000) -> str:
29
+ """
30
+ Searches Wikipedia and returns a summary, truncated as a safety net.
31
+ Args:
32
+ query (str): The search term. Use the exact Wikipedia page title (e.g. "Mercedes_Sosa").
33
+ max_chars (int): Maximum characters to return (default 2000).
34
+ Returns:
35
+ str: Wikipedia summary content or an error message.
36
+ """
37
+ result = _wiki_tool.forward(query)
38
+ if result and len(result) > max_chars:
39
+ return result[:max_chars] + "\n\n[...content truncated, use a more specific query if you need more detail...]"
40
+ return result
41
+
42
+ @tool
43
+ def wikipedia_search(query: str, max_chars: int = 2000) -> str:
44
+ """
45
+ Searches Wikipedia and returns a summary, truncated as a safety net.
46
+ Args:
47
+ query (str): The search term. Use the exact Wikipedia page title (e.g. "Mercedes_Sosa").
48
+ max_chars (int): Maximum characters to return (default 2000).
49
+ Returns:
50
+ str: Wikipedia summary content or an error message.
51
+ """
52
+ result = _wiki_tool.forward(query)
53
+ if result and len(result) > max_chars:
54
+ return result[:max_chars] + "\n\n[...content truncated, use a more specific query if you need more detail...]"
55
+ return result
56
  # Vision Tool
57
  @tool
58
  def vision_tool(prompt: str, image_list: List[Image.Image]) -> str: