Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,6 +18,26 @@ 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.
|
|
@@ -55,7 +75,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 55 |
|
| 56 |
agent = CodeAgent(
|
| 57 |
model=model,
|
| 58 |
-
tools=[final_answer, get_current_time_in_timezone ], ## add your tools here (don't remove final answer)
|
| 59 |
max_steps=6,
|
| 60 |
verbosity_level=1,
|
| 61 |
grammar=None,
|
|
|
|
| 18 |
"""
|
| 19 |
return "What magic will you build ?"
|
| 20 |
|
| 21 |
+
@tool
|
| 22 |
+
def read_file(filepath: str) -> str:
|
| 23 |
+
"""A tool that reads the contents of a file.
|
| 24 |
+
Args:
|
| 25 |
+
filepath: Path to the file
|
| 26 |
+
"""
|
| 27 |
+
with open(filepath, 'r') as f:
|
| 28 |
+
return f.read()
|
| 29 |
+
|
| 30 |
+
@tool
|
| 31 |
+
def write_file(filepath: str, content: str) -> str:
|
| 32 |
+
"""A tool that writes content to a file.
|
| 33 |
+
Args:
|
| 34 |
+
filepath: Path to the file
|
| 35 |
+
content: Content to write
|
| 36 |
+
"""
|
| 37 |
+
with open(filepath, 'w') as f:
|
| 38 |
+
f.write(content)
|
| 39 |
+
return f"Content written to {filepath}"
|
| 40 |
+
|
| 41 |
@tool
|
| 42 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 43 |
"""A tool that fetches the current local time in a specified timezone.
|
|
|
|
| 75 |
|
| 76 |
agent = CodeAgent(
|
| 77 |
model=model,
|
| 78 |
+
tools=[final_answer, get_current_time_in_timezone, read_file, write_file ], ## add your tools here (don't remove final answer)
|
| 79 |
max_steps=6,
|
| 80 |
verbosity_level=1,
|
| 81 |
grammar=None,
|