24Arys11 commited on
Commit
9144b12
·
verified ·
1 Parent(s): ae7a494

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -1
app.py CHANGED
@@ -18,6 +18,33 @@ 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 +82,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,
 
18
  """
19
  return "What magic will you build ?"
20
 
21
+ @tool
22
+ def inspect_directory(directory: str, prefix: str = '') -> str:
23
+ """
24
+ A tool that generates a visual tree structure of the directory contents.
25
+
26
+ Args:
27
+ directory (str): The path to the directory to inspect.
28
+ prefix (str): The prefix string used for formatting the tree structure.
29
+
30
+ Returns:
31
+ str: A string representing the tree structure of the directory.
32
+ """
33
+ tree_str = ''
34
+ contents = os.listdir(directory)
35
+ directories = sorted([d for d in contents if os.path.isdir(os.path.join(directory, d))], key=str.lower)
36
+ files = sorted([f for f in contents if os.path.isfile(os.path.join(directory, f))], key=str.lower)
37
+ contents = directories + files
38
+ pointers = [contents[-1]]
39
+ for content in contents:
40
+ pointer = '└── ' if content == pointers[0] else '├── '
41
+ tree_str += prefix + pointer + content + '\n'
42
+ path = os.path.join(directory, content)
43
+ if os.path.isdir(path):
44
+ extension = ' ' if content == pointers[0] else '│ '
45
+ tree_str += inspect_directory(path, prefix=prefix + extension)
46
+ return tree_str
47
+
48
  @tool
49
  def get_current_time_in_timezone(timezone: str) -> str:
50
  """A tool that fetches the current local time in a specified timezone.
 
82
 
83
  agent = CodeAgent(
84
  model=model,
85
+ tools=[inspect_directory, final_answer], ## add your tools here (don't remove final answer)
86
  max_steps=6,
87
  verbosity_level=1,
88
  grammar=None,