Welcome to the Fantrax Fantasy Hockey Analysis app! This application leverages Google Gemini AI, LangChain, and a forked version of Fantrax API to help you manage your fantasy hockey team effectively. You can view your current roster, available players, and receive AI-powered recommendations for improving your team's standing in the league. Built to play around with fantasy hockey data and LLM-tech with my family's league. And to find a way to win! Available at Streamlit Community Cloud For those without a Fantrax League, you can see a short video demo here.
demo.mp4
- Login and Session Management: Authenticate with your Fantrax account to access private league information.
- AI-Powered Recommendations: Google Gemini provides personalized recommendations to enhance your team's standing.
- Chat with your Team: Chat with the team, where user is the GM and the chatbot acts as the head coach.
- Chat with your Team-Agent Style: Coach has access to tools to answer your questions (search, roster, free-agent lookup). Updated to use Groq.
- Python 3.8+ is required.
- Streamlit, Fantrax API, LangChain, Google Generative AI, and other dependencies need to be installed.
-
Clone the Repository
git clone https://github.com/yourusername/fantasy-hockey-analysis.git cd fantasy-hockey-analysis
-
Install Dependencies Use
pip
to install the required Python packages.pip install -r requirements.txt
-
Set Up Optional Secret Environment Variables
- Google API Key: Obtain an API key for Google Gemini and store it in the
./streamlit/secrets.toml
file with the keygemini_key
. Used in concert withleague_whitelist
, will bypass entering the API key on every render. - League Whitelist: List of league ids where we want to use the
gemini_key
above to skip entering the API key on every render. - Default Stats: For rotisserie based leagues, you can establish a default stat to display in the
default_stat
variable insecrets.toml
- Ollama info for Agent Chat: For running locally,
ollama_server
points to your local Ollama instance andollama_model
is your model of choice. - Groq info for Agent Chat: For running locally,
groq_api_key
is your Groq API key.
- Google API Key: Obtain an API key for Google Gemini and store it in the
-
Run the Application Start the Streamlit application.
streamlit run Home.py
- Home.py: Main entry point for the Streamlit application, which initializes the session, shows the league standings and AI-powered recommendations.
- Chat_With_Yer_Team.py: Chatbot functionality
- Chat_With_Yer_Team-Agent.py: Leverages tools for searching and looking up roster, free-agent and standings info.
- utils.py: Helper functions for transforming data to a usable format.
- requirements.txt: Lists the required packages for running the app.
- Login: Use your Fantrax credentials to log in on the Home page
- Chat with your team: Chat with the team, where the user is the GM and the chatbot acts as the head coach.
- Chat with your team-Agent Style: Chat with the team, where the user is the GM and the chatbot acts as the head coach. Uses Groq.
- Streamlit: Web framework for building the UI of the app.
- Fantrax API: A forked version supporting rotisserie based leagues, to fetch data such as roster, available players, and standings. Will try to get these into upstream master at some point.
- LangChain & Google Generative AI (Gemini): To interact with Google Gemini for generating strategic recommendations.
- LangChain & Groq: To interact with Groq for generating strategic recommendations.
- Advanced Visualization: Add more charts and visual aids to show changes in team performance after applying recommendations.
- User Preferences: Allow customization of AI recommendation settings, such as risk tolerance or positional needs.
- Tune the Agent Chat: Experiment with different tooling, system instructions and LLMs.
- Cannot Connect to Google Gemini: Check your API key and ensure it is correctly set in the environment variables.
- Button Actions Not Reflecting: Sometimes buttons may need to use
st.experimental_set_query_params()
for proper reruns.
Feel free to fork this repository, submit pull requests, or suggest features. Any contributions to improve the functionality or expand the app are welcome.
This project is licensed under the MIT License.
For questions or support, please reach out at [[email protected]].