Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -31,30 +31,17 @@ def search_images_for_presentation(query: str) -> str:
|
|
| 31 |
return image_path
|
| 32 |
|
| 33 |
|
| 34 |
-
|
| 35 |
-
def save_image_from_browser(
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
image_path = f"{image_dir}/captured_image_{current_step}.png"
|
| 46 |
-
|
| 47 |
-
# Save image locally
|
| 48 |
-
image.save(image_path)
|
| 49 |
-
print(f"Captured and saved an image: {image_path}")
|
| 50 |
-
|
| 51 |
-
memory_step.observations_images = [image.copy()]
|
| 52 |
-
|
| 53 |
-
# Update observations with the current URL for reference:
|
| 54 |
-
url_info = f"Current url: {driver.current_url}"
|
| 55 |
-
memory_step.observations = (
|
| 56 |
-
url_info if memory_step.observations is None else memory_step.observations + "\n" + url_info
|
| 57 |
-
)
|
| 58 |
return image_path
|
| 59 |
|
| 60 |
|
|
|
|
| 31 |
return image_path
|
| 32 |
|
| 33 |
|
| 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 |
|