-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtools.py
More file actions
147 lines (138 loc) · 4.81 KB
/
Copy pathtools.py
File metadata and controls
147 lines (138 loc) · 4.81 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
from context import ContextTool
get_project_structure = {
"type": "function",
"function":{
"name": "get_project_structure",
"description": "Get the tree structure of the buggy project",
"parameters": {},
"strict": True
}
}
get_class_skeleton = {
"type": "function",
"function":{
"name": "get_class_skeleton",
"description": "Get brief information about a java class, including fields and method signatures.",
"parameters": {
"type": "object",
"properties": {
"class_full_qualified_name": {
"type": "string",
"description": "The full qualified name of the class, e.g., org.example.clazzA",
},
},
"required": ["class_full_qualified_name"],
},
"strict": True
}
}
get_field_type = {
"type": "function",
"function":{
"name": "get_field_type",
"description": "Get the type of a class variable",
"parameters": {
"type": "object",
"properties": {
"class_full_qualified_name": {
"type": "string",
"description": "The full qualified name of the class, e.g., org.example.clazzA",
},
"field_name": {
"type": "string",
"description": "The name of the class variable",
}
},
"required": ["class_full_qualified_name", "field_name"],
},
"strict": True
}
}
get_local_variable_type = {
"type": "function",
"function":{
"name": "get_local_variable_type",
"description": "Get the type of a local variable defined in a Java method",
"parameters": {
"type": "object",
"properties": {
"class_full_qualified_name": {
"type": "string",
"description": "The full qualified name of the class, e.g., org.example.clazzA",
},
"function_name": {
"type": "string",
"description": "The name of the Java method where the local variable is defined",
},
"var_name": {
"type": "string",
"description": "The name of the local variable",
}
},
"required": ["class_full_qualified_name", "function_name", "var_name"],
},
"strict": True
}
}
get_function_body = {
"type": "function",
"function":{
"name": "get_function_body",
"description": "Get the content of a Java method",
"parameters": {
"type": "object",
"properties": {
"class_full_qualified_name": {
"type": "string",
"description": "The full qualified name of the class, e.g., org.example.clazzA",
},
"function_name": {
"type": "string",
"description": "The name of the Java method",
}
},
"required": ["class_full_qualified_name", "function_name"],
},
"strict": True
}
}
summarize_context = {
"type": "function",
"function":{
"name": "summarize_context",
"description": "Provide the final summary of the context retrieved in previous chat history",
"parameters": {
"type": "object",
"properties": {
"summarized_context": {
"type": "string",
"description": "The final summary of the context that will be used for later bug repair",
}
},
"required": ["summarized_context"],
},
"strict": True
}
}
context_tools = [
get_project_structure,
get_class_skeleton,
get_field_type,
get_local_variable_type,
get_function_body,
summarize_context
]
def handle_tool_call(context_tool: ContextTool, name, args):
if name == 'get_project_structure':
return context_tool.get_project_structure()
elif name == 'get_class_skeleton':
return context_tool.get_class_skeleton(args['class_full_qualified_name'])
elif name == 'get_field_type':
return context_tool.get_field_type(args['class_full_qualified_name'], args['field_name'])
elif name == 'get_local_variable_type':
return context_tool.get_local_variable_type(args['class_full_qualified_name'], args['function_name'],
args['var_name'])
elif name == 'get_function_body':
return context_tool.get_function_body(args['class_full_qualified_name'], args['function_name'])
else:
raise NotImplementedError(f'no implementation for {name}')