Update app.py
#96
by
i03fesea
- opened
app.py
CHANGED
|
@@ -4,7 +4,7 @@ import requests
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
-
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
|
@@ -33,6 +33,25 @@ 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 |
|
|
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
+
from PIL import Image
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
|
|
|
| 33 |
except Exception as e:
|
| 34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 35 |
|
| 36 |
+
@tool
|
| 37 |
+
def get_image_from_description(description: str) -> str:
|
| 38 |
+
"""A tool that fetches and displays an image based on a description.
|
| 39 |
+
Args:
|
| 40 |
+
description: A string describing the image to generate.
|
| 41 |
+
"""
|
| 42 |
+
image_generation_tool = Tool.from_space(
|
| 43 |
+
"black-forest-labs/FLUX.1-dev",
|
| 44 |
+
name="image_generator",
|
| 45 |
+
description="Generate an image from a prompt")
|
| 46 |
+
image_obj = image_generation_tool(description)
|
| 47 |
+
if hasattr(image_obj, "_path"):
|
| 48 |
+
image_path = image_obj._path
|
| 49 |
+
image = Image.open(image_path)
|
| 50 |
+
image.show()
|
| 51 |
+
return "Image displayed."
|
| 52 |
+
else:
|
| 53 |
+
return "Unexpected output: " + str(image_obj)
|
| 54 |
+
|
| 55 |
|
| 56 |
final_answer = FinalAnswerTool()
|
| 57 |
|