Skip to content

Commit a70763e

Browse files
committed
Rename format_vars -> template_vars
1 parent c914798 commit a70763e

3 files changed

Lines changed: 14 additions & 14 deletions

File tree

codeclash/agents/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ def get_agent(config: dict, game: CodeGame) -> Player:
1212
if agents is None:
1313
raise ValueError(f"Unknown agent type: {config['agent']}")
1414
environment = game.get_environment()
15-
format_vars = {
15+
template_vars = {
1616
"game_id": game.game_id,
1717
"rounds": game.rounds,
1818
"round": game.round,
1919
"player_id": config["name"],
2020
"game_description": game.config.get("description", ""),
2121
}
22-
return agents(config, environment, format_vars)
22+
return agents(config, environment, template_vars)

codeclash/agents/abstract.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ def __init__(
1616
self,
1717
config: dict,
1818
environment: Environment,
19-
format_vars: dict,
19+
template_vars: dict,
2020
):
2121
self.config = config
22-
self.name = f"{format_vars['game_id']}_{config['name']}"
22+
self.name = f"{template_vars['game_id']}_{config['name']}"
2323
self.environment = environment
24-
self.round = format_vars["round"]
25-
self.format_vars = format_vars
24+
self.round = template_vars["round"]
25+
self.template_vars = template_vars
2626

2727
def commit(self):
2828
"""Commit changes to the agent's codebase."""
29-
rounds = self.format_vars["rounds"]
29+
rounds = self.template_vars["rounds"]
3030
for cmd in [
3131
"git add -A",
3232
f"git commit --allow-empty -m 'Round {self.round}/{rounds} Update'",

codeclash/agents/minisweagent.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ def __init__(
2929
model: Model,
3030
env: Environment,
3131
name: str,
32-
format_vars: dict,
32+
template_vars: dict,
3333
*,
3434
config_class: Callable = AgentConfig,
3535
**kwargs,
3636
):
3737
super().__init__(model, env, config_class=config_class, **kwargs)
3838
self.name = name
39-
self.format_vars = format_vars
39+
self.template_vars = template_vars
4040
self.console = Console()
4141

4242
def add_message(self, role: str, content: str, **kwargs):
@@ -52,7 +52,7 @@ def render_template(self, template: str, **kwargs) -> str:
5252
| asdict(self.env.config)
5353
| asdict(self.model.config)
5454
| platform.uname()._asdict()
55-
| self.format_vars
55+
| self.template_vars
5656
)
5757
return Template(template).render(**kwargs, **cs, **os.environ)
5858

@@ -65,16 +65,16 @@ def run(self) -> tuple[str, str]:
6565
class MiniSWEAgent(Player):
6666
"""Player with agentic code editing capabilities"""
6767

68-
def __init__(self, config: dict, environment: Environment, format_vars: dict):
69-
super().__init__(config, environment=environment, format_vars=format_vars)
68+
def __init__(self, config: dict, environment: Environment, template_vars: dict):
69+
super().__init__(config, environment=environment, template_vars=template_vars)
7070
self.agent = ClashAgent(
7171
LitellmModel(
7272
model_name=config["model"],
7373
model_kwargs={"api_key": resolve_api_key(config["model"])},
7474
),
7575
self.environment,
7676
self.name,
77-
format_vars,
77+
template_vars,
7878
**yaml.safe_load(Path(config["config"]).read_text())["agent"],
7979
)
8080

@@ -93,7 +93,7 @@ def run(self):
9393
save_traj(
9494
self.agent, # type: ignore
9595
DIR_LOGS
96-
/ f"{self.format_vars['game_id']}/{player_id}_r{self.format_vars['round']}.traj.json",
96+
/ f"{self.template_vars['game_id']}/{player_id}_r{self.template_vars['round']}.traj.json",
9797
exit_status=exit_status,
9898
result=result,
9999
)

0 commit comments

Comments
 (0)