Skip to content

Commit 88482c3

Browse files
committed
added baselines/agents.py
1 parent ad23e19 commit 88482c3

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

baselines/agents.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from abc import ABC, abstractmethod
2+
from pathlib import Path
3+
4+
from aider.coders import Coder
5+
from aider.models import Model
6+
from aider.io import InputOutput
7+
8+
class Agents(ABC):
9+
@abstractmethod
10+
def run(self):
11+
raise NotImplementedError
12+
13+
class AiderAgents(Agents):
14+
def __init__(self, model_name: str):
15+
self.model = Model(model_name)
16+
17+
def run(self, message: str, test_cmd: str, lint_cmd: str, fnames: list[str], log_dir: Path) -> None:
18+
if test_cmd:
19+
auto_test = True
20+
else:
21+
auto_test = False
22+
if lint_cmd:
23+
auto_lint = True
24+
else:
25+
auto_lint = False
26+
log_dir.mkdir(parents=True, exist_ok=True)
27+
input_history_file = log_dir / ".aider.input.history"
28+
chat_history_file = log_dir / ".aider.chat.history.md"
29+
io = InputOutput(yes=True, input_history_file=input_history_file, chat_history_file=chat_history_file)
30+
coder = Coder.create(main_model=self.model, fnames=fnames, auto_lint=auto_lint, lint_cmds=lint_cmd, io=io)
31+
coder.run(message)

0 commit comments

Comments
 (0)