Skip to content

Commit 80e9d9a

Browse files
committed
feat: add new tools and agentic capabilities
1 parent b4a3da1 commit 80e9d9a

2 files changed

Lines changed: 358 additions & 16 deletions

File tree

src/balatrollm/llm.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
from typing import Any
99

1010
import httpx
11-
from balatrobot import BalatroClient
12-
from balatrobot.enums import State
1311
from jinja2 import Environment, FileSystemLoader
1412
from openai import AsyncOpenAI
1513
from openai.types.chat import ChatCompletion
1614

15+
from balatrobot import BalatroClient
16+
from balatrobot.enums import State
17+
1718
logger = logging.getLogger(__name__)
1819
logging.basicConfig(level=logging.INFO)
1920

@@ -147,6 +148,7 @@ async def get_tool_call(self, game_state: dict):
147148
# Extract tool call
148149
message = response.choices[0].message
149150
if not hasattr(message, "tool_calls") or not message.tool_calls:
151+
print(response.choices[0].message)
150152
raise ValueError("No tool calls in LLM response")
151153

152154
tool_call = message.tool_calls[0]
@@ -188,26 +190,20 @@ async def play_game(self) -> None:
188190

189191
match current_state:
190192
case State.BLIND_SELECT:
191-
# TODO: Enable LLM decision for blind selection
192-
# tool_call = await self.make_decision(game_state)
193-
game_state = self.balatro_client.send_message(
194-
"skip_or_select_blind", {"action": "select"}
195-
)
193+
tool_call = await self.get_tool_call(game_state)
194+
game_state = self.execute_tool_call(tool_call)
196195

197196
case State.SELECTING_HAND:
198197
tool_call = await self.get_tool_call(game_state)
199198
game_state = self.execute_tool_call(tool_call)
200199

201200
case State.ROUND_EVAL:
202-
logger.info("Cashing out")
203-
game_state = self.balatro_client.send_message("cash_out")
201+
tool_call = await self.get_tool_call(game_state)
202+
game_state = self.execute_tool_call(tool_call)
204203

205204
case State.SHOP:
206-
# TODO: Enable LLM decision for shop actions
207-
# tool_call = await self.make_decision(game_state)
208-
game_state = self.balatro_client.send_message(
209-
"shop", {"action": "next_round"}
210-
)
205+
tool_call = await self.get_tool_call(game_state)
206+
game_state = self.execute_tool_call(tool_call)
211207

212208
case State.GAME_OVER:
213209
logger.info("Game over!")

0 commit comments

Comments
 (0)