Skip to content

Commit 543ef7a

Browse files
committed
pass precommit
1 parent 7ad3a54 commit 543ef7a

File tree

4 files changed

+37
-18
lines changed

4 files changed

+37
-18
lines changed

agent/agent_utils.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,10 @@ def get_message_function_by_function(
458458
f"Invalid implementation strategy: {agent_config.implementation_strategy}"
459459
)
460460

461-
messages_to_agent = [context + uf for uf in unimplemented_functions]
461+
if agent_config.implementation_strategy == "function_by_function":
462+
messages_to_agent = [context + uf for uf in function_info if len(uf) > 0]
463+
else:
464+
messages_to_agent = []
462465

463466
return messages_to_agent
464467

@@ -577,7 +580,9 @@ def get_changed_files_from_commits(
577580

578581

579582
def run_eval_after_each_commit(
580-
branch: str, backend: str, commit0_config_file: str, repo_name: str
583+
branch: str,
584+
backend: str,
585+
commit0_config_file: str,
581586
) -> str:
582587
"""Run the eval command after each commit."""
583588
eval_cmd = f"python -m commit0 evaluate --branch {branch} --backend {backend} --commit0-config-file {commit0_config_file} --timeout 100"

agent/cli.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import typer
2-
from agent.run_agent_no_rich import run_agent as run_agent_no_rich
32
from agent.run_agent import run_agent
43
from commit0.harness.constants import RUN_AGENT_LOG_DIR
54
import subprocess
@@ -242,12 +241,13 @@ def run(
242241
display_repo_progress_num,
243242
)
244243
else:
245-
run_agent_no_rich(
246-
branch,
247-
override_previous_changes,
248-
backend,
249-
agent_config_file,
250-
commit0_config_file,
251-
log_dir,
252-
max_parallel_repos,
253-
)
244+
# run_agent_no_rich(
245+
# branch,
246+
# override_previous_changes,
247+
# backend,
248+
# agent_config_file,
249+
# commit0_config_file,
250+
# log_dir,
251+
# max_parallel_repos,
252+
# )
253+
raise NotImplementedError("Currently not supported")

agent/run_agent.py

+19-6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
get_lint_cmd,
1515
read_yaml_config,
1616
)
17+
from agent.agents import AgentReturn
1718
import json
1819
import subprocess
1920
from agent.agents import AiderAgents
@@ -62,7 +63,7 @@ def run_agent_multiple_times_on_same_inquiry(
6263
repeat_times_for_each_inquiry: int,
6364
backend: str,
6465
commit0_config_file: str,
65-
) -> None:
66+
) -> AgentReturn | None:
6667
"""Run agent multiple times on the same inquiry and return the best performing agent return"""
6768
if repeat_times_for_each_inquiry == 1:
6869
return agent.run(
@@ -71,10 +72,9 @@ def run_agent_multiple_times_on_same_inquiry(
7172
else:
7273
commit_before_run = repo.head.commit.hexsha
7374
commit_results = {}
74-
best_commit_diff = None
75+
best_commit_diff = ""
7576
best_eval_result = float("-inf")
7677
best_agent_return = None
77-
7878
for attempt in range(repeat_times_for_each_inquiry):
7979
agent_return = agent.run(
8080
message,
@@ -221,6 +221,7 @@ def run_agent_for_repo(
221221
if agent_config is None:
222222
raise ValueError("Invalid input")
223223

224+
agent_return = None
224225
if agent_config.run_tests:
225226
update_queue.put(("start_repo", (repo_name, len(test_files))))
226227
# when unit test feedback is available, iterate over test files
@@ -260,7 +261,11 @@ def run_agent_for_repo(
260261
update_queue.put(
261262
(
262263
"update_money_display",
263-
(repo_name, test_file, agent_return.last_cost),
264+
(
265+
repo_name,
266+
test_file,
267+
agent_return.last_cost if agent_return is not None else 0,
268+
),
264269
)
265270
)
266271
elif agent_config.run_entire_dir_lint:
@@ -300,7 +305,11 @@ def run_agent_for_repo(
300305
update_queue.put(
301306
(
302307
"update_money_display",
303-
(repo_name, lint_file, agent_return.last_cost),
308+
(
309+
repo_name,
310+
lint_file,
311+
agent_return.last_cost if agent_return is not None else 0,
312+
),
304313
)
305314
)
306315
else:
@@ -373,7 +382,11 @@ def run_agent_for_repo(
373382
update_queue.put(
374383
(
375384
"update_money_display",
376-
(repo_name, file_name, agent_return.last_cost),
385+
(
386+
repo_name,
387+
file_name,
388+
agent_return.last_cost if agent_return is not None else 0,
389+
),
377390
)
378391
)
379392
if agent_config.record_test_for_each_commit:

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ dependencies = [
2222
"strenum>=0.4.15",
2323
"e2b-code-interpreter>=1.0.4",
2424
"python-dotenv>=1.0.1",
25+
"rank_bm25>=0.2.1",
2526
]
2627
classifiers = [
2728
"License :: OSI Approved :: MIT License",

0 commit comments

Comments
 (0)