Spaces:
Runtime error
Runtime error
fix index error
Browse files
app.py
CHANGED
@@ -235,9 +235,9 @@ def alter_body(old_code, func_id, funcs_list: list, prompt="", temperature=0.2,
|
|
235 |
func_start_idx = line_chr2char(old_code, func_node.start_point[0], func_node.start_point[1])
|
236 |
identifier_str = func_node.child_by_field_name("type").text.decode() + " " + func_node.child_by_field_name("declarator").text.decode() #func_start_idx:body_start_idx?
|
237 |
body_node = func_node.child_by_field_name("body")
|
238 |
-
body_start_idx, body_end_idx = node_str_idx(body_node)
|
239 |
-
|
240 |
-
|
241 |
print(f"{old_code[body_start_idx:body_end_idx]=}")
|
242 |
model_context = identifier_str # base case
|
243 |
# add any comments at the beginning of the function to the model_context
|
|
|
235 |
func_start_idx = line_chr2char(old_code, func_node.start_point[0], func_node.start_point[1])
|
236 |
identifier_str = func_node.child_by_field_name("type").text.decode() + " " + func_node.child_by_field_name("declarator").text.decode() #func_start_idx:body_start_idx?
|
237 |
body_node = func_node.child_by_field_name("body")
|
238 |
+
# body_start_idx, body_end_idx = node_str_idx(body_node) #can cause index error, needs better testing!
|
239 |
+
body_start_idx = line_chr2char(old_code, body_node.start_point[0], body_node.start_point[1])
|
240 |
+
body_end_idx = line_chr2char(old_code, body_node.end_point[0], body_node.end_point[1])
|
241 |
print(f"{old_code[body_start_idx:body_end_idx]=}")
|
242 |
model_context = identifier_str # base case
|
243 |
# add any comments at the beginning of the function to the model_context
|