palbha commited on
Commit
f6ca80d
·
verified ·
1 Parent(s): 28f431d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -4
app.py CHANGED
@@ -34,15 +34,27 @@ def search_images_for_presentation(query: str) -> str:
34
  @tool
35
  def save_image_from_browser(image_url: str) -> str:
36
  """
37
- Saves the image from the given URL to a file.
38
  Args:
39
  image_url: The URL of the image to be saved.
40
  Returns:
41
  str: The path to the saved image.
42
  """
43
- image_path = f"/path/to/save/directory/{image_url.split('/')[-1]}" # Example: use image's filename from URL
44
- # Add image download and save logic here
45
- return image_path
 
 
 
 
 
 
 
 
 
 
 
 
46
 
47
 
48
  # Initialize agent (same as before)
 
34
  @tool
35
  def save_image_from_browser(image_url: str) -> str:
36
  """
37
+ Downloads and saves the image from the given URL.
38
  Args:
39
  image_url: The URL of the image to be saved.
40
  Returns:
41
  str: The path to the saved image.
42
  """
43
+ # Download image from the URL
44
+ try:
45
+ response = requests.get(image_url)
46
+ response.raise_for_status()
47
+
48
+ # Save the image locally (you can adjust the save path as needed)
49
+ image_path = f"/path/to/save/directory/{image_url.split('/')[-1]}"
50
+ with open(image_path, "wb") as file:
51
+ file.write(response.content)
52
+
53
+ return image_path
54
+ except requests.exceptions.RequestException as e:
55
+ print(f"Error downloading image: {e}")
56
+ return None
57
+
58
 
59
 
60
  # Initialize agent (same as before)