Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,15 +10,21 @@ from tools.final_answer import FinalAnswerTool
|
|
| 10 |
from Gradio_UI import GradioUI
|
| 11 |
|
| 12 |
@tool
|
| 13 |
-
def dog_average_longevity(
|
| 14 |
-
"""
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
| 20 |
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
with DDGS() as ddgs:
|
| 24 |
results = list(ddgs.text(query, max_results=5))
|
|
@@ -27,7 +33,7 @@ def dog_average_longevity(dog_breed: str) -> str:
|
|
| 27 |
for result in results:
|
| 28 |
lifespan = extract_lifespan(result)
|
| 29 |
if lifespan:
|
| 30 |
-
return f"The average lifespan of a {
|
| 31 |
|
| 32 |
return "No reliable lifespan information found. Please check with a veterinarian."
|
| 33 |
|
|
|
|
| 10 |
from Gradio_UI import GradioUI
|
| 11 |
|
| 12 |
@tool
|
| 13 |
+
def dog_average_longevity(breed: str) -> str:
|
| 14 |
+
"""
|
| 15 |
+
Retrieves the average lifespan of a given dog breed using DuckDuckGo search.
|
| 16 |
+
|
| 17 |
+
Parameters
|
| 18 |
+
----------
|
| 19 |
+
breed : str
|
| 20 |
+
The name of the dog breed (e.g., "Labrador").
|
| 21 |
|
| 22 |
+
Returns
|
| 23 |
+
-------
|
| 24 |
+
str
|
| 25 |
+
A message stating the average lifespan of the breed, or an error message if not found.
|
| 26 |
+
"""
|
| 27 |
+
query = f"average lifespan for {breed} dog in years"
|
| 28 |
|
| 29 |
with DDGS() as ddgs:
|
| 30 |
results = list(ddgs.text(query, max_results=5))
|
|
|
|
| 33 |
for result in results:
|
| 34 |
lifespan = extract_lifespan(result)
|
| 35 |
if lifespan:
|
| 36 |
+
return f"The average lifespan of a {breed} dog is {lifespan} years."
|
| 37 |
|
| 38 |
return "No reliable lifespan information found. Please check with a veterinarian."
|
| 39 |
|