A conversational AI assistant that provides insights and answers questions about Bundesliga football data. The project uses LangChain and OpenAI to create an intelligent agent that can analyze and discuss Bundesliga statistics, standings, and match data.
- Interactive chat interface using Streamlit
- Natural language processing for Bundesliga-related queries
- Multi-turn conversation support
- Data-driven insights about teams, players, and matches
- Dynamic data visualization capabilities
The Bundesliga Chat Assistant uses a multi-layered approach to answer questions:
-
Database Query Layer
- Primary source of information is the SQLite database
- Queries match information, player statistics, and team standings
- Uses natural language to SQL conversion for complex queries
- Maintains historical data and current season information
-
Web Search Fallback
- If information is not found in the database, the agent performs web searches
- Useful for recent news, transfers, or information not yet in the database
- Ensures up-to-date information even when database is not current
-
Plotting Agent
- Generates visualizations for statistical analysis
- Creates charts for:
- Team performance over time
- Player statistics comparisons
- League standings visualization
- Match result distributions
- Currently in development with basic plotting capabilities
-
Multi-Agent Architecture
- Uses LangGraph for orchestrating different specialized agents
- Each agent handles specific types of queries:
- Data retrieval agent
- Analysis agent
- Visualization agent
- Agents collaborate to provide comprehensive answers
- Python 3.8 or higher
- SQLite
- OpenAI API key
- Clone the repository:
git clone [repository-url]
cd football-bot- Create and activate 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:
# Copy the example environment file
cp env.example .env
# Edit the .env file with your actual values
# Required: OPENAI_API_KEY
# Optional: LANGSMITH_* variables for tracingThe database setup must be performed in the following order:
-
Create Games Table
- First, create the games table which contains match information
- This is the foundation for other tables
-
Calculate Standings
- After games are created, calculate the standings
- This depends on the games data being present
-
Create Goals Table
- Place the
cleaned_name_mapping.csvfile in thedatabase/datadirectory - This file contains player name mappings for unifying the players names (data quality issues)
- Create the goals table using this data
- Place the
-
Create SQLite Database
- The final step is to create the SQLite database
- This will combine all the tables into a single database file
- Run the Streamlit app:
streamlit run app.py- Alternatively, run the command-line version:
python main.pysrc/- Source code containing the Bundesliga agent implementationdatabase/- Database-related files and scriptsimages/- Project images and assetsapp.py- Streamlit web applicationmain.py- Command-line interfacerequirements.txt- Python dependencies
Once the application is running, you can:
- Ask questions about Bundesliga teams, players, and matches
- Get statistical insights and analysis
- Compare teams and players
- Query historical data and current standings
Contributions are welcome! Please feel free to submit a Pull Request.
[Add your license information here]