An AI-powered Spotify playlist assistant that uses the Agno framework to orchestrate multiple AI agents. The system creates personalized playlists based on natural language descriptions of mood and preferences.
demo.mp4
- Natural Language Playlist Creation: Describe your mood, genre preferences, or situation to create custom playlists
- Multi-Agent AI System: Uses specialized AI agents for text analysis, music curation, and Spotify operations
- Web Interface: Clean, Material Design-inspired UI with real-time streaming responses
- Conversation Memory: PostgreSQL-backed memory for context-aware conversations
- OAuth Integration: Secure Spotify authentication flow
-
Multi-Agent System (
spotify_playlist/spotify_assistant.py):- Expert Text Analyzer: Analyzes user input for mood/preferences
- Expert Music Curator: Searches for songs based on analysis
- Spotify API Expert: Handles all Spotify operations
- Uses Azure OpenAI GPT-4 with Agno framework
-
Spotify Toolkit (
spotify_playlist/spotify_toolkit.py):- Custom tools for Spotify API operations
- Functions: search_song, create_playlist, add_song_to_playlist, play_song, get_user_top_genres
-
Web API (
api/):- FastAPI application with streaming chat endpoint
- OAuth2 authentication flow for Spotify
- Server-Sent Events for real-time AI responses
-
Frontend (
static/index3.html):- Material Design-inspired UI
- Real-time streaming responses with markdown rendering
- Quick suggestion buttons for common requests
- Docker & Docker Compose (required for both deployment methods)
- Spotify Developer Account
- Azure OpenAI Account
- Serper API Key (for web search)
- Python 3.12+ (only for local development)
git clone https://github.com/NTTLuke/spotify-playlist-agno.git
cd spotify-playlist-agno-
Copy the environment template:
cp .env.example .env
-
Edit
.envwith your API keys and configuration:nano .env # or your preferred editorRequired Environment Variables:
# Azure OpenAI (Required) AZURE_OPENAI_API_KEY=your_azure_openai_api_key AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com/ AZURE_OPENAI_DEPLOYMENT_NAME=your_deployment # Spotify OAuth (Required) SPOTIFY_CLIENT_ID=your_spotify_client_id SPOTIFY_CLIENT_SECRET=your_spotify_client_secret SPOTIFY_REDIRECT_URI=http://localhost:8000/callback # Serper API for web search (Required) SERPER_API_KEY=your_serper_api_key
The easiest way to run the application is using Docker Compose, which handles both the database and the FastAPI application.
# Start both database and FastAPI application
docker-compose up -dThis command will:
- Build the FastAPI application container
- Start the PostgreSQL database
- Configure networking between services
- Set up all environment variables automatically
# View application logs
docker-compose logs -f
# View logs for specific service
docker-compose logs -f app
docker-compose logs -f db
# Rebuild application after code changes
docker-compose up --build -d app
# Stop all services
docker-compose down
# Stop and remove all data (including database)
docker-compose down -v- Web Interface: http://localhost:8000/
- API Documentation: http://localhost:8000/docs
If you prefer to run the FastAPI application locally while using Docker only for the database:
Using uv (recommended):
pip install uv
uv syncOr using pip:
pip install -r requirements.txtdocker-compose up -d dbuvicorn api.main:app --reload- Web Interface: http://localhost:8000
- API Documentation: http://localhost:8000/docs
- Go to Spotify Developer Dashboard
- Create a new app
- Add redirect URI:
http://localhost:8000/callback - Copy the Client ID and Client Secret to your
.envfile
- Create an Azure OpenAI resource
- Deploy an OpenAI model
- Copy the API key, endpoint, and deployment name to your
.envfile
- Go to OpenAI Platform
- Create an API key
- Copy the API key to your
.envfile
- Go to Serper.dev
- Sign up and get your API key
- Add it to your
.envfile
- The
.envfile is in.gitignoreand should never be committed - All sensitive configuration uses environment variables
- Default database credentials are for development only - change them in production
- The secret key should be changed in production environments
- Open http://localhost:8000
- Click "Login with Spotify" to authenticate
- Start chatting with the AI assistant
- Use natural language to describe the playlist you want:
- "Create a playlist for a rainy Sunday morning"
- "I need energetic workout music"
- "Make me a chill playlist for studying"
- Alternatively, you can use the suggested buttons on top
GET /- Web interfaceGET /login- Spotify OAuth loginGET /callback- OAuth callbackPOST /chat/- Chat with the assistant (requires authentication)GET /auth/status- Check authentication status
βββ api/ # FastAPI application
β βββ core/ # Core configuration and logging
β βββ routers/ # API route handlers
β βββ models/ # Request/response models
βββ spotify_playlist/ # AI assistant and Spotify toolkit
βββ static/ # Frontend assets
βββ docker-compose.yaml # PostgreSQL database setup
spotify_playlist/spotify_assistant.py- Main AI assistant with multi-agent systemspotify_playlist/spotify_toolkit.py- Spotify API operationsapi/routers/chat.py- Chat endpoint with streaming responsesapi/core/config.py- Application configurationstatic/index3.html- Web interface
Currently, there are no automated tests configured. This would be a good area for contribution.
No linting configuration is currently set up. Consider adding tools like ruff or black for code formatting.
- Fork the repository
- Create a feature branch
- Make your changes
- Ensure no sensitive information is committed
- Submit a pull request
[Add your license information here]
-
Database Connection Error:
- Ensure Docker is running:
docker-compose up -d - Check database credentials in
.env
- Ensure Docker is running:
-
Spotify Authentication Failed:
- Verify your Spotify Client ID and Secret
- Ensure redirect URI matches exactly:
http://localhost:8000/callback
-
Azure OpenAI API Error:
- Check your API key and endpoint
- Verify your deployment name
- Ensure you have sufficient quota
-
Import Errors:
- Make sure all dependencies are installed:
uv sync - Check Python version (requires 3.12+)
- Make sure all dependencies are installed:
The application logs to the console. Set LOG_LEVEL=DEBUG in your .env file for detailed logging.