Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,16 +7,66 @@ 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 !
|
| 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 |
-
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -55,7 +105,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 55 |
|
| 56 |
agent = CodeAgent(
|
| 57 |
model=model,
|
| 58 |
-
tools=[final_answer, get_current_time_in_timezone,image_generation_tool
|
| 59 |
max_steps=6,
|
| 60 |
verbosity_level=1,
|
| 61 |
grammar=None,
|
|
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
+
class Destiny:
|
| 11 |
+
def __init__(self, name, dob):
|
| 12 |
+
self.name = name
|
| 13 |
+
self.dob = dob
|
| 14 |
+
def birth_stones(self.dob):
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
|
| 18 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 19 |
@tool
|
| 20 |
+
def destiny_still_arrives(name:str, age_or_dob:str)-> str: #it's import to specify the return type
|
| 21 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 22 |
+
"""A tool that takes a name, age or date of birth as input. It outputs the meaning of the name, an image of that person's birthstone and a horoscope reading of the day.
|
| 23 |
Args:
|
| 24 |
+
name: A string representing a person's age
|
| 25 |
+
age_or_dob: A string representing a person's age or date of birth
|
| 26 |
"""
|
| 27 |
+
def get_birthstone(name: str, age_or_dob: str):
|
| 28 |
+
birthstones = {
|
| 29 |
+
"January": "Garnet",
|
| 30 |
+
"February": "Amethyst",
|
| 31 |
+
"March": "Aquamarine",
|
| 32 |
+
"April": "Diamond",
|
| 33 |
+
"May": "Emerald",
|
| 34 |
+
"June": "Pearl",
|
| 35 |
+
"July": "Ruby",
|
| 36 |
+
"August": "Peridot",
|
| 37 |
+
"September": "Sapphire",
|
| 38 |
+
"October": "Opal",
|
| 39 |
+
"November": "Topaz",
|
| 40 |
+
"December": "Turquoise"
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
month = datetime.strptime(dob, "%Y-%m-%d").strftime("%B")
|
| 44 |
+
birthstone = birthstones.get(month, "Unknown")
|
| 45 |
+
|
| 46 |
+
image_urls = {
|
| 47 |
+
"Garnet": "https://upload.wikimedia.org/wikipedia/commons/1/12/Garnet_rough.jpg",
|
| 48 |
+
"Amethyst": "https://upload.wikimedia.org/wikipedia/commons/8/8b/Amethyst.jpg",
|
| 49 |
+
"Aquamarine": "https://upload.wikimedia.org/wikipedia/commons/d/d5/Aquamarine_Brazil.jpg",
|
| 50 |
+
"Diamond": "https://upload.wikimedia.org/wikipedia/commons/a/a7/Loose_diamond.png",
|
| 51 |
+
"Emerald": "https://upload.wikimedia.org/wikipedia/commons/4/4f/Emerald.jpg",
|
| 52 |
+
"Pearl": "https://upload.wikimedia.org/wikipedia/commons/1/17/Pearl_macro.jpg",
|
| 53 |
+
"Ruby": "https://upload.wikimedia.org/wikipedia/commons/0/0d/Ruby.jpg",
|
| 54 |
+
"Peridot": "https://upload.wikimedia.org/wikipedia/commons/8/8a/Peridot.jpg",
|
| 55 |
+
"Sapphire": "https://upload.wikimedia.org/wikipedia/commons/3/35/Sapphire.jpg",
|
| 56 |
+
"Opal": "https://upload.wikimedia.org/wikipedia/commons/2/2f/Opal_macro.jpg",
|
| 57 |
+
"Topaz": "https://upload.wikimedia.org/wikipedia/commons/5/56/Topaz.jpg",
|
| 58 |
+
"Turquoise": "https://upload.wikimedia.org/wikipedia/commons/d/d6/Turquoise.jpg"
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
if birthstone in image_urls:
|
| 62 |
+
response = requests.get(image_urls[birthstone])
|
| 63 |
+
img = Image.open(BytesIO(response.content))
|
| 64 |
+
img.show()
|
| 65 |
+
return f"Hello {name}, your birthstone is {birthstone}!"
|
| 66 |
+
else:
|
| 67 |
+
return f"Hello {name}, we could not determine your birthstone."
|
| 68 |
+
|
| 69 |
+
return get_birthstone
|
| 70 |
|
| 71 |
@tool
|
| 72 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 105 |
|
| 106 |
agent = CodeAgent(
|
| 107 |
model=model,
|
| 108 |
+
tools=[final_answer, get_current_time_in_timezone,image_generation_tool,destiny_still_arrives], ## add your tools here (don't remove final answer)
|
| 109 |
max_steps=6,
|
| 110 |
verbosity_level=1,
|
| 111 |
grammar=None,
|