rakesh-dvg commited on
Commit
b419bcf
·
verified ·
1 Parent(s): ea10964

Update agent.py

Browse files
Files changed (1) hide show
  1. agent.py +8 -0
agent.py CHANGED
@@ -12,28 +12,34 @@ from langchain_core.tools import tool
12
 
13
  @tool
14
  def multiply(a: int, b: int) -> int:
 
15
  return a * b
16
 
17
  @tool
18
  def add(a: int, b: int) -> int:
 
19
  return a + b
20
 
21
  @tool
22
  def subtract(a: int, b: int) -> int:
 
23
  return a - b
24
 
25
  @tool
26
  def divide(a: int, b: int) -> float:
 
27
  if b == 0:
28
  raise ValueError("Cannot divide by zero.")
29
  return a / b
30
 
31
  @tool
32
  def modulus(a: int, b: int) -> int:
 
33
  return a % b
34
 
35
  @tool
36
  def wiki_search(query: str) -> dict:
 
37
  search_docs = WikipediaLoader(query=query, load_max_docs=2).load()
38
  results = "\n\n---\n\n".join(
39
  f"<Document>\n{doc.page_content}\n</Document>" for doc in search_docs
@@ -42,6 +48,7 @@ def wiki_search(query: str) -> dict:
42
 
43
  @tool
44
  def web_search(query: str) -> dict:
 
45
  search_docs = TavilySearchResults(max_results=3).invoke(query=query)
46
  results = "\n\n---\n\n".join(
47
  f"<Document>\n{doc.page_content}\n</Document>" for doc in search_docs
@@ -50,6 +57,7 @@ def web_search(query: str) -> dict:
50
 
51
  @tool
52
  def arvix_search(query: str) -> dict:
 
53
  search_docs = ArxivLoader(query=query, load_max_docs=3).load()
54
  results = "\n\n---\n\n".join(
55
  f"<Document>\n{doc.page_content[:500]}\n</Document>" for doc in search_docs
 
12
 
13
  @tool
14
  def multiply(a: int, b: int) -> int:
15
+ """Multiply two integers and return the result."""
16
  return a * b
17
 
18
  @tool
19
  def add(a: int, b: int) -> int:
20
+ """Add two integers and return the result."""
21
  return a + b
22
 
23
  @tool
24
  def subtract(a: int, b: int) -> int:
25
+ """Subtract b from a and return the result."""
26
  return a - b
27
 
28
  @tool
29
  def divide(a: int, b: int) -> float:
30
+ """Divide a by b and return the result. Raises an error if b is zero."""
31
  if b == 0:
32
  raise ValueError("Cannot divide by zero.")
33
  return a / b
34
 
35
  @tool
36
  def modulus(a: int, b: int) -> int:
37
+ """Return the modulus (remainder) of a divided by b."""
38
  return a % b
39
 
40
  @tool
41
  def wiki_search(query: str) -> dict:
42
+ """Search Wikipedia for a query and return up to 2 results."""
43
  search_docs = WikipediaLoader(query=query, load_max_docs=2).load()
44
  results = "\n\n---\n\n".join(
45
  f"<Document>\n{doc.page_content}\n</Document>" for doc in search_docs
 
48
 
49
  @tool
50
  def web_search(query: str) -> dict:
51
+ """Search the web via Tavily and return up to 3 results."""
52
  search_docs = TavilySearchResults(max_results=3).invoke(query=query)
53
  results = "\n\n---\n\n".join(
54
  f"<Document>\n{doc.page_content}\n</Document>" for doc in search_docs
 
57
 
58
  @tool
59
  def arvix_search(query: str) -> dict:
60
+ """Search Arxiv and return up to 3 truncated results."""
61
  search_docs = ArxivLoader(query=query, load_max_docs=3).load()
62
  results = "\n\n---\n\n".join(
63
  f"<Document>\n{doc.page_content[:500]}\n</Document>" for doc in search_docs