Repository navigation
Expand file tree
/
Copy path__init__.py
More file actions
57 lines (54 loc) · 1.88 KB
/
Copy path__init__.py
File metadata and controls
57 lines (54 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from .tool_definition import ToolDefinition
from .file_operations import read_file_from_path, list_files_from_path, edit_file
read_file_tool = ToolDefinition(
name="read_file",
description="Read the contents of a file",
parameters={
"type": "object",
"properties": {
"file_path": {
"type": "string",
"description": "Path to the file to read"
}
},
"required": ["file_path"]
},
function_to_call=read_file_from_path
)
list_files_tool = ToolDefinition(
name="list_files",
description="List files and directories at a given path. If no path is provided, lists files in the current directory.",
parameters={
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "Optional relative path to list files from. Defaults to current directory if not provided."
}
}
},
function_to_call=list_files_from_path
)
edit_file_tool = ToolDefinition(
name="edit_file",
description="Make edits to a text file. Replaces 'old_str' with 'new_str' in the given file. 'old_str' and 'new_str' MUST be different from each other. If the file specified with path doesn't exist, it will be created.",
parameters={
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "The path to the file"
},
"old_str": {
"type": "string",
"description": "Text to search for - must match exactly and must only have one match exactly"
},
"new_str": {
"type": "string",
"description": "Text to replace old_str with"
}
},
"required": ["path", "old_str", "new_str"]
},
function_to_call=edit_file
)