eocone commited on
Commit
a4b07ae
·
verified ·
1 Parent(s): a85f311

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -9
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(dog_breed: str) -> str:
14
- """A tool that fetches the average lifespan for a given dog breed.
15
- Parameters:
16
- dog_breed (str): The breed of the dog (e.g., "Labrador").
17
- Returns:
18
- str: The average lifespan of the specified dog breed in years.
19
- """
 
20
 
21
- query = f"average lifespan for {dog_breed} dog in years"
 
 
 
 
 
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 {dog_breed} dog is {lifespan} years."
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