-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtools.py
More file actions
73 lines (71 loc) · 2.29 KB
/
Copy pathtools.py
File metadata and controls
73 lines (71 loc) · 2.29 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
from run_bash import run_bash
from read_file import read_file
from write_file import write_file
from str_replace import str_replace
TOOL_MAP = {
"bash": lambda args: run_bash(args["command"]),
"read_file": lambda args: read_file(args["path"]),
"write_file": lambda args: write_file(args["path"], args["content"]),
"str_replace": lambda args: str_replace(args["path"], args["old_str"], args["new_str"]),
}
TOOL_DEFINITIONS = [
{
"type": "function",
"function": {
"name": "bash",
"description": "Runs a bash command inside a container.",
"parameters": {
"type": "object",
"properties": {
"command": {"type": "string"}
},
"required": ["command"]
},
},
},
{
"type": "function",
"function": {
"name": "read_file",
"description": "Reads a file using cat.",
"parameters": {
"type": "object",
"properties": {
"path": {"type": "string"}
},
"required": ["path"]
},
},
},
{
"type": "function",
"function": {
"name": "write_file",
"description": "Writes content to a file and creates it and its parent directories if they do not exist yet. Prefer str_replace for editing.",
"parameters": {
"type": "object",
"properties": {
"path": {"type": "string"},
"content": {"type": "string"}
},
"required": ["path", "content"]
},
},
},
{
"type": "function",
"function": {
"name": "str_replace",
"description": "Replaces a string in a file. String must start and end at line boundaries. More efficient for small changes in big files.",
"parameters": {
"type": "object",
"properties": {
"path": {"type": "string"},
"old_str": {"type": "string"},
"new_str": {"type": "string"},
},
"required": ["path", "old_str", "new_str"]
},
},
},
]