Elffuss BraidHub

kikocis/auto-code-rover public

Fix lint
Changeset0f4e2e4e2ecbb83a8b74e1c24318b654bb5c7edf3d4960f005463465a9c7e20f
AuthorZhang Yuntong <ang.unong@gmail.com> · 2024-05-07 13:49 +08:00
CommitterZhang Yuntong <ang.unong@gmail.com> · 2024-05-07 13:49 +08:00
Parents222ea812b676

Browse the files at this changeset

7 files changed

modified app/api/agent_write_patch.py +40 −11
@@ -4,8 +4,7 @@
44
55 import json
66 import shutil
7-from typing import Callable
8-from collections.abc import Iterable
7+from collections.abc import Callable, Iterable
98 from copy import deepcopy
109 from os.path import join as pjoin
1110 from pathlib import Path
@@ -58,7 +57,7 @@
5857 output_dir: str,
5958 task: Task,
6059 retries=3,
61- print_callback: Callable[[dict], None] | None = None
60+ print_callback: Callable[[dict], None] | None = None,
6261 ) -> tuple[str, float, int, int]:
6362 """
6463 Since the agent may not always write an applicable patch, we allow for retries.
@@ -99,7 +98,9 @@
9998 with open(raw_patch_file, "w") as f:
10099 f.write(res_text)
101100
102- print_patch_generation(res_text, f"try {i} / {retries}", print_callback=print_callback)
101+ print_patch_generation(
102+ res_text, f"try {i} / {retries}", print_callback=print_callback
103+ )
103104
104105 # Attemp to extract a real patch from the raw patch
105106 diff_file = pjoin(output_dir, f"extracted_patch_{i}.diff")
@@ -112,7 +113,11 @@
112113
113114 if extract_status == ExtractStatus.APPLICABLE_PATCH:
114115 patch_content = Path(diff_file).read_text()
115- print_acr(f"```diff\n{patch_content}\n```", "extracted patch", print_callback=print_callback)
116+ print_acr(
117+ f"```diff\n{patch_content}\n```",
118+ "extracted patch",
119+ print_callback=print_callback,
120+ )
116121
117122 # patch generated is applicable and all edits are ok, so we can think about validation
118123 if globals.enable_validation:
@@ -126,7 +131,11 @@
126131 "Written a patch that resolves the issue. Congratulations!"
127132 )
128133 new_thread.add_user(result_msg) # just for logging
129- print_acr(result_msg, f"patch generation try {i} / {retries}", print_callback=print_callback)
134+ print_acr(
135+ result_msg,
136+ f"patch generation try {i} / {retries}",
137+ print_callback=print_callback,
138+ )
130139 can_stop = True
131140 # the following two branches cannot be swapped, because
132141 # --enable-perfect-angelic is meant to override --enable-angelic
@@ -147,7 +156,11 @@
147156
148157 result_msg = f"{msg}\n{angelic_msg}"
149158 new_thread.add_user(result_msg)
150- print_acr(result_msg, f"patch generation try {i} / {retries}", print_callback=print_callback)
159+ print_acr(
160+ result_msg,
161+ f"patch generation try {i} / {retries}",
162+ print_callback=print_callback,
163+ )
151164 continue
152165 elif globals.enable_angelic:
153166 raise NotImplementedError(
@@ -157,7 +170,11 @@
157170 result_msg = f"Written an applicable patch, but it did not resolve the issue. {err_message} "
158171 result_msg += " Please try again."
159172 new_thread.add_user(result_msg)
160- print_acr(result_msg, f"patch generation try {i} / {retries}", print_callback=print_callback)
173+ print_acr(
174+ result_msg,
175+ f"patch generation try {i} / {retries}",
176+ print_callback=print_callback,
177+ )
161178 continue
162179 elif globals.enable_perfect_angelic:
163180 if not isinstance(task, SweTask):
@@ -176,14 +193,22 @@
176193 result_msg = msg
177194
178195 new_thread.add_user(result_msg)
179- print_acr(result_msg, f"patch generation try {i} / {retries}", print_callback=print_callback)
196+ print_acr(
197+ result_msg,
198+ f"patch generation try {i} / {retries}",
199+ print_callback=print_callback,
200+ )
180201 continue
181202 elif globals.enable_angelic:
182203 raise NotImplementedError("Angelic debugging has not been integrated")
183204 else:
184205 result_msg = "Extracted a patch. Since validation is disabled, you should validation the patch later on. Ending the workflow."
185206 new_thread.add_user(result_msg) # just for logging
186- print_acr(result_msg, f"patch generation try {i} / {retries}", print_callback=print_callback)
207+ print_acr(
208+ result_msg,
209+ f"patch generation try {i} / {retries}",
210+ print_callback=print_callback,
211+ )
187212 can_stop = True
188213
189214 else:
@@ -194,7 +219,11 @@
194219 + " Please try again."
195220 )
196221 new_thread.add_user(new_prompt)
197- print_acr(new_prompt, f"patch generation try {i} / {retries}", print_callback=print_callback)
222+ print_acr(
223+ new_prompt,
224+ f"patch generation try {i} / {retries}",
225+ print_callback=print_callback,
226+ )
198227 result_msg = "Failed to write a valid patch."
199228
200229 return result_msg
modified app/api/manage.py +8 −7
@@ -1,8 +1,7 @@
11 import json
22 import os
33 import shutil
4-from typing import Callable
5-from collections.abc import Mapping
4+from collections.abc import Callable, Mapping
65 from copy import deepcopy
76 from os.path import join as pjoin
87 from pathlib import Path
@@ -178,9 +177,10 @@
178177 return all_tool_objs
179178
180179 def dispatch_intent(
181- self, intent: FunctionCallIntent,
180+ self,
181+ intent: FunctionCallIntent,
182182 message_thread: MessageThread,
183- print_callback:Callable[[dict], None] | None = None
183+ print_callback: Callable[[dict], None] | None = None,
184184 ) -> tuple[str, str, bool]:
185185 """Dispatch a function call intent to actually perform its action.
186186
@@ -432,9 +432,10 @@
432432 """
433433 return self.search_manager.search_code_in_file(code_str, file_name)
434434
435- def write_patch(self,
435+ def write_patch(
436+ self,
436437 message_thread: MessageThread,
437- print_callback:Callable[[dict], None] | None = None
438+ print_callback: Callable[[dict], None] | None = None,
438439 ) -> tuple[str, str, bool]:
439440 """Based on the current context, ask another agent to write a patch.
440441
@@ -447,7 +448,7 @@
447448 self.output_dir,
448449 self.task,
449450 # self.validator,
450- print_callback=print_callback
451+ print_callback=print_callback,
451452 )
452453 summary = "The tool returned the patch written by another agent."
453454 # The return status of write_patch does not really matter, so we just use True here
modified app/inference.py +50 −14
@@ -1,7 +1,7 @@
11 import inspect
22 import json
33 import re
4-from typing import Callable
4+from collections.abc import Callable
55 from os.path import join as pjoin
66 from pathlib import Path
77
@@ -73,7 +73,7 @@
7373 msg_thread: MessageThread,
7474 api_manager: ProjectApiManager,
7575 start_round_no: int = 0,
76- print_callback: Callable[[dict], None] | None = None
76+ print_callback: Callable[[dict], None] | None = None,
7777 ) -> bool:
7878 """
7979 This version uses json data to process API calls, instead of using the OpenAI function calling.
@@ -102,7 +102,11 @@
102102
103103 print_banner(f"CONTEXT RETRIEVAL ROUND {round_no}")
104104
105- print_acr(prompt, f"context retrieval round {start_round_no}", print_callback=print_callback)
105+ print_acr(
106+ prompt,
107+ f"context retrieval round {start_round_no}",
108+ print_callback=print_callback,
109+ )
106110
107111 res_text, *_ = common.SELECTED_MODEL.call(msg_thread.to_msg())
108112 msg_thread.add_model(res_text, tools=[])
@@ -117,7 +121,11 @@
117121 if selected_apis is None:
118122 msg = "The search API calls seem not valid. Please check the arguments you give carefully and try again."
119123 msg_thread.add_user(msg)
120- print_acr(msg, f"context retrieval round {round_no}", print_callback=print_callback)
124+ print_acr(
125+ msg,
126+ f"context retrieval round {round_no}",
127+ print_callback=print_callback,
128+ )
121129 continue
122130
123131 selected_apis_json = json.loads(selected_apis)
@@ -137,7 +145,11 @@
137145 s = ", ".join(f"{k}: `{v}`" for k, v in location.items())
138146 formatted.extend([f"\n- {s}"])
139147
140- print_acr("\n".join(formatted), "Agent-selected API calls", print_callback=print_callback)
148+ print_acr(
149+ "\n".join(formatted),
150+ "Agent-selected API calls",
151+ print_callback=print_callback,
152+ )
141153
142154 # collected enough information to write patch
143155 if buggy_locations and (not json_api_calls):
@@ -157,12 +169,20 @@
157169
158170 print_banner("PATCH GENERATION")
159171 logger.debug("Gathered enough information. Invoking write_patch.")
160- print_acr(collated_tool_response, "patch generation round 1", print_callback=print_callback)
172+ print_acr(
173+ collated_tool_response,
174+ "patch generation round 1",
175+ print_callback=print_callback,
176+ )
161177 break
162178
163179 msg = "The buggy locations is not precise. You may need to check whether the arguments are correct and search more information."
164180 msg_thread.add_user(msg)
165- print_acr(msg, f"context retrieval round {round_no}", print_callback=print_callback)
181+ print_acr(
182+ msg,
183+ f"context retrieval round {round_no}",
184+ print_callback=print_callback,
185+ )
166186 continue
167187
168188 # prepare response from tools
@@ -186,11 +206,17 @@
186206 collated_tool_response += tool_output + "\n\n"
187207
188208 msg_thread.add_user(collated_tool_response)
189- print_acr(collated_tool_response, f"context retrieval round {round_no}", print_callback=print_callback)
209+ print_acr(
210+ collated_tool_response,
211+ f"context retrieval round {round_no}",
212+ print_callback=print_callback,
213+ )
190214
191215 msg = "Let's analyze collected context first"
192216 msg_thread.add_user(msg)
193- print_acr(msg, f"context retrieval round {round_no}", print_callback=print_callback)
217+ print_acr(
218+ msg, f"context retrieval round {round_no}", print_callback=print_callback
219+ )
194220
195221 res_text, *_ = common.SELECTED_MODEL.call(msg_thread.to_msg())
196222 msg_thread.add_model(res_text, tools=[])
@@ -206,7 +232,11 @@
206232 # llama models tend to always output search APIs and buggy locations.
207233 msg += "\n\nNOTE: If you have already identified the bug locations, do not make any search API calls."
208234 msg_thread.add_user(msg)
209- print_acr(msg, f"context retrieval round {round_no}", print_callback=print_callback)
235+ print_acr(
236+ msg,
237+ f"context retrieval round {round_no}",
238+ print_callback=print_callback,
239+ )
210240 else:
211241 logger.info("Too many rounds. Try writing patch anyway.")
212242
@@ -215,7 +245,9 @@
215245 api_manager.start_new_tool_call_layer()
216246
217247 write_patch_intent = FunctionCallIntent("write_patch", {}, None)
218- api_manager.dispatch_intent(write_patch_intent, msg_thread, print_callback=print_callback)
248+ api_manager.dispatch_intent(
249+ write_patch_intent, msg_thread, print_callback=print_callback
250+ )
219251
220252 conversation_file = pjoin(output_dir, f"conversation_round_{round_no}.json")
221253 msg_thread.save_to_file(conversation_file)
@@ -383,8 +415,10 @@
383415
384416
385417 def run_one_task(
386- output_dir: str, api_manager: ProjectApiManager, problem_stmt: str,
387- print_callback: Callable[[dict], None] | None = None
418+ output_dir: str,
419+ api_manager: ProjectApiManager,
420+ problem_stmt: str,
421+ print_callback: Callable[[dict], None] | None = None,
388422 ) -> bool:
389423 """
390424 Main entry point to run inference on one task.
@@ -415,7 +449,9 @@
415449 msg_thread.add_user(localization_prompt)
416450
417451 if globals.enable_layered:
418- return start_conversation_round_stratified(output_dir, msg_thread, api_manager, print_callback=print_callback)
452+ return start_conversation_round_stratified(
453+ output_dir, msg_thread, api_manager, print_callback=print_callback
454+ )
419455 else:
420456 return start_conversation_round_state_machine(
421457 output_dir, msg_thread, api_manager
modified app/log.py +30 −21
@@ -1,6 +1,6 @@
11 import time
2+from collections.abc import Callable
23 from os import get_terminal_size
3-from typing import Callable
44
55 from loguru import logger
66 from rich.console import Console
@@ -57,7 +57,10 @@
5757 content = content.replace(key, value)
5858 return content
5959
60-def print_acr(msg: str, desc="", print_callback: Callable[[dict], None] | None = None) -> None:
60+
61+def print_acr(
62+ msg: str, desc="", print_callback: Callable[[dict], None] | None = None
63+) -> None:
6164 if not print_stdout:
6265 return
6366
@@ -80,14 +83,14 @@
8083 console.print(panel)
8184
8285 if print_callback:
83- print_callback({
84- 'title': f"{name} ({desc})",
85- 'message': msg,
86- 'category': 'auto_code_rover'
87- })
86+ print_callback(
87+ {"title": f"{name} ({desc})", "message": msg, "category": "auto_code_rover"}
88+ )
8889
8990
90-def print_retrieval(msg: str, desc="", print_callback: Callable[[dict], None] | None = None) -> None:
91+def print_retrieval(
92+ msg: str, desc="", print_callback: Callable[[dict], None] | None = None
93+) -> None:
9194 if not print_stdout:
9295 return
9396
@@ -109,14 +112,18 @@
109112 )
110113 console.print(panel)
111114 if print_callback:
112- print_callback({
113- 'title': f"{name} ({desc})",
114- 'message': msg,
115- 'category': 'context_retrieval_agent'
116- })
117-
118-
119-def print_patch_generation(msg: str, desc="", print_callback: Callable[[dict], None] | None = None) -> None:
115+ print_callback(
116+ {
117+ "title": f"{name} ({desc})",
118+ "message": msg,
119+ "category": "context_retrieval_agent",
120+ }
121+ )
122+
123+
124+def print_patch_generation(
125+ msg: str, desc="", print_callback: Callable[[dict], None] | None = None
126+) -> None:
120127 if not print_stdout:
121128 return
122129
@@ -138,11 +145,13 @@
138145 )
139146 console.print(panel)
140147 if print_callback:
141- print_callback({
142- 'title': f"{name} ({desc})",
143- 'message': msg,
144- 'category': 'patch_generation'
145- })
148+ print_callback(
149+ {
150+ "title": f"{name} ({desc})",
151+ "message": msg,
152+ "category": "patch_generation",
153+ }
154+ )
146155
147156
148157 def print_issue(content: str) -> None:
modified app/main.py +19 −9
@@ -4,8 +4,7 @@
44
55 import json
66 from argparse import ArgumentParser
7-from typing import Callable
8-from collections.abc import Mapping, Sequence
7+from collections.abc import Callable, Mapping, Sequence
98 from concurrent.futures import ProcessPoolExecutor
109 from datetime import datetime
1110 from itertools import chain
@@ -18,7 +17,6 @@
1817 from app import utils as apputils
1918 from app.api.manage import ProjectApiManager
2019 from app.model import common
21-from app.model.register import register_all_models
2220 from app.post_process import (
2321 extract_organize_and_form_input,
2422 get_final_patch_path,
@@ -28,7 +26,10 @@
2826 from app.raw_tasks import RawGithubTask, RawLocalTask, RawSweTask, RawTask
2927 from app.task import Task
3028
31-def get_args(from_command_line_str: str = None, subparser_dest_attr_name: str = "command"):
29+
30+def get_args(
31+ from_command_line_str: str = None, subparser_dest_attr_name: str = "command"
32+):
3233 parser = ArgumentParser()
3334 subparsers = parser.add_subparsers(dest=subparser_dest_attr_name)
3435
@@ -64,6 +65,7 @@
6465 return parser.parse_args()
6566 return parser.parse_args(from_command_line_str.split())
6667
68+
6769 def main(args, subparser_dest_attr_name: str = "command"):
6870
6971 ## common options
@@ -414,7 +416,9 @@
414416 executor.submit(run_raw_task, task)
415417
416418
417-def run_raw_task(task: RawTask, print_callback: Callable[[dict], None] | None = None) -> bool:
419+def run_raw_task(
420+ task: RawTask, print_callback: Callable[[dict], None] | None = None
421+) -> bool:
418422 """
419423 High-level entry for running one task.
420424
@@ -467,7 +471,11 @@
467471 return run_ok
468472
469473
470-def do_inference(python_task: Task, task_output_dir: str, print_callback: Callable[[dict], None] | None = None) -> bool:
474+def do_inference(
475+ python_task: Task,
476+ task_output_dir: str,
477+ print_callback: Callable[[dict], None] | None = None,
478+) -> bool:
471479
472480 apputils.create_dir_if_not_exists(task_output_dir)
473481
@@ -489,8 +497,10 @@
489497 _, _, run_ok = api_manager.fault_localization()
490498 else:
491499 run_ok = inference.run_one_task(
492- api_manager.output_dir, api_manager, python_task.get_issue_statement(),
493- print_callback
500+ api_manager.output_dir,
501+ api_manager,
502+ python_task.get_issue_statement(),
503+ print_callback,
494504 )
495505
496506 api_manager.dump_tool_call_sequence_to_file()
@@ -526,4 +536,4 @@
526536 if __name__ == "__main__":
527537 logger.remove()
528538 args = get_args()
529- main(args)
No newline at the end of the file
539+ main(args)
modified demo_vis/main.py +43 −36
@@ -1,28 +1,34 @@
1-import os, time, sys, datetime
2-import threading
1+import datetime
32 import json
3+import os
4+import sys
5+import threading
6+import time
47 from queue import Queue
5-from flask import Flask, Response, request, jsonify
6-from flask_cors import CORS, cross_origin
78
8-sys.path.append('/opt/auto-code-rover/')
9-from app.raw_tasks import RawGithubTask
10-from app.model import common
11-from app.model.register import register_all_models
12-from app.main import get_args, run_raw_task
13-from app import globals, log
9+from flask import Flask, Response, jsonify, request
10+from flask_cors import cross_origin
1411
12+sys.path.append("/opt/auto-code-rover/")
1513 from test_data import RawGithubTask_for_debug, test_generate_data
1614
15+from app import globals, log
16+from app.main import get_args, run_raw_task
17+from app.model import common
18+from app.model.register import register_all_models
19+from app.raw_tasks import RawGithubTask
20+
1721 app = Flask(__name__)
1822
23+
1924 def initialize_thread_cost():
2025 common.thread_cost.process_cost = 0.0
2126 common.thread_cost.process_input_tokens = 0
2227 common.thread_cost.process_output_tokens = 0
2328
24-@app.route('/api/run_github_issue', methods=['POST'])
25-@cross_origin(origin='http://localhost:3000') # nextjs cross origin
29+
30+@app.route("/api/run_github_issue", methods=["POST"])
31+@cross_origin(origin="http://localhost:3000") # nextjs cross origin
2632 def run_github_issue():
2733
2834 if not request.is_json:
@@ -30,16 +36,17 @@
3036 register_all_models()
3137
3238 data = request.get_json()
33- args = get_args('''github-issue --output-dir output --setup-dir setup --model gpt-4-0125-preview --model-temperature 0.2''')
34- args.task_id = datetime.datetime.now().strftime('%Y-%m-%d_%H:%M:%S')
35- args.clone_link = data['repository_link']
36- args.commit_hash = data['commit_hash']
37- args.issue_link = data['issue_link']
39+ args = get_args(
40+ """github-issue --output-dir output --setup-dir setup --model gpt-4-0125-preview --model-temperature 0.2"""
41+ )
42+ args.task_id = datetime.datetime.now().strftime("%Y-%m-%d_%H:%M:%S")
43+ args.clone_link = data["repository_link"]
44+ args.commit_hash = data["commit_hash"]
45+ args.issue_link = data["issue_link"]
3846
3947 globals.output_dir = args.output_dir
4048 if globals.output_dir is not None:
4149 globals.output_dir = os.path.abspath(globals.output_dir)
42- num_processes: int = int(args.num_processes)
4350 # set whether brief or verbose log
4451 print_stdout: bool = not args.no_print
4552 log.print_stdout = print_stdout
@@ -73,33 +80,31 @@
7380 args.issue_link,
7481 os.path.abspath(args.setup_dir),
7582 )
76- except RuntimeError as e:
77- error_form = {
78- 'message': str(e)
79- }
83+ except RuntimeError as e:
84+ error_form = {"message": str(e)}
8085 return jsonify(error_form), 400
8186
8287 def stream_print():
8388 print_queue = Queue()
84-
89+
8590 def callback(data: dict):
86- print_queue.put(f'{json.dumps(data)}</////json_end>')
87-
91+ print_queue.put(f"{json.dumps(data)}</////json_end>")
92+
8893 def run(task, callback):
8994 initialize_thread_cost()
90- callback({
91- 'category': 'issue_info',
92- 'problem_statement': task.problem_statement
93- })
95+ callback(
96+ {"category": "issue_info", "problem_statement": task.problem_statement}
97+ )
9498 run_raw_task(task, callback)
9599
96100 thread = threading.Thread(target=run, args=(task, callback))
97101 if app.debug:
98- callback({
99- 'category': 'issue_info',
100- 'problem_statement': task.problem_statement
101- })
102- thread = threading.Thread(target=test_generate_data, args=(callback,)) # debug
102+ callback(
103+ {"category": "issue_info", "problem_statement": task.problem_statement}
104+ )
105+ thread = threading.Thread(
106+ target=test_generate_data, args=(callback,)
107+ ) # debug
103108 time.sleep(1)
104109 else:
105110 thread = threading.Thread(target=run, args=(task, callback))
@@ -110,8 +115,10 @@
110115 yield print_queue.get()
111116 else:
112117 time.sleep(0.1)
113- return Response(stream_print(), mimetype='text/event-stream')
118+
119+ return Response(stream_print(), mimetype="text/event-stream")
120+
114121
115122 # http://localhost:5000/
116123 if __name__ == "__main__":
117- app.run(host='0.0.0.0', port=5000, debug=False)
124+ app.run(host="0.0.0.0", port=5000, debug=False)
modified demo_vis/test_data.py +112 −112
@@ -1,20 +1,24 @@
1-import os, time
1+import json
2+import os
3+import time
24 from os.path import join as pjoin
35 from pathlib import Path
4-from app.log import log_and_print
5-from app.raw_tasks import RawTask, PlainTask
6+
67 from app import utils as app_utils
8+from app.log import log_and_print
9+from app.raw_tasks import PlainTask, RawTask
10+
711
812 class RawGithubTask_for_debug(RawTask):
913 """
10- Encapsulate everything required to run ACR on a fresh issue from the internet.
11-
12- For debug / dev: github limits the calling times of api. Therefore when
13- debuging, use the hardcode task:
14+ Encapsulate everything required to run ACR on a fresh issue from the internet.
15+
16+ For debug / dev: github limits the calling times of api. Therefore when
17+ debuging, use the hardcode task:
1418 self.clone_link = 'https://github.com/langchain-ai/langchain.git'
1519 self.commit_hash = 'cb6e5e5'
1620 self.issue_link = 'https://github.com/langchain-ai/langchain/issues/20453'
17- self.problem_statement: refer to the implementation of fetch_github_issue function
21+ self.problem_statement: refer to the implementation of fetch_github_issue function
1822 """
1923
2024 def __init__(
@@ -23,12 +27,12 @@
2327 clone_link: str,
2428 commit_hash: str,
2529 issue_link: str,
26- setup_dir: str
30+ setup_dir: str,
2731 ):
2832 self._task_id = task_id
29- self.clone_link = 'https://github.com/langchain-ai/langchain.git'
30- self.commit_hash = 'cb6e5e5'
31- self.issue_link = 'https://github.com/langchain-ai/langchain/issues/20453'
33+ self.clone_link = "https://github.com/langchain-ai/langchain.git"
34+ self.commit_hash = "cb6e5e5"
35+ self.issue_link = "https://github.com/langchain-ai/langchain/issues/20453"
3236 self.setup_dir = setup_dir
3337 self.clone_path = pjoin(self.setup_dir, self.task_id)
3438 self.problem_statement, self.created_at = self.fetch_issue()
@@ -41,11 +45,7 @@
4145 def clone_repo(self):
4246 clone_path = Path(self.clone_path)
4347 if os.path.exists(clone_path):
44- return # Dev/Debug mode
45- log_and_print(
46- f"Path {clone_path} already exists. Removing it to get a fresh clone."
47- )
48- shutil.rmtree(clone_path)
48+ return # Dev/Debug mode
4949 app_utils.clone_repo(self.clone_link, str(clone_path.parent), clone_path.name)
5050 log_and_print(f"Cloned source code to {clone_path}.")
5151
@@ -88,8 +88,8 @@
8888 def fetch_github_issue(cls, issue_url: str) -> tuple[str, str, str]:
8989 """Extract owner, repo, and issue number from the URL"""
9090
91- title = '''`PaiEasChatEndpoint._call_eas` should return `bytes` type instead of `str` type'''
92- body = '''
91+ title = """`PaiEasChatEndpoint._call_eas` should return `bytes` type instead of `str` type"""
92+ body = """
9393 ### Checked other resources
9494
9595 - [X] I added a very descriptive title to this issue.
@@ -139,7 +139,7 @@
139139 ------------------
140140 > OS: Linux
141141 > OS Version: #190-Ubuntu SMP Fri Feb 2 23:24:22 UTC 2024
142-> Python Version: 3.9.18 (main, Feb 13 2024, 14:37:08)
142+> Python Version: 3.9.18 (main, Feb 13 2024, 14:37:08)
143143 [GCC 9.4.0]
144144
145145 Package Information
@@ -156,8 +156,8 @@
156156
157157 > langgraph
158158 > langserve
159-'''
160- created_at = '''2024-04-15T07:47:06Z'''
159+"""
160+ created_at = """2024-04-15T07:47:06Z"""
161161
162162 return title, body, created_at
163163
@@ -170,10 +170,10 @@
170170
171171
172172 test_data = [
173- {
174- 'title': 'AutoCodeRover (context retrieval round 0)',
175- 'category': 'auto_code_rover',
176- 'message': '''Based on the files, classes, methods, and code statements from the issue related to the bug, you can use the following search APIs to get more context of the project.
173+ {
174+ "title": "AutoCodeRover (context retrieval round 0)",
175+ "category": "auto_code_rover",
176+ "message": """Based on the files, classes, methods, and code statements from the issue related to the bug, you can use the following search APIs to get more context of the project.
177177 - search_class(class_name: str): Search for a class in the codebase
178178 - search_method_in_file(method_name: str, file_path: str): Search for a method in a given file
179179 - search_method_in_class(method_name: str, class_name: str): Search for a method in a given class
@@ -183,31 +183,31 @@
183183
184184 Note that you can use multiple search APIs in one round.
185185
186-Now analyze the issue and select necessary APIs to get more context of the project. Each API call must have concrete arguments as inputs.'''
187- },
188- {
189- 'title': 'Context Retrieval Agent (round 0)',
190- 'category': 'context_retrieval_agent',
191- 'message': '''I will start by searching for the `PaiEasChatEndpoint` class to understand its structure and methods. Then, I will search for the `_call_eas` method within this class to investigate its implementation.
186+Now analyze the issue and select necessary APIs to get more context of the project. Each API call must have concrete arguments as inputs.""",
187+ },
188+ {
189+ "title": "Context Retrieval Agent (round 0)",
190+ "category": "context_retrieval_agent",
191+ "message": """I will start by searching for the `PaiEasChatEndpoint` class to understand its structure and methods. Then, I will search for the `_call_eas` method within this class to investigate its implementation.
192192
193193 1. `search_class("PaiEasChatEndpoint")`
194-2. `search_method_in_class("_call_eas", "PaiEasChatEndpoint")`'''
195- },
196- {
197- 'title': 'AutoCodeRover (Agent-selected API calls)',
198- 'category': 'auto_code_rover',
199- 'message': '''
194+2. `search_method_in_class("_call_eas", "PaiEasChatEndpoint")`""",
195+ },
196+ {
197+ "title": "AutoCodeRover (Agent-selected API calls)",
198+ "category": "auto_code_rover",
199+ "message": """
200200 API calls:
201201
202202 - `search_class('PaiEasChatEndpoint')`
203203
204204 - `search_method_in_class('_call_eas', 'PaiEasChatEndpoint')`
205- '''
206- },
207- {
208- 'title': 'AutoCodeRover (context retrieval round 0)',
209- 'category': 'auto_code_rover',
210- 'message': '''
205+ """,
206+ },
207+ {
208+ "title": "AutoCodeRover (context retrieval round 0)",
209+ "category": "auto_code_rover",
210+ "message": '''
211211 Result of search_class('PaiEasChatEndpoint'):
212212
213213 Found 1 classes with name PaiEasChatEndpoint in the codebase:
@@ -292,17 +292,17 @@
292292
293293 </code>
294294 ```
295- '''
296- },
297- {
298- 'title': 'Context Retrieval Agent (round 0)',
299- 'category': 'auto_code_rover',
300- 'message': '''Let's analyze collected context first'''
301- },
302- {
303- 'title': 'AutoCodeRover (context retrieval round 0)',
304- 'category': 'context_retrieval_agent',
305- 'message': '''Based on the search results, here is the analysis of the `PaiEasChatEndpoint` class and the `_call_eas` method:
295+ ''',
296+ },
297+ {
298+ "title": "Context Retrieval Agent (round 0)",
299+ "category": "auto_code_rover",
300+ "message": """Let's analyze collected context first""",
301+ },
302+ {
303+ "title": "AutoCodeRover (context retrieval round 0)",
304+ "category": "context_retrieval_agent",
305+ "message": """Based on the search results, here is the analysis of the `PaiEasChatEndpoint` class and the `_call_eas` method:
306306
307307 1. **PaiEasChatEndpoint Class**:
308308 - The `PaiEasChatEndpoint` class is defined in the file `libs/community/langchain_community/chat_models/pai_eas_endpoint.py`.
@@ -317,19 +317,19 @@
317317 - If the request fails (status code other than 200), it raises an exception with the status code and response message.
318318 - Currently, the method returns the response text as a `str`.
319319
320-Based on this analysis, the issue is indeed related to the `_call_eas` method returning a `str` type instead of `bytes`, which leads to a type mismatch in the `_call` method. The fix involves modifying the `_call_eas` method to return `bytes` instead of `str`.'''
321- },
322- {
323- 'title': 'AutoCodeRover (context retrieval round 0)',
324- 'category': 'auto_code_rover',
325- 'message': '''Based on your analysis, answer below questions:
320+Based on this analysis, the issue is indeed related to the `_call_eas` method returning a `str` type instead of `bytes`, which leads to a type mismatch in the `_call` method. The fix involves modifying the `_call_eas` method to return `bytes` instead of `str`.""",
321+ },
322+ {
323+ "title": "AutoCodeRover (context retrieval round 0)",
324+ "category": "auto_code_rover",
325+ "message": """Based on your analysis, answer below questions:
326326 - do we need more context: construct search API calls to get more context of the project. (leave it empty if you don't need more context)
327-- where are bug locations: buggy files and methods. (leave it empty if you don't have enough information)'''
328- },
329- {
330- 'title': 'AutoCodeRover (context retrieval round 0)',
331- 'category': 'auto_code_rover',
332- 'message': '''
327+- where are bug locations: buggy files and methods. (leave it empty if you don't have enough information)""",
328+ },
329+ {
330+ "title": "AutoCodeRover (context retrieval round 0)",
331+ "category": "auto_code_rover",
332+ "message": """
333333 Based on the files, classes, methods, and code statements from the issue related to the bug, you can use the following search APIs to get more context of the project.
334334 - search_class(class_name: str): Search for a class in the codebase
335335 - search_method_in_file(method_name: str, file_path: str): Search for a method in a given file
@@ -341,31 +341,31 @@
341341 Note that you can use multiple search APIs in one round.
342342
343343 Now analyze the issue and select necessary APIs to get more context of the project. Each API call must have concrete arguments as inputs.
344- '''
345- },
346- {
347- 'title': 'Context Retrieval Agent (round 1)',
348- 'category': 'context_retrieval_agent',
349- 'message': '''- **More Context**:
344+ """,
345+ },
346+ {
347+ "title": "Context Retrieval Agent (round 1)",
348+ "category": "context_retrieval_agent",
349+ "message": """- **More Context**:
350350 - We have sufficient context to proceed with fixing the bug. No additional search API calls are needed at this point.
351351
352352 - **Bug Locations**:
353353 - Buggy File: `libs/community/langchain_community/chat_models/pai_eas_endpoint.py`
354-- Buggy Method: `_call_eas` in the `PaiEasChatEndpoint` class'''
355- },
356- {
357- 'title': 'AutoCodeRover (Agent-selected API calls)',
358- 'category': 'auto_code_rover',
359- 'message': '''
354+- Buggy Method: `_call_eas` in the `PaiEasChatEndpoint` class""",
355+ },
356+ {
357+ "title": "AutoCodeRover (Agent-selected API calls)",
358+ "category": "auto_code_rover",
359+ "message": """
360360
361361 Bug locations
362362
363-- file: `libs/community/langchain_community/chat_models/pai_eas_endpoint.py`, class: `PaiEasChatEndpoint`, method: `_call_eas`'''
364- },
365- {
366- 'title': 'AutoCodeRover (Patch generation round 1)',
367- 'category': 'auto_code_rover',
368- 'message': '''Here is the code in buggy locations:
363+- file: `libs/community/langchain_community/chat_models/pai_eas_endpoint.py`, class: `PaiEasChatEndpoint`, method: `_call_eas`""",
364+ },
365+ {
366+ "title": "AutoCodeRover (Patch generation round 1)",
367+ "category": "auto_code_rover",
368+ "message": '''Here is the code in buggy locations:
369369
370370
371371
@@ -399,12 +399,12 @@
399399
400400 </code>
401401 ```
402-'''
403- },
404- {
405- 'title': 'AutoCodeRover (patch generation)',
406- 'category': 'auto_code_rover',
407- 'message': '''
402+''',
403+ },
404+ {
405+ "title": "AutoCodeRover (patch generation)",
406+ "category": "auto_code_rover",
407+ "message": """
408408 Write a patch for the issue, based on the retrieved context.
409409
410410 You can import necessary libraries.
@@ -432,12 +432,12 @@
432432
433433 # modification 3
434434 ...
435-```'''
436- },
437- {
438- 'category': 'patch_generation',
439- 'title': 'Patch Generation (try 1 / 3)',
440- 'message': '''```
435+```""",
436+ },
437+ {
438+ "category": "patch_generation",
439+ "title": "Patch Generation (try 1 / 3)",
440+ "message": '''```
441441 # Patch for changing the return type of _call_eas method to bytes
442442
443443 import requests
@@ -488,12 +488,12 @@
488488
489489 return response.content
490490 </patched>
491-```'''
492- },
493- {
494- 'title': 'AutoCodeRover (extracted patch)',
495- 'category': 'auto_code_rover',
496- 'message': '''```diff
491+```''',
492+ },
493+ {
494+ "title": "AutoCodeRover (extracted patch)",
495+ "category": "auto_code_rover",
496+ "message": '''```diff
497497 diff --git a/libs/community/langchain_community/chat_models/pai_eas_endpoint.py b/libs/community/langchain_community/chat_models/pai_eas_endpoint.py
498498 index e438ad25e..309c6d287 100644
499499 --- a/libs/community/langchain_community/chat_models/pai_eas_endpoint.py
@@ -517,17 +517,17 @@
517517 def _call_eas_stream(self, query_body: dict) -> Any:
518518 """Generate text from the eas service."""
519519
520-```'''
521- },
522- {
523- 'title': 'AutoCodeRover (patch generation try 1 / 3)',
524- 'category': 'auto_code_rover',
525- 'message': '''Extracted a patch. Since validation is disabled, you should validation the patch later on. Ending the workflow.'''
526- },
527- ]
520+```''',
521+ },
522+ {
523+ "title": "AutoCodeRover (patch generation try 1 / 3)",
524+ "category": "auto_code_rover",
525+ "message": """Extracted a patch. Since validation is disabled, you should validation the patch later on. Ending the workflow.""",
526+ },
527+]
528+
528529
529530 def test_generate_data(callback):
530531 for data in test_data:
531532 callback(data)
532533 time.sleep(1)
533-