Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -40,7 +40,21 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 40 |
return f"The current local time in {timezone} is: {local_time}"
|
| 41 |
except Exception as e:
|
| 42 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
|
|
|
|
|
|
| 44 |
|
| 45 |
final_answer = FinalAnswerTool()
|
| 46 |
|
|
@@ -55,8 +69,7 @@ custom_role_conversions=None,
|
|
| 55 |
)
|
| 56 |
|
| 57 |
|
| 58 |
-
|
| 59 |
-
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 60 |
|
| 61 |
with open("prompts.yaml", 'r') as stream:
|
| 62 |
prompt_templates = yaml.safe_load(stream)
|
|
|
|
| 40 |
return f"The current local time in {timezone} is: {local_time}"
|
| 41 |
except Exception as e:
|
| 42 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 43 |
+
|
| 44 |
+
# Import tool from Hub
|
| 45 |
+
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 46 |
+
|
| 47 |
+
@tool
|
| 48 |
+
def text_to_image(text: str) -> image:
|
| 49 |
+
"""A tool that takes string and creates image with textual information.
|
| 50 |
+
Args:
|
| 51 |
+
text: A string representing the textual information about the image to be created.
|
| 52 |
+
"""
|
| 53 |
+
try :
|
| 54 |
+
return image_generation_tool(text)
|
| 55 |
|
| 56 |
+
except Exception as e:
|
| 57 |
+
return "Error creating the image"
|
| 58 |
|
| 59 |
final_answer = FinalAnswerTool()
|
| 60 |
|
|
|
|
| 69 |
)
|
| 70 |
|
| 71 |
|
| 72 |
+
|
|
|
|
| 73 |
|
| 74 |
with open("prompts.yaml", 'r') as stream:
|
| 75 |
prompt_templates = yaml.safe_load(stream)
|