Skip to content

Commit ca1c85c

Browse files
S1M0N38claude
andcommitted
feat: update package exports and environment configuration
Export LLMBot class and add environment variables for LiteLLM proxy configuration. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent c04175b commit ca1c85c

2 files changed

Lines changed: 158 additions & 2 deletions

File tree

.envrc.example

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Copy this file to .envrc and fill in your actual values.
33

44
# Load the virtual environment
5-
# source .venv/bin/activate
5+
source .venv/bin/activate
66

77
# Example environment variables:
88
# export MY_VARIABLE="some_value"
@@ -12,9 +12,45 @@
1212
export PYTHONUNBUFFERED="1"
1313
export PYTHONPATH="${PWD}/src:${PYTHONPATH}"
1414

15+
# Disable git lfs
16+
export GIT_LFS_SKIP_SMUDGE=1
17+
1518
# Example: Django settings module
1619
# export DJANGO_SETTINGS_MODULE="myproject.settings.local"
1720

1821
# Example: Flask app
1922
# export FLASK_APP="myapp:create_app()"
2023
# export FLASK_ENV="development"
24+
25+
# LITELLM PROXY CONFIGURATION
26+
# The bot now uses LiteLLM proxy for unified model access
27+
export LITELLM_MODEL="cerebras-gpt-oss-120b" # Available models: cerebras-gpt-oss-120b, groq-qwen32b, local-deepseek, openai-gpt4o, anthropic-sonnet
28+
export LITELLM_PROXY_URL="http://localhost:4000"
29+
export LITELLM_API_KEY="sk-balatrollm-proxy-key"
30+
31+
# PROVIDER API KEYS (used by LiteLLM proxy)
32+
# You need to set the API keys for the providers you want to use
33+
34+
# CEREBRAS
35+
export CEREBRAS_API_KEY="your-cerebras-api-key"
36+
37+
# GROQ
38+
export GROQ_API_KEY="your-groq-api-key"
39+
40+
# OPENAI (optional)
41+
export OPENAI_API_KEY="your-openai-api-key"
42+
43+
# ANTHROPIC (optional)
44+
export ANTHROPIC_API_KEY="your-anthropic-api-key"
45+
46+
# LMSTUDIO (for local-deepseek model)
47+
# No API key needed, just make sure LM Studio is running on localhost:1234
48+
49+
# TTS
50+
51+
# Edge-TTS
52+
export TTS_API_KEY="your_api_key_here"
53+
export TTS_MODEL="tts-1"
54+
export TTS_VOICE="en-US-AvaNeural"
55+
export TTS_SPEED=1.0
56+
export TTS_BASE_URL="https://api.groq.com/openai/v1"

src/balatrollm/__init__.py

Lines changed: 121 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,125 @@
11
"""Balatrollm project."""
22

3+
import argparse
4+
import asyncio
5+
import os
6+
import sys
7+
from pathlib import Path
8+
9+
from .llm import LLMBot
10+
311

412
def main() -> None:
5-
print("Hello from balatrollm!")
13+
"""Main CLI entry point for balatrollm."""
14+
parser = argparse.ArgumentParser(
15+
description="LLM-powered Balatro bot using LiteLLM proxy",
16+
formatter_class=argparse.RawDescriptionHelpFormatter,
17+
epilog="""
18+
Examples:
19+
balatrollm --model cerebras-gpt-oss-120b
20+
balatrollm --model groq-qwen32b --proxy-url http://localhost:4000
21+
balatrollm --list-models
22+
""",
23+
)
24+
25+
parser.add_argument(
26+
"--model",
27+
default=os.getenv("LITELLM_MODEL", "cerebras-gpt-oss-120b"),
28+
help="Model name to use from LiteLLM proxy (default: cerebras-gpt-oss-120b)",
29+
)
30+
31+
parser.add_argument(
32+
"--proxy-url",
33+
default=os.getenv("LITELLM_PROXY_URL", "http://localhost:4000"),
34+
help="LiteLLM proxy URL (default: http://localhost:4000)",
35+
)
36+
37+
parser.add_argument(
38+
"--api-key",
39+
default=os.getenv("LITELLM_API_KEY", "sk-balatrollm-proxy-key"),
40+
help="LiteLLM proxy API key (default: sk-balatrollm-proxy-key)",
41+
)
42+
43+
parser.add_argument(
44+
"--list-models",
45+
action="store_true",
46+
help="List available models from the proxy and exit",
47+
)
48+
49+
parser.add_argument(
50+
"--config",
51+
default="config/litellm.yaml",
52+
help="Path to LiteLLM configuration file (default: config/litellm.yaml)",
53+
)
54+
55+
parser.add_argument(
56+
"--verbose", "-v", action="store_true", help="Enable verbose logging"
57+
)
58+
59+
args = parser.parse_args()
60+
61+
# Configure logging
62+
import logging
63+
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+
)
68+
logger = logging.getLogger(__name__)
69+
70+
# Check if config file exists
71+
config_path = Path(args.config)
72+
if not config_path.exists():
73+
logger.error(f"LiteLLM config file not found: {config_path}")
74+
logger.error(f"Please create the config file or start the proxy manually:")
75+
logger.error(f" litellm --config {config_path}")
76+
sys.exit(1)
77+
78+
# Create and run the bot
79+
asyncio.run(run_bot(args))
80+
81+
82+
async def run_bot(args) -> None:
83+
"""Run the Balatro bot with the given arguments."""
84+
bot = LLMBot(model=args.model, proxy_url=args.proxy_url, api_key=args.api_key)
85+
86+
# List models if requested
87+
if args.list_models:
88+
print("Checking available models from LiteLLM proxy...")
89+
if not await bot.validate_proxy_connection():
90+
print(f"❌ Cannot connect to LiteLLM proxy at {args.proxy_url}")
91+
print(f"Please start the proxy with: litellm --config {args.config}")
92+
sys.exit(1)
93+
94+
models = await bot.list_available_models()
95+
if models:
96+
print("✅ Available models:")
97+
for model in models:
98+
print(f" - {model}")
99+
else:
100+
print("❌ No models available or failed to retrieve models")
101+
return
102+
103+
# Validate proxy connection and model before starting game
104+
print(f"🤖 Starting Balatro LLM Bot with model: {args.model}")
105+
106+
if not await bot.validate_proxy_connection():
107+
print(f"❌ Cannot connect to LiteLLM proxy at {args.proxy_url}")
108+
print(f"Please start the proxy with: litellm --config {args.config}")
109+
sys.exit(1)
110+
111+
if not await bot.validate_model_exists():
112+
print(f"❌ Model '{args.model}' not available")
113+
print("Use --list-models to see available models")
114+
sys.exit(1)
115+
116+
print("✅ Proxy connection validated, starting game...")
117+
118+
try:
119+
with bot:
120+
await bot.play_game()
121+
except KeyboardInterrupt:
122+
print("\n🛑 Game interrupted by user")
123+
except Exception as e:
124+
print(f"❌ Game failed: {e}")
125+
sys.exit(1)

0 commit comments

Comments
 (0)