Music shopping assistant

In this assignment you are going to construct a python function that implements a music shopping assistant. You will pass the function the name of a recording artist and the function will determine the name of that artist's most recent release, do a web search to find pages that might offer that release for sale, and then return both the name of the recording and a URL to a page that appears to be most likely to be offering that title for sale.

I have written a solution for this assignment, and here are some examples of the results it returns:

recordingURL("Tame Impala")
{'release': 'The Slow Rush', 'url': 'https://www.ebay.com/p/2317114103'}
recordingURL("Robert Hood")
{'release': 'DJ Kicks: Robert Hood',
 'url': 'https://k7records.bandcamp.com/album/dj-kicks-robert-hood'}
recordingURL("Flying Lotus")
{'release': 'Flamagra',
 'url': 'https://sound-merch.com.au/collections/flying-lotus'}
recordingURL("Underworld (band)")
{'release': 'Barking', 'url': 'https://store.underworldlive.com/'}

What to do

Here are the steps your recordingURL() function should do:

  1. Run a Wikipedia query to get the artist's discography
  2. Pass the text from this query to the LLM and ask the LLM to return the name of the artist's most recent recording.
  3. Do a web search to find 10 pages that offer that recording by that artist for sale.
  4. For each URL that the web search returns, scrape that page and collect the first 1000 characters from the page.
  5. Pass all of the URLs and all of the associated scraped text to the LLM and ask it which page is most likely to offer the recording for sale. Have the LLM return just the URL for the most promising page.
  6. Have your function return a dictionary containing the name of the release and the URL of the page where you are most likely to be able to purchase that release.

Helpful hint

To do the Wikipedia search you will use the Langchain WikipediaLoader class. One problem with that class is that it defaults to returning only the first 4000 characters from any query you ask it to do. For many artists it will take more then 4000 characters to get to the part of their Wikipedia page that lists the artist's discography. To overcome this character limitation, add the parameter doc_content_chars_max = 12000 when you are setting up the loader.