Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -11,56 +11,66 @@ from Gradio_UI import GradioUI
|
|
11 |
|
12 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
13 |
@tool
|
14 |
-
def destiny_still_arrives(name:str,
|
15 |
-
#Keep this format for the description / args / args description but feel free to modify the tool
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
-
# month = datetime.strptime(age_or_dob, "%Y-%m-%d").strftime("%B")
|
38 |
-
# birthstone = birthstones.get(month, "Unknown")
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
# return f"Hello {name}, your birthstone is {birthstone}!"
|
60 |
-
# else:
|
61 |
-
# return f"Hello {name}, we could not determine your birthstone."
|
62 |
|
63 |
-
return
|
64 |
|
65 |
@tool
|
66 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
11 |
|
12 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
13 |
@tool
|
14 |
+
def destiny_still_arrives(name:str, dob:str)-> str: #it's import to specify the return type
|
15 |
+
# Keep this format for the description / args / args description but feel free to modify the tool
|
16 |
+
"""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.
|
17 |
+
Args:
|
18 |
+
name: A string representing a person's age
|
19 |
+
age_or_dob: A string representing a person's age or date of birth
|
20 |
+
"""
|
21 |
+
def get_birthstone(name: str, dob: str):
|
22 |
+
birthstones = {
|
23 |
+
"January": "Garnet",
|
24 |
+
"February": "Amethyst",
|
25 |
+
"March": "Aquamarine",
|
26 |
+
"April": "Diamond",
|
27 |
+
"May": "Emerald",
|
28 |
+
"June": "Pearl",
|
29 |
+
"July": "Ruby",
|
30 |
+
"August": "Peridot",
|
31 |
+
"September": "Sapphire",
|
32 |
+
"October": "Opal",
|
33 |
+
"November": "Topaz",
|
34 |
+
"December": "Turquoise"
|
35 |
+
}
|
36 |
+
|
37 |
+
month = datetime.strptime(dob, "%Y-%m-%d").strftime("%B")
|
38 |
+
birthstone = birthstones.get(month, "Unknown")
|
39 |
+
|
40 |
+
model = HfApiModel(
|
41 |
+
max_tokens=2096,
|
42 |
+
temperature=0.5,
|
43 |
+
model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
|
44 |
+
custom_role_conversions=None,
|
45 |
+
)
|
46 |
|
|
|
|
|
47 |
|
48 |
+
# Import tool from Hub
|
49 |
+
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
50 |
+
|
51 |
+
with open("prompts.yaml", 'r') as stream:
|
52 |
+
prompt_templates = yaml.safe_load(stream)
|
53 |
+
|
54 |
+
agent = CodeAgent(
|
55 |
+
model=model,
|
56 |
+
tools=[final_answer,image_generation_tool], ## add your tools here (don't remove final answer)
|
57 |
+
max_steps=6,
|
58 |
+
verbosity_level=1,
|
59 |
+
grammar=None,
|
60 |
+
planning_interval=None,
|
61 |
+
name=None,
|
62 |
+
description=None,
|
63 |
+
prompt_templates=prompt_templates
|
64 |
+
)
|
65 |
+
|
66 |
+
|
67 |
|
68 |
+
if birthstone in image_urls:
|
69 |
+
response = agent.run(f"Generate an image of the following birthstone: {birthstone}")
|
70 |
+
else:
|
71 |
+
response = agent.run("Generate an image of the following birthstone: Sapphire")
|
|
|
|
|
|
|
72 |
|
73 |
+
return response
|
74 |
|
75 |
@tool
|
76 |
def get_current_time_in_timezone(timezone: str) -> str:
|