Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,18 +10,34 @@ from tools.final_answer import FinalAnswerTool
|
|
| 10 |
from Gradio_UI import GradioUI
|
| 11 |
|
| 12 |
@tool
|
| 13 |
-
def get_roots(a:
|
| 14 |
-
|
| 15 |
-
|
| 16 |
Args:
|
| 17 |
-
a:
|
| 18 |
-
b:
|
| 19 |
-
c:
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
@tool
|
| 27 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 10 |
from Gradio_UI import GradioUI
|
| 11 |
|
| 12 |
@tool
|
| 13 |
+
def get_roots(a: float, b: float, c: float) -> Tuple[float, float]:
|
| 14 |
+
"""Compute the real roots of a quadratic equation ax^2 + bx + c = 0.
|
| 15 |
+
|
| 16 |
Args:
|
| 17 |
+
a: Quadratic coefficient (must be non-zero).
|
| 18 |
+
b: Linear coefficient.
|
| 19 |
+
c: Constant term.
|
| 20 |
+
|
| 21 |
+
Returns:
|
| 22 |
+
A tuple (x1, x2) containing the two real roots.
|
| 23 |
+
|
| 24 |
+
Raises:
|
| 25 |
+
ValueError: If a == 0 or the discriminant is negative (no real roots).
|
| 26 |
+
"""
|
| 27 |
+
if a == 0:
|
| 28 |
+
raise ValueError("Coefficient 'a' must be non-zero for a quadratic equation.")
|
| 29 |
+
|
| 30 |
+
discriminant = b * b - 4 * a * c
|
| 31 |
+
if discriminant < 0:
|
| 32 |
+
raise ValueError(
|
| 33 |
+
f"Discriminant is negative ({discriminant}); equation has no real roots."
|
| 34 |
+
)
|
| 35 |
+
|
| 36 |
+
sqrt_disc = math.sqrt(discriminant)
|
| 37 |
+
denom = 2 * a
|
| 38 |
+
x1 = (-b + sqrt_disc) / denom
|
| 39 |
+
x2 = (-b - sqrt_disc) / denom
|
| 40 |
+
return (x1, x2)
|
| 41 |
|
| 42 |
@tool
|
| 43 |
def get_current_time_in_timezone(timezone: str) -> str:
|