I have been playing around with OpenAI / ChatGPT and created a Roon extension that goes with it. It’s inspired by the Sonic Sage feature currently available in Plex Amp.
Short description:
Extension that uses OpenAI to generates playlists based on a prompt
Description:
This extensions uses OpenAI (using your own API Key) or ChatGPT (requires GPT Plus) to generate playlists. It currently has the following features:
Use GPT-4 or GPT-3
Verifies songs with Spotify (for cover image and song names)
Matches songs with your Roon library
Option to select a different versions of a song
Show OpenAI search history and spent tokens
Requirements
Using the Open AI feature of the extension requires an Open AI API Key. You can find your API keys in your User settings of Open AI. It also requires a “Pay-as-you-go” account with sufficient credits.
Installation
Installing the AI Guest DJ extension can be done via Docker or using NPM. See the Github or NPM link below. It is build using Next.Js so it requires a minimum node version 18.
Thanks! Strange that this is happening. I’ve just updated the extension so it gives you more meaning full messages. My first thought would be that the API key is not correct.
A bit more. When using your updated container and the extension with GPT-3 (3.5?), I was getting a “Network Error”. I tried it a few times and it changed to this:
When using the Open AI feature in the extension it uses the API key that you provide. The only place where the API key is present is in the environment variable due to security concerns. It doesn’t use that key with the custom GPT. But I’m not sure how Open AI measures quotas. I haven’t experienced a lot of quota limitations using the API.
It seems to be a credits/account-type issue. Could you check if your account is setup in such a way that it supports GPT-4?
Using Open AI API or a custom GPT requires an Open AI account with sufficient credits. In most scenarios the “Pay as you go” approach with the API is the cheapest. I played around with the API a lot and it takes some effort to reach the $20 mark.
Edit: I also noticed that sometimes it fails to return a valid JSON object. I’m working on a solution for this.
My question about API key usage wasn’t regarding where it’s stored, but about where it’s used. You were clearly wondering if I’d set it up correctly in my yaml file. I was trying to figure out if the fact that the custom GPT worked was an indicator that I had.
I have a ChatGPT “Plus” subscription. I thought that was enough to get me API access but you’re correct that it isn’t. I set up a billing/quota for API usage and I’m able to use the extension now. You might want to specifically clarify this.
I showed this to my wife and she was pretty excited. She prompted something like:
“An EDM mix for working out. Tracks should be at least 80 BPM and high energy”
She liked what she got but one oddity about the mix is that it had at least one track on it that was a karaoke version of a well-known contemporary song. I wonder if your GPT prompt could be modified to say something like:
“Do not include karaoke versions of songs unless you have been explicitly asked to do so” or something like that.
Anyhow…thanks again!
Edit: Watchtower picked up your latest which does now display stack traces
Great to hear that it’s working! I will update the extension this week with your suggestion. My first thought is to add the option to view and modify the instructions passed to OpenAI.
I’m also working on a user area to view, modify and expand previously created playlists. This will also include the option to remove songs from the generated playlist. Building this area will take a bit of time though.
@gTunes A new version is ready in docker. With the option to modify the way Open AI is handeling prompts.
@DrCWO Would it be possible to add this extension to RooExtend as well? Or does RooExtend always require node version 8. The UI is build using Next.JS and that has a minimum node version of 18.
Hi Jaap, noce work!
Node 18 will be fine
I currently offer rooAIDJ that also offers to get playlists with ChatGPT. With it an iOS App is available for iPhone, iPad, Mac and Apple Watch.
But this already attracts my attention and @Klaus_Engel will try soon. After discussion with him we will decide what to do.
This won‘t happen before I‘m back from my South East Asia trip end of April. So you have all your time for further improvements.
Is your Roon Extension compatible with the Roon Extension Manager?
How can I verify the compatibility with the extension manager? I now simply use the roon-kit to make it work. I couldn’t find any where to add my own extension to the extension manager.
Thanks for the update! I should have time to play with it later today.
rooExtend, from @DrCWO, supports Roon Extension Manager and my recommendation would be for you to get your extension into it. That would mean that anyone running Roon Extension Manager, on any platform, would have access.
Since extensions running in Extension Manager run in docker containers, and you’ve already worked most of that out, it might be pretty straightforward for you to get yours working there.
I assume you have a large, more complex prompt somewhere that tells ChatGPT that it is an expert DJ who is going to make playlists on request. Is that correct? So this supplements that?
That’s correct. This only appends to some larger explanation of how it should respond. The goal is that you should be able to finetune your personal preferences. My configuration is currently as follows:
Each playlist should contain at least 30 songs.
You should create meaning-full matches between the songs.
Do not include any instrumental or karaoke songs.
I like larger playlists. But it does take a bit longer to generate those and it costs more tokens.
Thanks for the docs of the extension-manager. It seems pretty straight forward so I will dive into that as soon as I get the chance.
I’ve played around a bit and to be honest it’s a challenge to get to 200. Often it simply denies the request saying that it cannot create a playlist with that data (GPT-3.5) or it only returns 25 tracks (GPT-4). Only when adding multiple genres to the request I got to something a bit larger.
The created playlists seem to cost around the 1700-2000 tokens. Even the larger one.
Using Chat-GPT confirms my thoughts as it begins saying “Generate a playlist of at least 200 songs is challenging”. The first try ended with 15 songs only.
Please share your findings when you do play around with it! The first feeling I have is that you really need to specify a broad selection with multiple genres and multiple era’s.
A month has passed and I had some time to work on an update for AI Guest DJ. It has now been added to the Roon Extension manager so the installation process is way easier! Thanks @Jan_Koudijs for your help
Note: I was forced to rename the docker repository name for it to work with the Roon Extension Manager integration. So the original docker image is not updated. My advice would be to simply re-install via the extension manager.