An AI experimental project where an AI bot gives you music recommendations based on your preferences and mood.
This project was built for learning and portfolio purposes. It explores:
- Building REST APIs with FastAPI
- Integrating local LLMs using Ollama
- Prompt engineering for personalized responses
- Input your musical preferences (name, genres, artists, mood)
- Get personalized music recommendations powered by a local LLM
- Clean, fast API responses with detailed explanations
- Python 3.10+
- Ollama installed with
gemma2:9bmodel
-
Clone the repository
-
Create and activate virtual environment:
python3 -m venv .venv
source .venv/bin/activate- Install dependencies:
pip install -r requirements.txt- Make sure Ollama is running with the model:
ollama pull gemma2:9b
ollama serve- Start the API:
uvicorn app.main:app --reload- Access the API docs at
http://127.0.0.1:8000/docs
Step 1: Register your preferences
curl -X POST http://127.0.0.1:8000/users \
-H "Content-Type: application/json" \
-d '{"name": "Your Name", "genres": ["rock", "indie"], "artists": ["Radiohead"], "mood": "melancholic"}'Step 2: Get recommendations
curl http://127.0.0.1:8000/recommendationsSend everything in one request:
curl -X POST http://127.0.0.1:8000/recommendations/direct \
-H "Content-Type: application/json" \
-d '{"name": "Your Name", "genres": ["rock", "indie"], "artists": ["Radiohead"], "mood": "melancholic"}'| Endpoint | Method | Description |
|---|---|---|
/users |
POST | Register user preferences |
/recommendations |
GET | Get recommendations (uses saved data) |
/recommendations/direct |
POST | Get recommendations (pass data directly) |
/docs |
GET | Swagger UI documentation |
- Integrate LangChain for better LLM orchestration
- Add observability with Langfuse or LangSmith
- Track metrics: latency, tokens used, request history
- FastAPI - Web framework
- Ollama - Local LLM runner
- gemma2:9b - LLM model
- Pydantic - Data validation