lautel commited on
Commit
34c3352
·
verified ·
1 Parent(s): 8c5c24b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -1
app.py CHANGED
@@ -33,6 +33,31 @@ def get_current_time_in_timezone(timezone: str) -> str:
33
  except Exception as e:
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  final_answer = FinalAnswerTool()
38
 
@@ -55,7 +80,7 @@ with open("prompts.yaml", 'r') as stream:
55
 
56
  agent = CodeAgent(
57
  model=model,
58
- tools=[final_answer], ## add your tools here (don't remove final answer)
59
  max_steps=6,
60
  verbosity_level=1,
61
  grammar=None,
 
33
  except Exception as e:
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
36
+ @tool
37
+ def get_random_dog_info():
38
+ """
39
+ Fetches a random dog image and fact from dogapi.dog.
40
+
41
+ Returns:
42
+ A dictionary with the dog image URL and a dog fact.
43
+ """
44
+ base_url = "https://dogapi.dog/api/v2"
45
+
46
+ try:
47
+ # Get random fact
48
+ fact_response = requests.get(f"{base_url}/facts")
49
+ fact_response.raise_for_status()
50
+ fact = fact_response.json()['data'][0]['attributes']['body']
51
+
52
+ return {
53
+ "image_url": image_url,
54
+ "fact": fact
55
+ }
56
+
57
+ except requests.RequestException as e:
58
+ print("API call failed:", e)
59
+ return None
60
+
61
 
62
  final_answer = FinalAnswerTool()
63
 
 
80
 
81
  agent = CodeAgent(
82
  model=model,
83
+ tools=[get_random_dog_info, image_generation_tool, final_answer], ## add your tools here (don't remove final answer)
84
  max_steps=6,
85
  verbosity_level=1,
86
  grammar=None,