Update - add custom die throwing tool
Browse files
app.py
CHANGED
@@ -18,6 +18,14 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
|
|
18 |
"""
|
19 |
return "What magic will you build ?"
|
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.
|
@@ -44,13 +52,9 @@ model = HfApiModel(
|
|
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) ## https://huggingface.co/spaces/agents-course/text-to-image
|
50 |
|
51 |
-
# Import other tools
|
52 |
-
visit_webpage_tool = load_tool("tools/visit_webpage.py",trust_remote_code=True)
|
53 |
-
|
54 |
with open("prompts.yaml", 'r') as stream:
|
55 |
prompt_templates = yaml.safe_load(stream)
|
56 |
|
|
|
18 |
"""
|
19 |
return "What magic will you build ?"
|
20 |
|
21 |
+
# Writing my first custom tool
|
22 |
+
@tool
|
23 |
+
def toss_a_die(k=6: int) -> int:
|
24 |
+
"""A tool to toss a k-sided die / dice and return the value showing on that die / dice.
|
25 |
+
Args:
|
26 |
+
k=6: the number of sides on the die, defaulting to 6 sides"""
|
27 |
+
return 3
|
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.
|
|
|
52 |
custom_role_conversions=None,
|
53 |
)
|
54 |
|
|
|
55 |
# Import tool from Hub
|
56 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True) ## https://huggingface.co/spaces/agents-course/text-to-image
|
57 |
|
|
|
|
|
|
|
58 |
with open("prompts.yaml", 'r') as stream:
|
59 |
prompt_templates = yaml.safe_load(stream)
|
60 |
|