BlackDragon13x commited on
Commit
f8497c0
·
verified ·
1 Parent(s): 82687d6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -35,17 +35,23 @@ def get_current_time_in_timezone(timezone: str) -> str:
35
 
36
  @tool
37
  def get_random_cat_picture() -> str:
38
- """Fetches a random cat picture URL.
39
 
40
  Returns:
41
- A URL to a random cat picture.
42
  """
43
  api_url = "https://api.thecatapi.com/v1/images/search"
44
 
45
  try:
46
  response = requests.get(api_url)
47
  data = response.json()
48
- return data[0]["url"] # Extract the image URL
 
 
 
 
 
 
49
  except Exception as e:
50
  return f"Error fetching cat image: {str(e)}"
51
 
 
35
 
36
  @tool
37
  def get_random_cat_picture() -> str:
38
+ """Fetches a random cat picture and returns it as an image.
39
 
40
  Returns:
41
+ An image of a random cat.
42
  """
43
  api_url = "https://api.thecatapi.com/v1/images/search"
44
 
45
  try:
46
  response = requests.get(api_url)
47
  data = response.json()
48
+ img_url = data[0]["url"]
49
+
50
+ # Fetch the image content
51
+ img_response = requests.get(img_url)
52
+ img = Image.open(BytesIO(img_response.content))
53
+
54
+ return img # Return the image directly
55
  except Exception as e:
56
  return f"Error fetching cat image: {str(e)}"
57