Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add patches arguments description #144

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions troi/patches/ai_jams.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class AiJamsPatch(Patch):
""" Generate a playlist using AI from the given prompt. """
"""Generate a playlist using AI from the given prompt."""

@staticmethod
def inputs():
Expand All @@ -18,8 +18,8 @@ def inputs():
PROMPT is the description of the playlist to generate.
"""
return [
{"type": "argument", "args": ["api_key"]},
{"type": "argument", "args": ["prompt"]}
{"type": "argument", "args": ["api_key"], "kwargs": {"help-text": "The OpenAI api key"}},
{"type": "argument", "args": ["prompt"], "kwargs": {"help-text": "The description of the playlist to generate"}},
]

@staticmethod
Expand All @@ -35,19 +35,21 @@ def description():
return "Generate a playlist using AI from the given prompt."

def create(self, inputs):
api_key = inputs['api_key']
prompt = inputs['prompt'].strip()
api_key = inputs["api_key"]
prompt = inputs["prompt"].strip()

ai_recordings_lookup = troi.external.gpt.GPTRecordingElement(api_key, prompt)

recs_lookup = troi.musicbrainz.mbid_mapping.MBIDMappingLookupElement(remove_unmatched=True)
recs_lookup = troi.musicbrainz.mbid_mapping.MBIDMappingLookupElement(
remove_unmatched=True
)
recs_lookup.set_sources(ai_recordings_lookup)

pl_maker = PlaylistMakerElement(
patch_slug=self.slug(),
max_num_recordings=50,
max_artist_occurrence=2,
shuffle=False
shuffle=False,
)
pl_maker.set_sources(recs_lookup)

Expand Down
7 changes: 5 additions & 2 deletions troi/patches/lb_radio.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,17 @@ def inputs():
"args": ["mode"],
"kwargs": {
"required": True,
"nargs": 1
"nargs": 1,
"help-text": "Which mode to generate playlists in. Must be one of easy, mediumedium, hard",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, typo. "mediumedium"

"choices": ["easy", "mediumedium", "hard"],
}
}, {
"type": "argument",
"args": ["prompt"],
"kwargs": {
"required": True,
"nargs": 1
"nargs": 1,
"help-text": "The LB radio prompt. See troi/parse_prompt.py for details.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A better link for docs is this one: https://troi.readthedocs.io/en/latest/lb_radio.html

}
}]

Expand Down
11 changes: 8 additions & 3 deletions troi/patches/periodic_jams.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,23 @@ def inputs():
"""
return [{
"type": "argument",
"args": ["user_name"]
"args": ["user_name"], "kwargs": {"help-text": "A MusicBrainz user name that has an account on ListenBrainz."}

}, {
"type": "argument",
"args": ["type"],
"kwargs": {
"required": False
"required": False,
"choices": ["daily-jams", "weekly-jams", "weekly-exploration"],
"help-text": "Must be one of daily-jams, weekly-jams or weekly-exploration"
}
}, {
"type": "argument",
"args": ["jam_date"],
"kwargs": {
"required": False
"required": False,
"help-text": "The date for which the jam is created (this is needed to account for the fact different timezones \
can be on different dates). Required formatting for the date is 'YYYY-MM-DD'"
}
}]

Expand Down
4 changes: 2 additions & 2 deletions troi/patches/playlist_from_listenbrainz.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ def inputs():
to LB again which is many times not desirable.
"""
return [
{"type": "argument", "args": ["mbid"], "kwargs": {"required": False}},
{"type": "argument", "args": ["mbid"], "kwargs": {"required": False, "help-text": "the playlist mbid to save."}},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please reformat this block too, now grown too large.

{"type": "argument", "args": ["jspf"], "kwargs": {"required": False}},
{"type": "argument", "args": ["read_only_token"], "kwargs": {"required": False}}
{"type": "argument", "args": ["read_only_token"], "kwargs": {"required": False, "help-text": "The listenbrainz auth token to retrieve the playlist if its private."}}
]

@staticmethod
Expand Down
15 changes: 10 additions & 5 deletions troi/patches/playlist_from_ms.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ImportPlaylistPatch(Patch):
@staticmethod
def inputs():
"""
A patch that retrieves an existing playlist from Spotify for use in Troi.
A patch that retrieves an existing playlist from Spotify/Apple Music/SoundCloud for use in Troi.

\b
MS_TOKEN is the music service token from which the playlist is retrieved. For now, only Spotify tokens are accepted.
Expand All @@ -22,10 +22,15 @@ def inputs():
APPLE_USER_TOKEN is the apple user token. Optional, if music services is not Apple Music
"""
return [
{"type": "argument", "args": ["ms_token"], "kwargs": {"required": False}},
{"type": "argument", "args": ["playlist_id"], "kwargs": {"required": False}},
{"type": "argument", "args": ["music_service"], "kwargs": {"required": False}},
{"type": "argument", "args": ["apple_user_token"], "kwargs": {"required": False}},
{"type": "argument", "args": ["ms_token"], "kwargs": {"required": False, "help-text": "The music service token from which the playlist is retrieved. For now, only Spotify tokens are accepted." }},
{"type": "argument", "args": ["playlist_id"], "kwargs": {"required": False, "help-text": "The playlist id to retrieve the tracks from it"}},
{"type": "argument", "args": ["music_service"],
"kwargs": {
"required": False,
"help-text": "The music service from which the playlist is retrieved : Spotify/Apple Music/SoundCloud",
"choices": ["Spotify", "Apple Music", "SoundCloud"]
}},
{"type": "argument", "args": ["apple_user_token"], "kwargs": {"required": False, "help-text": "The apple user token. Optional, if music services is not Apple Music"}},
]

@staticmethod
Expand Down
Loading