Datawithsarah commited on
Commit
56e4890
·
1 Parent(s): 5bd65b0
Files changed (1) hide show
  1. agent.py +8 -0
agent.py CHANGED
@@ -23,38 +23,46 @@ load_dotenv()
23
  # === Tools ===
24
  @tool
25
  def multiply(a: int, b: int) -> int:
 
26
  return a * b
27
 
28
  @tool
29
  def add(a: int, b: int) -> int:
 
30
  return a + b
31
 
32
  @tool
33
  def subtract(a: int, b: int) -> int:
 
34
  return a - b
35
 
36
  @tool
37
  def divide(a: int, b: int) -> float:
 
38
  if b == 0:
39
  raise ValueError("Cannot divide by zero.")
40
  return a / b
41
 
42
  @tool
43
  def modulus(a: int, b: int) -> int:
 
44
  return a % b
45
 
46
  @tool
47
  def wiki_search(query: str) -> str:
 
48
  search_docs = WikipediaLoader(query=query, load_max_docs=2).load()
49
  return "\n\n---\n\n".join([doc.page_content for doc in search_docs])
50
 
51
  @tool
52
  def web_search(query: str) -> str:
 
53
  search_docs = TavilySearchResults(max_results=3).invoke(query=query)
54
  return "\n\n---\n\n".join([doc.page_content for doc in search_docs])
55
 
56
  @tool
57
  def arvix_search(query: str) -> str:
 
58
  search_docs = ArxivLoader(query=query, load_max_docs=3).load()
59
  return "\n\n---\n\n".join([doc.page_content[:1000] for doc in search_docs])
60
 
 
23
  # === Tools ===
24
  @tool
25
  def multiply(a: int, b: int) -> int:
26
+ """Multiplies two integers and returns the result."""
27
  return a * b
28
 
29
  @tool
30
  def add(a: int, b: int) -> int:
31
+ """Adds two integers and returns the sum."""
32
  return a + b
33
 
34
  @tool
35
  def subtract(a: int, b: int) -> int:
36
+ """Subtracts the second integer from the first and returns the result."""
37
  return a - b
38
 
39
  @tool
40
  def divide(a: int, b: int) -> float:
41
+ """Divides the first integer by the second and returns the result as a float."""
42
  if b == 0:
43
  raise ValueError("Cannot divide by zero.")
44
  return a / b
45
 
46
  @tool
47
  def modulus(a: int, b: int) -> int:
48
+ """Returns the remainder of dividing the first integer by the second."""
49
  return a % b
50
 
51
  @tool
52
  def wiki_search(query: str) -> str:
53
+ """Searches Wikipedia for a query and returns the top 2 results as a formatted string."""
54
  search_docs = WikipediaLoader(query=query, load_max_docs=2).load()
55
  return "\n\n---\n\n".join([doc.page_content for doc in search_docs])
56
 
57
  @tool
58
  def web_search(query: str) -> str:
59
+ """Uses Tavily to search the web for a query and returns the top 3 result snippets."""
60
  search_docs = TavilySearchResults(max_results=3).invoke(query=query)
61
  return "\n\n---\n\n".join([doc.page_content for doc in search_docs])
62
 
63
  @tool
64
  def arvix_search(query: str) -> str:
65
+ """Searches Arxiv for academic papers related to the query and returns the top 3 abstracts."""
66
  search_docs = ArxivLoader(query=query, load_max_docs=3).load()
67
  return "\n\n---\n\n".join([doc.page_content[:1000] for doc in search_docs])
68