rakesh-dvg commited on
Commit
371909c
·
verified ·
1 Parent(s): 649de87

Update agent.py

Browse files
Files changed (1) hide show
  1. agent.py +81 -1
agent.py CHANGED
@@ -25,6 +25,7 @@ print(f"SUPABASE_SERVICE_KEY: {SUPABASE_SERVICE_KEY[:10]}..." if SUPABASE_SERVIC
25
 
26
 
27
  def get_supabase_client():
 
28
  if not SUPABASE_URL or not SUPABASE_SERVICE_KEY:
29
  raise ValueError("Supabase environment variables are missing.")
30
  return create_client(SUPABASE_URL, SUPABASE_SERVICE_KEY)
@@ -32,38 +33,117 @@ def get_supabase_client():
32
 
33
  @tool
34
  def multiply(a: int, b: int) -> int:
 
 
 
 
 
 
 
 
 
35
  return a * b
36
 
 
37
  @tool
38
  def add(a: int, b: int) -> int:
 
 
 
 
 
 
 
 
 
39
  return a + b
40
 
 
41
  @tool
42
  def subtract(a: int, b: int) -> int:
 
 
 
 
 
 
 
 
 
43
  return a - b
44
 
 
45
  @tool
46
- def divide(a: int, b: int) -> int:
 
 
 
 
 
 
 
 
 
 
 
 
47
  if b == 0:
48
  raise ValueError("Cannot divide by zero.")
49
  return a / b
50
 
 
51
  @tool
52
  def modulus(a: int, b: int) -> int:
 
 
 
 
 
 
 
 
 
53
  return a % b
54
 
 
55
  @tool
56
  def wiki_search(query: str) -> str:
 
 
 
 
 
 
 
 
57
  docs = WikipediaLoader(query=query, load_max_docs=2).load()
58
  return "\n\n---\n\n".join([doc.page_content for doc in docs])
59
 
 
60
  @tool
61
  def web_search(query: str) -> str:
 
 
 
 
 
 
 
 
62
  docs = TavilySearchResults(max_results=3).invoke(query=query)
63
  return "\n\n---\n\n".join([doc.page_content for doc in docs])
64
 
 
65
  @tool
66
  def arvix_search(query: str) -> str:
 
 
 
 
 
 
 
 
67
  docs = ArxivLoader(query=query, load_max_docs=3).load()
68
  return "\n\n---\n\n".join([doc.page_content[:1000] for doc in docs])
69
 
 
25
 
26
 
27
  def get_supabase_client():
28
+ """Create and return a Supabase client from environment variables."""
29
  if not SUPABASE_URL or not SUPABASE_SERVICE_KEY:
30
  raise ValueError("Supabase environment variables are missing.")
31
  return create_client(SUPABASE_URL, SUPABASE_SERVICE_KEY)
 
33
 
34
  @tool
35
  def multiply(a: int, b: int) -> int:
36
+ """Multiply two integers and return the result.
37
+
38
+ Args:
39
+ a (int): First multiplier.
40
+ b (int): Second multiplier.
41
+
42
+ Returns:
43
+ int: The product of a and b.
44
+ """
45
  return a * b
46
 
47
+
48
  @tool
49
  def add(a: int, b: int) -> int:
50
+ """Add two integers and return the sum.
51
+
52
+ Args:
53
+ a (int): First addend.
54
+ b (int): Second addend.
55
+
56
+ Returns:
57
+ int: The sum of a and b.
58
+ """
59
  return a + b
60
 
61
+
62
  @tool
63
  def subtract(a: int, b: int) -> int:
64
+ """Subtract b from a and return the difference.
65
+
66
+ Args:
67
+ a (int): Minuend.
68
+ b (int): Subtrahend.
69
+
70
+ Returns:
71
+ int: The difference a - b.
72
+ """
73
  return a - b
74
 
75
+
76
  @tool
77
+ def divide(a: int, b: int) -> float:
78
+ """Divide a by b and return the quotient.
79
+
80
+ Args:
81
+ a (int): Dividend.
82
+ b (int): Divisor.
83
+
84
+ Raises:
85
+ ValueError: If b is zero.
86
+
87
+ Returns:
88
+ float: The quotient of a divided by b.
89
+ """
90
  if b == 0:
91
  raise ValueError("Cannot divide by zero.")
92
  return a / b
93
 
94
+
95
  @tool
96
  def modulus(a: int, b: int) -> int:
97
+ """Return the remainder of dividing a by b.
98
+
99
+ Args:
100
+ a (int): Dividend.
101
+ b (int): Divisor.
102
+
103
+ Returns:
104
+ int: The remainder of a divided by b.
105
+ """
106
  return a % b
107
 
108
+
109
  @tool
110
  def wiki_search(query: str) -> str:
111
+ """Search Wikipedia for the query and return the combined content of top 2 documents.
112
+
113
+ Args:
114
+ query (str): Search query string.
115
+
116
+ Returns:
117
+ str: Combined content of top 2 Wikipedia documents separated by "---".
118
+ """
119
  docs = WikipediaLoader(query=query, load_max_docs=2).load()
120
  return "\n\n---\n\n".join([doc.page_content for doc in docs])
121
 
122
+
123
  @tool
124
  def web_search(query: str) -> str:
125
+ """Search the web using TavilySearchResults and return combined content of top 3 results.
126
+
127
+ Args:
128
+ query (str): Search query string.
129
+
130
+ Returns:
131
+ str: Combined content of top 3 web search results separated by "---".
132
+ """
133
  docs = TavilySearchResults(max_results=3).invoke(query=query)
134
  return "\n\n---\n\n".join([doc.page_content for doc in docs])
135
 
136
+
137
  @tool
138
  def arvix_search(query: str) -> str:
139
+ """Search Arxiv for the query and return combined content (up to 1000 chars) of top 3 documents.
140
+
141
+ Args:
142
+ query (str): Search query string.
143
+
144
+ Returns:
145
+ str: Combined content snippet of top 3 Arxiv documents separated by "---".
146
+ """
147
  docs = ArxivLoader(query=query, load_max_docs=3).load()
148
  return "\n\n---\n\n".join([doc.page_content[:1000] for doc in docs])
149