Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,9 @@ import requests
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
|
@@ -34,6 +37,16 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 34 |
except Exception as e:
|
| 35 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
final_answer = FinalAnswerTool()
|
| 39 |
|
|
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
+
from PIL.Image import Image as PILImage
|
| 8 |
+
from io import BytesIO
|
| 9 |
+
import base64
|
| 10 |
|
| 11 |
from Gradio_UI import GradioUI
|
| 12 |
|
|
|
|
| 37 |
except Exception as e:
|
| 38 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 39 |
|
| 40 |
+
@tool
|
| 41 |
+
def convert_image_to_base64(image: PILImage) -> str:
|
| 42 |
+
"""A tool that you MUST use exactly after the image_generation_tool since it encodes it's output to a printable image
|
| 43 |
+
Args:
|
| 44 |
+
image: An image that is the output of the image_generation_tool and is not in printable form
|
| 45 |
+
"""
|
| 46 |
+
buffered = BytesIO()
|
| 47 |
+
image.save(buffered, format="PNG")
|
| 48 |
+
return f"data:image/png;base64,{base64.b64encode(buffered.getvalue()).decode()}"
|
| 49 |
+
|
| 50 |
|
| 51 |
final_answer = FinalAnswerTool()
|
| 52 |
|