small improvements

This commit is contained in:
ned
2023-06-22 20:13:02 +02:00
parent cc9f33b1d3
commit 0b0771aaa4
3 changed files with 25 additions and 24 deletions

View File

@@ -36,13 +36,12 @@ class SpotifyPlugin(Plugin):
"type": "string", "type": "string",
"enum": ["short_term", "medium_term", "long_term"], "enum": ["short_term", "medium_term", "long_term"],
"description": "The time range of the data to be returned. Short term is the last 4 weeks, " "description": "The time range of the data to be returned. Short term is the last 4 weeks, "
"medium term is last 6 months, long term is last several years. " "medium term is last 6 months, long term is last several years. Default to "
"Ignore if action is currently_playing", "short_term if not specified."
} }
limit_param = { limit_param = {
"type": "integer", "type": "integer",
"description": "The number of results to return. Max is 50. Default to 5 if not specified." "description": "The number of results to return. Max is 50. Default to 5 if not specified.",
"Ignore if action is currently_playing",
} }
type_param = { type_param = {
"type": "string", "type": "string",
@@ -60,7 +59,7 @@ class SpotifyPlugin(Plugin):
}, },
{ {
"name": "spotify_get_users_top_artists", "name": "spotify_get_users_top_artists",
"description": "Get the user's top artists", "description": "Get the user's top listened artists",
"parameters": { "parameters": {
"type": "object", "type": "object",
"properties": { "properties": {
@@ -71,7 +70,7 @@ class SpotifyPlugin(Plugin):
}, },
{ {
"name": "spotify_get_users_top_tracks", "name": "spotify_get_users_top_tracks",
"description": "Get the user's top tracks", "description": "Get the user's top listened tracks",
"parameters": { "parameters": {
"type": "object", "type": "object",
"properties": { "properties": {
@@ -262,7 +261,8 @@ class SpotifyPlugin(Plugin):
else: else:
return {'error': 'Invalid search type. Must be track, artist or album'} return {'error': 'Invalid search type. Must be track, artist or album'}
def _get_artist(self, response, albums): @staticmethod
def _get_artist(response, albums):
return { return {
'name': response['name'], 'name': response['name'],
'url': response['external_urls']['spotify'], 'url': response['external_urls']['spotify'],
@@ -281,7 +281,8 @@ class SpotifyPlugin(Plugin):
], ],
} }
def _get_track(self, response): @staticmethod
def _get_track(response):
return { return {
'name': response['name'], 'name': response['name'],
'artist': response['artists'][0]['name'], 'artist': response['artists'][0]['name'],
@@ -295,7 +296,8 @@ class SpotifyPlugin(Plugin):
'explicit': response['explicit'], 'explicit': response['explicit'],
} }
def _get_album(self, response): @staticmethod
def _get_album(response):
return { return {
'name': response['name'], 'name': response['name'],
'artist': response['artists'][0]['name'], 'artist': response['artists'][0]['name'],

View File

@@ -15,6 +15,13 @@ class WeatherPlugin(Plugin):
return "OpenMeteo" return "OpenMeteo"
def get_spec(self) -> [Dict]: def get_spec(self) -> [Dict]:
latitude_param = {"type": "string", "description": "Latitude of the location"}
longitude_param = {"type": "string", "description": "Longitude of the location"}
unit_param = {
"type": "string",
"enum": ["celsius", "fahrenheit"],
"description": "The temperature unit to use. Infer this from the provided location.",
}
return [ return [
{ {
"name": "get_current_weather", "name": "get_current_weather",
@@ -22,13 +29,9 @@ class WeatherPlugin(Plugin):
"parameters": { "parameters": {
"type": "object", "type": "object",
"properties": { "properties": {
"latitude": {"type": "string", "description": "Latitude of the location"}, "latitude": latitude_param,
"longitude": {"type": "string", "description": "Longitude of the location"}, "longitude": longitude_param,
"unit": { "unit": unit_param,
"type": "string",
"enum": ["celsius", "fahrenheit"],
"description": "The temperature unit to use. Infer this from the provided location.",
},
}, },
"required": ["latitude", "longitude", "unit"], "required": ["latitude", "longitude", "unit"],
}, },
@@ -40,13 +43,9 @@ class WeatherPlugin(Plugin):
"parameters": { "parameters": {
"type": "object", "type": "object",
"properties": { "properties": {
"latitude": {"type": "string", "description": "Latitude of the location"}, "latitude": latitude_param,
"longitude": {"type": "string", "description": "Longitude of the location"}, "longitude": longitude_param,
"unit": { "unit": unit_param,
"type": "string",
"enum": ["celsius", "fahrenheit"],
"description": "The temperature unit to use. Infer this from the provided location.",
},
"forecast_days": { "forecast_days": {
"type": "integer", "type": "integer",
"description": "The number of days to forecast, including today. Default is 7. Max 14. " "description": "The number of days to forecast, including today. Default is 7. Max 14. "

View File

@@ -37,7 +37,7 @@ class WebSearchPlugin(Plugin):
region='wt-wt', region='wt-wt',
safesearch='off' safesearch='off'
) )
results = list(islice(ddgs_gen, 8)) results = list(islice(ddgs_gen, 3))
if results is None or len(results) == 0: if results is None or len(results) == 0:
return {"Result": "No good DuckDuckGo Search Result was found"} return {"Result": "No good DuckDuckGo Search Result was found"}