Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,16 +9,16 @@ from Gradio_UI import GradioUI
|
|
| 9 |
|
| 10 |
#my first try
|
| 11 |
@tool
|
| 12 |
-
def dog_average_longevity(
|
| 13 |
"""A tool that uses DuckDuckGo to search the web and find the average lifespan in years for a given dog breed.
|
| 14 |
|
| 15 |
Tool name : dog_average_longevity
|
| 16 |
Args:
|
| 17 |
-
arg1:
|
| 18 |
|
| 19 |
return : The extracted average lifespan of a dog breed in years or a fallback message.
|
| 20 |
"""
|
| 21 |
-
query = f"average lifespan for {
|
| 22 |
|
| 23 |
with DDGS() as ddgs:
|
| 24 |
results = list(ddgs.text(query, max_results=5))
|
|
@@ -27,7 +27,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 |
|
|
|
|
| 9 |
|
| 10 |
#my first try
|
| 11 |
@tool
|
| 12 |
+
def dog_average_longevity(breed: str)-> str:
|
| 13 |
"""A tool that uses DuckDuckGo to search the web and find the average lifespan in years for a given dog breed.
|
| 14 |
|
| 15 |
Tool name : dog_average_longevity
|
| 16 |
Args:
|
| 17 |
+
arg1: breed : a string representing the name of the dog breed.
|
| 18 |
|
| 19 |
return : The extracted average lifespan of a dog breed in years or a fallback message.
|
| 20 |
"""
|
| 21 |
+
query = f"average lifespan for {breed} dog in years"
|
| 22 |
|
| 23 |
with DDGS() as ddgs:
|
| 24 |
results = list(ddgs.text(query, max_results=5))
|
|
|
|
| 27 |
for result in results:
|
| 28 |
lifespan = extract_lifespan(result)
|
| 29 |
if lifespan:
|
| 30 |
+
return f"The average lifespan of a {breed} dog is {lifespan} years."
|
| 31 |
|
| 32 |
return "No reliable lifespan information found. Please check with a veterinarian."
|
| 33 |
|