Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,15 +9,23 @@ from Gradio_UI import GradioUI
|
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
@tool
|
| 12 |
-
def
|
| 13 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 14 |
-
"""A tool that
|
| 15 |
Args:
|
| 16 |
-
|
| 17 |
-
arg2: the second argument
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
|
|
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 23 |
"""A tool that fetches the current local time in a specified timezone.
|
|
@@ -32,7 +40,7 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 32 |
return f"The current local time in {timezone} is: {local_time}"
|
| 33 |
except Exception as e:
|
| 34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 35 |
-
|
| 36 |
|
| 37 |
final_answer = FinalAnswerTool()
|
| 38 |
|
|
@@ -55,7 +63,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 55 |
|
| 56 |
agent = CodeAgent(
|
| 57 |
model=model,
|
| 58 |
-
tools=[final_answer], ## add your tools here (don't remove final answer)
|
| 59 |
max_steps=6,
|
| 60 |
verbosity_level=1,
|
| 61 |
grammar=None,
|
|
|
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
@tool
|
| 12 |
+
def create_new_valentines_day_card(theme:str): #it's import to specify the return type
|
| 13 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 14 |
+
"""A tool that generates a custom Valentine's Day card based on a given theme.
|
| 15 |
Args:
|
| 16 |
+
theme: A string representing the theme for the Valentine's Day card.
|
|
|
|
| 17 |
"""
|
| 18 |
+
try:
|
| 19 |
+
imageGenTool = Tool.from_space(
|
| 20 |
+
"black-forest-labs/FLUX.1-schnell",
|
| 21 |
+
name = "image generator",
|
| 22 |
+
description = "Generate image from prompt"
|
| 23 |
+
)
|
| 24 |
+
imageGenTool(theme)
|
| 25 |
+
except Exception as e:
|
| 26 |
+
return f"Error creating image for theme '{theme}': {str(e)}"
|
| 27 |
|
| 28 |
+
'''
|
| 29 |
@tool
|
| 30 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 31 |
"""A tool that fetches the current local time in a specified timezone.
|
|
|
|
| 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 |
|
|
|
|
| 63 |
|
| 64 |
agent = CodeAgent(
|
| 65 |
model=model,
|
| 66 |
+
tools=[create_new_valentines_day_card, final_answer], ## add your tools here (don't remove final answer)
|
| 67 |
max_steps=6,
|
| 68 |
verbosity_level=1,
|
| 69 |
grammar=None,
|