File tree Expand file tree Collapse file tree 4 files changed +20
-2
lines changed Expand file tree Collapse file tree 4 files changed +20
-2
lines changed Original file line number Diff line number Diff line change
1
+ import sys
2
+ import os
1
3
from abc import ABC , abstractmethod
2
4
from pathlib import Path
3
5
7
9
8
10
9
11
class Agents (ABC ):
12
+ def __init__ (self , max_iteration : int ):
13
+ self .max_iteration = max_iteration
14
+
10
15
@abstractmethod
11
16
def run (self ) -> None :
12
17
"""Start agent"""
13
18
raise NotImplementedError
14
19
15
20
16
21
class AiderAgents (Agents ):
17
- def __init__ (self , model_name : str ):
22
+ def __init__ (self , max_iteration : int , model_name : str ):
23
+ super ().__init__ (max_iteration )
18
24
self .model = Model (model_name )
19
25
20
26
def run (
@@ -37,6 +43,10 @@ def run(
37
43
log_dir .mkdir (parents = True , exist_ok = True )
38
44
input_history_file = log_dir / ".aider.input.history"
39
45
chat_history_file = log_dir / ".aider.chat.history.md"
46
+ print (
47
+ f"check { os .path .abspath (chat_history_file )} for prompts and lm generations" ,
48
+ file = sys .stderr ,
49
+ )
40
50
io = InputOutput (
41
51
yes = True ,
42
52
input_history_file = input_history_file ,
@@ -51,4 +61,6 @@ def run(
51
61
test_cmd = test_cmd ,
52
62
io = io ,
53
63
)
64
+ coder .max_reflection = self .max_iteration
65
+ coder .stream = False
54
66
coder .run (message )
Original file line number Diff line number Diff line change @@ -26,3 +26,4 @@ class AgentConfig:
26
26
max_lint_info_length : int
27
27
pre_commit_config_path : str
28
28
run_tests : bool
29
+ max_iteration : int
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ agent_config:
25
25
max_unit_tests_info_length : 10000
26
26
max_reference_info_length : 10000
27
27
max_lint_info_length : 10000
28
+ max_iteration : 3
28
29
29
30
hydra :
30
31
run :
Original file line number Diff line number Diff line change 1
1
import os
2
+ import sys
2
3
import hydra
3
4
from datasets import load_dataset
4
5
import traceback
@@ -57,7 +58,7 @@ def run_agent_for_repo(
57
58
target_edit_files = get_target_edit_files (repo_path )
58
59
59
60
if agent_config .agent_name == "aider" :
60
- agent = AiderAgents (agent_config .model_name )
61
+ agent = AiderAgents (agent_config .max_iteration , agent_config . model_name )
61
62
else :
62
63
raise NotImplementedError (
63
64
f"{ agent_config .agent_name } is not implemented; please add your implementations in baselines/agents.py."
@@ -127,6 +128,9 @@ def main() -> None:
127
128
]
128
129
assert len (filtered_dataset ) > 0 , "No examples available"
129
130
131
+ if len (filtered_dataset ) > 1 :
132
+ sys .stdout = open (os .devnull , "w" )
133
+
130
134
with tqdm (
131
135
total = len (filtered_dataset ), smoothing = 0 , desc = "Running Aider for repos"
132
136
) as pbar :
You can’t perform that action at this time.
0 commit comments