remove karma endpoints from schema + add webhook notification for debugging (failed lyrics searches, non-LRC)

This commit is contained in:
codey 2025-05-01 06:32:28 -04:00
parent 8848d3a493
commit ad43db289a
6 changed files with 21 additions and 17 deletions

View File

@ -152,7 +152,7 @@ class Karma(FastAPI):
for endpoint, handler in self.endpoints.items(): for endpoint, handler in self.endpoints.items():
app.add_api_route( app.add_api_route(
f"/{endpoint}", handler, methods=["POST"], include_in_schema=True f"/{endpoint}", handler, methods=["POST"], include_in_schema=False
) )
async def top_karma_handler( async def top_karma_handler(

View File

@ -168,6 +168,10 @@ class LyricSearch(FastAPI):
) )
if not result: if not result:
if not data.lrc:
await self.notifier.send(
"DEBUG", f"Could not locate lyrics, request was:\n`{data}`"
)
return JSONResponse( return JSONResponse(
content={ content={
"err": True, "err": True,

View File

@ -149,15 +149,12 @@ class Radio(FastAPI):
"duration": item.get("duration"), "duration": item.get("duration"),
} }
) )
fallback_playlist_len: int = len( full_playlist_len: int = len(orig_queue)
orig_queue filtered_len: int = len(queue_full)
) # Used if search term is provided
out_json = { out_json = {
"draw": data.draw, "draw": data.draw,
"recordsTotal": ( "recordsTotal": full_playlist_len,
len(queue_full) if not data.search else fallback_playlist_len "recordsFiltered": filtered_len,
),
"recordsFiltered": (len(queue_full)),
"items": queue_out, "items": queue_out,
} }
return JSONResponse(content=out_json) return JSONResponse(content=out_json)

View File

@ -1,3 +1,4 @@
import logging
from typing import Optional from typing import Optional
from openai import AsyncOpenAI from openai import AsyncOpenAI
@ -13,6 +14,8 @@ class GPT:
self.default_system_prompt: str = """You are a helpful assistant who will provide only totally accurate tidbits of \ self.default_system_prompt: str = """You are a helpful assistant who will provide only totally accurate tidbits of \
info on the specific songs the user may listen to.""" info on the specific songs the user may listen to."""
logging.getLogger("httpx").setLevel("CRITICAL")
async def get_completion( async def get_completion(
self, prompt: str, system_prompt: Optional[str] = None self, prompt: str, system_prompt: Optional[str] = None
) -> Optional[str]: ) -> Optional[str]:

View File

@ -332,13 +332,13 @@ class RadioUtil:
# GROUP BY artistdashsong ORDER BY RANDOM()' # GROUP BY artistdashsong ORDER BY RANDOM()'
""" """
LIMITED GENRES FULL
""" """
# db_query: str = ( db_query: str = (
# 'SELECT distinct(LOWER(TRIM(artist)) || " - " || LOWER(TRIM(song))), (TRIM(artist) || " - " || TRIM(song))' 'SELECT distinct(LOWER(TRIM(artist)) || " - " || LOWER(TRIM(song))), (TRIM(artist) || " - " || TRIM(song))'
# "AS artistdashsong, id, artist, song, album, file_path, duration FROM tracks" "AS artistdashsong, id, artist, song, album, file_path, duration FROM tracks"
# ) )
""" """
LIMITED TO ONE/SMALL SUBSET OF GENRES LIMITED TO ONE/SMALL SUBSET OF GENRES
@ -351,8 +351,8 @@ class RadioUtil:
LIMITED TO ONE/SOME ARTISTS... LIMITED TO ONE/SOME ARTISTS...
""" """
db_query = 'SELECT distinct(artist || " - " || song) AS artistdashsong, id, artist, song, album, file_path, duration FROM tracks\ # db_query = 'SELECT distinct(artist || " - " || song) AS artistdashsong, id, artist, song, album, file_path, duration FROM tracks\
WHERE (artist LIKE "%chunk!%") AND (NOT song LIKE "%%stripped%%" AND NOT song LIKE "%(2022)%" AND NOT song LIKE "%(live%%" AND NOT song LIKE "%%acoustic%%" AND NOT song LIKE "%%instrumental%%" AND NOT song LIKE "%%remix%%" AND NOT song LIKE "%%reimagined%%" AND NOT song LIKE "%%alternative%%" AND NOT song LIKE "%%unzipped%%") GROUP BY artistdashsong ORDER BY RANDOM()' # ORDER BY album ASC, id ASC' # WHERE (artist LIKE "%sullivan king%") AND (NOT song LIKE "%%stripped%%" AND NOT song LIKE "%(2022)%" AND NOT song LIKE "%(live%%" AND NOT song LIKE "%%acoustic%%" AND NOT song LIKE "%%instrumental%%" AND NOT song LIKE "%%remix%%" AND NOT song LIKE "%%reimagined%%" AND NOT song LIKE "%%alternative%%" AND NOT song LIKE "%%unzipped%%") GROUP BY artistdashsong ORDER BY RANDOM()' # ORDER BY album ASC, id ASC'
# db_query = 'SELECT distinct(artist || " - " || song) AS artistdashsong, id, artist, song, album, genre, file_path, duration FROM tracks\ # db_query = 'SELECT distinct(artist || " - " || song) AS artistdashsong, id, artist, song, album, genre, file_path, duration FROM tracks\
# WHERE (artist LIKE "%sullivan king%" OR artist LIKE "%kayzo%" OR artist LIKE "%adventure club%") AND (NOT song LIKE "%%stripped%%" AND NOT song LIKE "%(2022)%" AND NOT song LIKE "%(live%%" AND NOT song LIKE "%%acoustic%%" AND NOT song LIKE "%%instrumental%%" AND NOT song LIKE "%%remix%%" AND NOT song LIKE "%%reimagined%%" AND NOT song LIKE "%%alternative%%" AND NOT song LIKE "%%unzipped%%") GROUP BY artistdashsong ORDER BY RANDOM()'# ORDER BY album ASC, id ASC' # WHERE (artist LIKE "%sullivan king%" OR artist LIKE "%kayzo%" OR artist LIKE "%adventure club%") AND (NOT song LIKE "%%stripped%%" AND NOT song LIKE "%(2022)%" AND NOT song LIKE "%(live%%" AND NOT song LIKE "%%acoustic%%" AND NOT song LIKE "%%instrumental%%" AND NOT song LIKE "%%remix%%" AND NOT song LIKE "%%reimagined%%" AND NOT song LIKE "%%alternative%%" AND NOT song LIKE "%%unzipped%%") GROUP BY artistdashsong ORDER BY RANDOM()'# ORDER BY album ASC, id ASC'