An AI-powered tool that explains baseball pitch strategies in real-time using MLB data and Google's Gemini API.
Features • Installation • Usage • Project Structure • Contributing
The Baseball Strategy Assistant is a real-time AI tool that analyses MLB game data and provides casual fans with fun, easy-to-understand explanations of pitch strategies. Built with Python, Streamlit, and Google's Gemini API, it transforms complex baseball tactics into relatable analogies.
- Real-Time Insights: Fetches live game data from MLB's API
- AI-Powered Analysis: Uses Gemini to generate casual, fun explanations
- Interactive UI: Built with Streamlit for a clean, user-friendly experience
- Multilingual Support: Gemini can explain strategies in multiple languages
- Historical Data: Works with past games for demo purposes
- Python 3.9+
- Google Gemini API Key (Get it here)
- MLB API Access (Public, no key required)
-
Clone the repository
git clone https://github.com/Eusha425/baseball-strategy-assistant.git cd baseball-strategy-assistant -
Set up a virtual environment
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Set up environment variables Create a
.envfile in the root directory:GEMINI_API_KEY=your_api_key_here
-
Run the app locally
streamlit run main.py
-
View the app Open your browser and navigate to
http://localhost:8501 -
Interact with the app
- The app automatically fetches live game data
- If no live games are available, it uses historical data for demonstration
- View real-time pitch insights with fun analogies!
baseball-strategy-assistant/
├── main.py # Streamlit app entry point
├── mlb_client/ # MLB API interactions
│ └── __init__.py
├── gemini_client/ # Gemini API integration
│ └── __init__.py
├── date_utils/ # Date-related utilities
│ └── __init__.py
├── .env # Environment variables
├── requirements.txt # Python dependencies
└── README.md # Project documentation
- Latency:
- MLB API: ~200ms
- Gemini API: ~500ms
- Supported Games:
- Live MLB games (when available)
- Historical games (fallback)
Contributions are welcome! Here's how you can help:
- Report Bugs: Open an issue with detailed steps to reproduce
- Suggest Features: Share your ideas for new features or improvements
- Submit Pull Requests: Follow the Contributing Guidelines
This project is licensed under the MIT License. See the LICENSE file for details.
- MLB API: For providing free access to live game data
- Google Gemini: For enabling AI-powered insights
- Streamlit: For making web app development simple and fast