mause123
commited on
Commit
·
a2bd2ee
1
Parent(s):
ce370fe
Add missing math tools: sqrt, power, absolute - fixes tool validation errors
Browse files
agent.py
CHANGED
|
@@ -69,13 +69,44 @@ def divide(a: int, b: int) -> int:
|
|
| 69 |
@tool
|
| 70 |
def modulus(a: int, b: int) -> int:
|
| 71 |
"""Get the modulus of two numbers.
|
| 72 |
-
|
| 73 |
Args:
|
| 74 |
a: first int
|
| 75 |
b: second int
|
| 76 |
"""
|
| 77 |
return a % b
|
| 78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
@tool
|
| 80 |
def wiki_search(query: str) -> str:
|
| 81 |
"""Search Wikipedia for a query and return maximum 2 results.
|
|
@@ -155,6 +186,9 @@ tools = [
|
|
| 155 |
subtract,
|
| 156 |
divide,
|
| 157 |
modulus,
|
|
|
|
|
|
|
|
|
|
| 158 |
wiki_search,
|
| 159 |
web_search,
|
| 160 |
arvix_search,
|
|
|
|
| 69 |
@tool
|
| 70 |
def modulus(a: int, b: int) -> int:
|
| 71 |
"""Get the modulus of two numbers.
|
| 72 |
+
|
| 73 |
Args:
|
| 74 |
a: first int
|
| 75 |
b: second int
|
| 76 |
"""
|
| 77 |
return a % b
|
| 78 |
|
| 79 |
+
@tool
|
| 80 |
+
def sqrt(a: float) -> float:
|
| 81 |
+
"""Calculate the square root of a number.
|
| 82 |
+
|
| 83 |
+
Args:
|
| 84 |
+
a: number to find square root of
|
| 85 |
+
"""
|
| 86 |
+
import math
|
| 87 |
+
if a < 0:
|
| 88 |
+
raise ValueError("Cannot calculate square root of negative number.")
|
| 89 |
+
return math.sqrt(a)
|
| 90 |
+
|
| 91 |
+
@tool
|
| 92 |
+
def power(a: float, b: float) -> float:
|
| 93 |
+
"""Calculate a number raised to a power (a^b).
|
| 94 |
+
|
| 95 |
+
Args:
|
| 96 |
+
a: base number
|
| 97 |
+
b: exponent
|
| 98 |
+
"""
|
| 99 |
+
return a ** b
|
| 100 |
+
|
| 101 |
+
@tool
|
| 102 |
+
def absolute(a: float) -> float:
|
| 103 |
+
"""Get the absolute value of a number.
|
| 104 |
+
|
| 105 |
+
Args:
|
| 106 |
+
a: number to get absolute value of
|
| 107 |
+
"""
|
| 108 |
+
return abs(a)
|
| 109 |
+
|
| 110 |
@tool
|
| 111 |
def wiki_search(query: str) -> str:
|
| 112 |
"""Search Wikipedia for a query and return maximum 2 results.
|
|
|
|
| 186 |
subtract,
|
| 187 |
divide,
|
| 188 |
modulus,
|
| 189 |
+
sqrt,
|
| 190 |
+
power,
|
| 191 |
+
absolute,
|
| 192 |
wiki_search,
|
| 193 |
web_search,
|
| 194 |
arvix_search,
|