Live Coding session video! Click here
This is an intro to AI (LLM) Agents using LangChain. The goal is to use natural language commands towards Spotify player to be able to play certain songs. Example queries: "Play Despacito", "I know a song that goes like I was running through the six with my woes. Play me that song", etc..
Please follow the instructions below to setup the project. Play with it, and build on top of it!
- Python
- LangChain (ReAct Agent)
- Spotipy
- Spotify
- OpenAI API
-
Sign up for Spotify and Spotify API (developer.spotify.com)
-
Sign up for OpenAI API Key (platform.openai.com)
-
Create a
.env
file and put these values inOPENAI_API_KEY=********************** SPOTIFY_CLIENT_ID=******************* SPOTIFY_CLIENT_SECRET=*************** SPOTIFY_REDIRECT_URI=****************
-
Create a new Python virtual environment
-
python -m venv spotify-chat
(Mac) -
py -m venv spotify-chat
(Windows 11)
-
-
Install Python requirements in the project repository:
pip install -r requirements.txt
-
Open a Spotify Player (Web or Local)
-
Hit play to activate the player (otherwise Spotify Web API won't recognize it). Then pause.
-
Start virtual environment manually by running:
-
source spotify-chat/bin/activate
(Mac) -
.\spotify-chat\Scripts\activate
(Windows 11)
-
-
Start script: In your Powershell (Windows) or Terminal (Mac), run either
py main.py
(Windows 11) orpython main.py
(Mac)
- If new dependencies are added, add them manually to
requirements.txt