Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,18 +16,19 @@ def dog_average_longevity(breed: str) -> str:
|
|
| 16 |
breed: a string representing the name of the dog breed.
|
| 17 |
"""
|
| 18 |
#return "A string stating the average lifespan of the dog breed in years."
|
| 19 |
-
|
|
|
|
| 20 |
|
| 21 |
-
|
| 22 |
results = list(ddgs.text(query, max_results=5))
|
| 23 |
|
| 24 |
-
|
| 25 |
for result in results:
|
| 26 |
lifespan = extract_lifespan(result)
|
| 27 |
if lifespan:
|
| 28 |
return f"The average lifespan of a {breed} dog is {lifespan} years."
|
| 29 |
|
| 30 |
-
|
| 31 |
|
| 32 |
@tool
|
| 33 |
def extract_lifespan(text: str) -> Optional[str]:
|
|
|
|
| 16 |
breed: a string representing the name of the dog breed.
|
| 17 |
"""
|
| 18 |
#return "A string stating the average lifespan of the dog breed in years."
|
| 19 |
+
|
| 20 |
+
query = f"average lifespan for {breed} dog in years"
|
| 21 |
|
| 22 |
+
with DDGS() as ddgs:
|
| 23 |
results = list(ddgs.text(query, max_results=5))
|
| 24 |
|
| 25 |
+
if results:
|
| 26 |
for result in results:
|
| 27 |
lifespan = extract_lifespan(result)
|
| 28 |
if lifespan:
|
| 29 |
return f"The average lifespan of a {breed} dog is {lifespan} years."
|
| 30 |
|
| 31 |
+
return "No reliable lifespan information found. Please check with a veterinarian."
|
| 32 |
|
| 33 |
@tool
|
| 34 |
def extract_lifespan(text: str) -> Optional[str]:
|