llama-index readers genius integration
Project description
LlamaIndex Readers Integration: Genius
pip install llama-index-readers-genius
This loader connects to the Genius API and loads lyrics, metadata, and album art into Documents.
As a prerequisite, you will need to register with Genius API and create an app in order to get a client_id and a client_secret. You should then set a redirect_uri for the app. The redirect_uri does not need to be functional. You should then generate an access token as an instantiator for the GeniusReader.
Usage
Here's an example usage of the GeniusReader. It will retrieve songs that match specific lyrics. Acceptable arguments are lyrics (str): The lyric snippet you're looking for and will return List[Document]: A list of documents containing songs with those lyrics.
GeniusReader Class Methods
load_artist_songs
- Description: Fetches all or a specified number of songs by an artist.
- Arguments:
artist_name(str): The name of the artist.max_songs(Optional[int]): Maximum number of songs to retrieve.
- Returns: List of
Documentobjects with song lyrics.
load_all_artist_songs
- Description: Fetches all songs of an artist and saves their lyrics.
- Arguments:
artist_name(str): The name of the artist.
- Returns: List of
Documentobjects with the artist's song lyrics.
load_artist_songs_with_filters
- Description: Loads the most or least popular song of an artist based on filters.
- Arguments:
artist_name(str): The artist's name.most_popular(bool):Truefor most popular song,Falsefor least popular.max_songs(Optional[int]): Max number of songs to consider for popularity.max_pages(int): Max number of pages to fetch.
- Returns:
Documentwith lyrics of the selected song.
load_song_by_url_or_id
- Description: Loads a song by its Genius URL or ID.
- Arguments:
song_url(Optional[str]): URL of the song on Genius.song_id(Optional[int]): ID of the song on Genius.
- Returns: List of
Documentobjects with the song's lyrics.
search_songs_by_lyrics
- Description: Searches for songs by a snippet of lyrics.
- Arguments:
lyrics(str): Lyric snippet to search for.
- Returns: List of
Documentobjects with songs matching the lyrics.
load_songs_by_tag
- Description: Loads songs by a specific tag or genre.
- Arguments:
tag(str): Tag or genre to search for.max_songs(Optional[int]): Max number of songs to fetch.max_pages(int): Max number of pages to fetch.
- Returns: List of
Documentobjects with song lyrics.
from llama_index.readers.genius import GeniusReader
access_token = "your_generated_access_token"
loader = GeniusReader(access_token)
documents = loader.search_songs_by_lyrics("Imagine")
Example
This loader is designed to be used as a way to load data into LlamaIndex.
LlamaIndex
from llama_index.core import VectorStoreIndex, download_loader
from llama_index.readers.genius import GeniusReader
access_token = "your_generated_access_token"
loader = GeniusReader(access_token)
documents = loader.search_songs_by_lyrics("Imagine")
index = VectorStoreIndex.from_documents(documents)
index.query(
"What artists have written songs that have the lyrics imagine in them?"
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llama_index_readers_genius-0.4.0.tar.gz.
File metadata
- Download URL: llama_index_readers_genius-0.4.0.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eded7ef2a6910ec8a20320b93582e452ce3620bf23ca3bc99fc77cde2619ca56
|
|
| MD5 |
41e2cf5a840e56d30a33322d03cc0ed0
|
|
| BLAKE2b-256 |
19cf92699ab1acdd8701704a95468fb7922cf4b3060abaddb12b6657b1ca2a21
|
File details
Details for the file llama_index_readers_genius-0.4.0-py3-none-any.whl.
File metadata
- Download URL: llama_index_readers_genius-0.4.0-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aad9e8aaacb62980c17a28d32fe22e7fe19d75745f224aa59b4f8744cd02e46b
|
|
| MD5 |
17c6a5dc9dcf83d28b4dcf0313d73003
|
|
| BLAKE2b-256 |
0b663f9551f4bd50072a8bd11fdbabe9fe3aafda13c0de1c916a75de46a649c7
|