Skip to content

Commit f38d93d

Browse files
S1M0N38claude
andcommitted
feat(core): refactor LLMBot with Config dataclass and improved architecture
- Add Config dataclass for centralized configuration management - Refactor LLMBot initialization to use Config instead of individual parameters - Add TemplateManager class for better Jinja2 template handling - Implement custom BalatroLLMError exception for better error handling - Add retry logic with exponential backoff for LLM API calls - Enhance logging with setup_logging function and structured formatting - Add structured save path generation based on version/model/template - Implement project version detection from pyproject.toml - Improve game loop with better state handling and error management - Add comprehensive input validation and error messages Co-Authored-By: Claude <noreply@anthropic.com>
1 parent cd6858e commit f38d93d

2 files changed

Lines changed: 341 additions & 124 deletions

File tree

src/balatrollm/__init__.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import sys
77
from pathlib import Path
88

9-
from .llm import LLMBot
9+
from .llm import Config, LLMBot, setup_logging
1010

1111

1212
def main() -> None:
@@ -61,10 +61,7 @@ def main() -> None:
6161
# Configure logging
6262
import logging
6363

64-
level = logging.DEBUG if args.verbose else logging.INFO
65-
logging.basicConfig(
66-
level=level, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
67-
)
64+
setup_logging(args.verbose)
6865
logger = logging.getLogger(__name__)
6966

7067
# Check if config file exists
@@ -81,7 +78,13 @@ def main() -> None:
8178

8279
async def run_bot(args) -> None:
8380
"""Run the Balatro bot with the given arguments."""
84-
bot = LLMBot(model=args.model, proxy_url=args.proxy_url, api_key=args.api_key)
81+
config = Config(
82+
model=args.model,
83+
proxy_url=args.proxy_url,
84+
api_key=args.api_key,
85+
template="system", # Default template, could be made configurable
86+
)
87+
bot = LLMBot(config)
8588

8689
# List models if requested
8790
if args.list_models:

0 commit comments

Comments
 (0)