Update app.py
Browse files
app.py
CHANGED
|
@@ -18,16 +18,26 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
|
|
| 18 |
return "What magic will you build ?"
|
| 19 |
|
| 20 |
@tool
|
| 21 |
-
def
|
| 22 |
"""Generates an image based on the provided prompt using the image generation tool.
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
try:
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
@tool
|
| 33 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 18 |
return "What magic will you build ?"
|
| 19 |
|
| 20 |
@tool
|
| 21 |
+
def generate_image_with_prompt(prompt: str) -> str:
|
| 22 |
"""Generates an image based on the provided prompt using the image generation tool.
|
| 23 |
+
Args:
|
| 24 |
+
prompt: A textual description for the image to be generated.
|
| 25 |
+
"""
|
| 26 |
try:
|
| 27 |
+
image_url = image_generation_tool.run(prompt)
|
| 28 |
+
return f"Here's your generated image: {image_url}"
|
| 29 |
+
except Exception as e:
|
| 30 |
+
return f"Error generating image: {str(e)}"
|
| 31 |
+
|
| 32 |
+
@tool
|
| 33 |
+
def random_fact() -> str:
|
| 34 |
+
"""Fetches a random fun fact."""
|
| 35 |
+
facts = [
|
| 36 |
+
"Honey never spoils.",
|
| 37 |
+
"Octopuses have three hearts.",
|
| 38 |
+
"Bananas are berries, but strawberries are not."
|
| 39 |
+
]
|
| 40 |
+
return random.choice(facts)
|
| 41 |
|
| 42 |
@tool
|
| 43 |
def get_current_time_in_timezone(timezone: str) -> str:
|