refactoring
This commit is contained in:
parent
5ee99664f3
commit
650c12d073
@ -9,27 +9,7 @@ import json
|
|||||||
from aiohttp import ClientSession, ClientTimeout
|
from aiohttp import ClientSession, ClientTimeout
|
||||||
from fastapi import FastAPI, Request, HTTPException, BackgroundTasks
|
from fastapi import FastAPI, Request, HTTPException, BackgroundTasks
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
from .constructors import ValidHookSongRequest, ValidAISongRequest
|
||||||
|
|
||||||
class ValidAISongRequest(BaseModel):
|
|
||||||
"""
|
|
||||||
- **a**: artist
|
|
||||||
- **s**: track title
|
|
||||||
"""
|
|
||||||
|
|
||||||
a: str
|
|
||||||
s: str
|
|
||||||
|
|
||||||
class ValidHookSongRequest(BaseModel):
|
|
||||||
"""
|
|
||||||
- **a**: artist
|
|
||||||
- **s**: track title
|
|
||||||
- **hook**: hook to return
|
|
||||||
"""
|
|
||||||
|
|
||||||
a: str
|
|
||||||
s: str
|
|
||||||
hook: str | None = ""
|
|
||||||
|
|
||||||
# pylint: enable=bad-indentation
|
# pylint: enable=bad-indentation
|
||||||
|
|
||||||
|
272
endpoints/constructors.py
Normal file
272
endpoints/constructors.py
Normal file
@ -0,0 +1,272 @@
|
|||||||
|
#!/usr/bin/env python3.12
|
||||||
|
|
||||||
|
from typing import Optional
|
||||||
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
# Constructors
|
||||||
|
# TODO: REORDER
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
AI
|
||||||
|
"""
|
||||||
|
|
||||||
|
class ValidAISongRequest(BaseModel):
|
||||||
|
"""
|
||||||
|
- **a**: artist
|
||||||
|
- **s**: track title
|
||||||
|
"""
|
||||||
|
|
||||||
|
a: str
|
||||||
|
s: str
|
||||||
|
|
||||||
|
class ValidHookSongRequest(BaseModel):
|
||||||
|
"""
|
||||||
|
- **a**: artist
|
||||||
|
- **s**: track title
|
||||||
|
- **hook**: hook to return
|
||||||
|
"""
|
||||||
|
|
||||||
|
a: str
|
||||||
|
s: str
|
||||||
|
hook: str | None = ""
|
||||||
|
|
||||||
|
"""
|
||||||
|
Karma
|
||||||
|
"""
|
||||||
|
|
||||||
|
class ValidKarmaUpdateRequest(BaseModel):
|
||||||
|
"""
|
||||||
|
Requires authentication
|
||||||
|
- **granter**: who updated the karma
|
||||||
|
- **keyword**: keyword to update karma for
|
||||||
|
- **flag**: either 0 (decrement) for --, or 1 (increment) for ++
|
||||||
|
"""
|
||||||
|
|
||||||
|
granter: str
|
||||||
|
keyword: str
|
||||||
|
flag: int
|
||||||
|
|
||||||
|
|
||||||
|
class ValidKarmaRetrievalRequest(BaseModel):
|
||||||
|
"""
|
||||||
|
- **keyword**: keyword to retrieve karma value of
|
||||||
|
"""
|
||||||
|
|
||||||
|
keyword: str
|
||||||
|
|
||||||
|
class ValidTopKarmaRequest(BaseModel):
|
||||||
|
"""
|
||||||
|
- **n**: Number of top results to return (default: 10)
|
||||||
|
"""
|
||||||
|
n: int | None = 10
|
||||||
|
|
||||||
|
"""
|
||||||
|
LastFM
|
||||||
|
"""
|
||||||
|
|
||||||
|
class ValidArtistSearchRequest(BaseModel):
|
||||||
|
"""
|
||||||
|
- **a**: artist name
|
||||||
|
"""
|
||||||
|
|
||||||
|
a: str
|
||||||
|
|
||||||
|
class Config: # pylint: disable=missing-class-docstring
|
||||||
|
schema_extra = {
|
||||||
|
"example": {
|
||||||
|
"a": "eminem"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ValidAlbumDetailRequest(BaseModel):
|
||||||
|
"""
|
||||||
|
- **a**: artist name
|
||||||
|
- **a2**: album/release name (as sourced from here/LastFM)
|
||||||
|
"""
|
||||||
|
|
||||||
|
a: str
|
||||||
|
a2: str
|
||||||
|
|
||||||
|
class Config: # pylint: disable=missing-class-docstring
|
||||||
|
schema_extra = {
|
||||||
|
"example": {
|
||||||
|
"a": "eminem",
|
||||||
|
"a2": "houdini"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ValidTrackInfoRequest(BaseModel):
|
||||||
|
"""
|
||||||
|
- **a**: artist name
|
||||||
|
- **t**: track
|
||||||
|
"""
|
||||||
|
|
||||||
|
a: str
|
||||||
|
t: str
|
||||||
|
|
||||||
|
class Config: # pylint: disable=missing-class-docstring
|
||||||
|
schema_extra = {
|
||||||
|
"example": {
|
||||||
|
"a": "eminem",
|
||||||
|
"t": "rap god"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
"""
|
||||||
|
Rand Msg
|
||||||
|
"""
|
||||||
|
|
||||||
|
class RandMsgRequest(BaseModel):
|
||||||
|
"""
|
||||||
|
- **short**: Short randmsg?
|
||||||
|
"""
|
||||||
|
|
||||||
|
short: Optional[bool] = False
|
||||||
|
|
||||||
|
"""
|
||||||
|
YT
|
||||||
|
"""
|
||||||
|
|
||||||
|
class ValidYTSearchRequest(BaseModel):
|
||||||
|
"""
|
||||||
|
- **t**: title to search
|
||||||
|
"""
|
||||||
|
|
||||||
|
t: str = "rick astley - never gonna give you up"
|
||||||
|
|
||||||
|
"""
|
||||||
|
XC
|
||||||
|
"""
|
||||||
|
|
||||||
|
class ValidXCRequest(BaseModel):
|
||||||
|
"""
|
||||||
|
- **key**: valid XC API key
|
||||||
|
- **bid**: bot id
|
||||||
|
- **cmd**: bot command
|
||||||
|
- **data**: command data
|
||||||
|
"""
|
||||||
|
|
||||||
|
key: str
|
||||||
|
bid: int
|
||||||
|
cmd: str
|
||||||
|
data: dict | None = None
|
||||||
|
|
||||||
|
"""
|
||||||
|
Transcriptions
|
||||||
|
"""
|
||||||
|
|
||||||
|
class ValidShowEpisodeListRequest(BaseModel):
|
||||||
|
"""
|
||||||
|
- **s**: show id
|
||||||
|
"""
|
||||||
|
|
||||||
|
s: int
|
||||||
|
|
||||||
|
class ValidShowEpisodeLineRequest(BaseModel):
|
||||||
|
"""
|
||||||
|
- **s**: show id
|
||||||
|
- **e**: episode id
|
||||||
|
"""
|
||||||
|
|
||||||
|
s: int
|
||||||
|
e: int
|
||||||
|
|
||||||
|
"""
|
||||||
|
Lyric Search
|
||||||
|
"""
|
||||||
|
|
||||||
|
class ValidLyricRequest(BaseModel):
|
||||||
|
"""
|
||||||
|
- **a**: artist
|
||||||
|
- **s**: song
|
||||||
|
- **t**: track (artist and song combined) [used only if a & s are not used]
|
||||||
|
- **extra**: include extra details in response [optional, default: false]
|
||||||
|
- **lrc**: Request LRCs?
|
||||||
|
- **sub**: text to search within lyrics, if found lyrics will begin at found verse [optional]
|
||||||
|
- **src**: the script/utility which initiated the request
|
||||||
|
- **excluded_sources**: sources to exclude (new only)
|
||||||
|
"""
|
||||||
|
|
||||||
|
a: str | None = None
|
||||||
|
s: str | None = None
|
||||||
|
t: str | None = None
|
||||||
|
sub: str | None = None
|
||||||
|
extra: bool | None = False
|
||||||
|
lrc: bool | None = False
|
||||||
|
src: str
|
||||||
|
excluded_sources: list | None = None
|
||||||
|
|
||||||
|
model_config = {
|
||||||
|
"json_schema_extra": {
|
||||||
|
"examples": [
|
||||||
|
{
|
||||||
|
"a": "eminem",
|
||||||
|
"s": "rap god",
|
||||||
|
"src": "WEB",
|
||||||
|
"extra": True,
|
||||||
|
"lrc": False,
|
||||||
|
"excluded_sources": [],
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class ValidTypeAheadRequest(BaseModel):
|
||||||
|
"""
|
||||||
|
- **query**: query string
|
||||||
|
"""
|
||||||
|
pre_query: str|None = None
|
||||||
|
query: str
|
||||||
|
|
||||||
|
"""
|
||||||
|
Radio
|
||||||
|
"""
|
||||||
|
|
||||||
|
class RadioException(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class ValidRadioSongRequest(BaseModel):
|
||||||
|
"""
|
||||||
|
- **key**: API Key
|
||||||
|
- **artist**: artist to search
|
||||||
|
- **song**: song to search
|
||||||
|
- **artistsong**: may be used IN PLACE OF artist/song to perform a combined/string search in the format "artist - song"
|
||||||
|
- **alsoSkip**: Whether to skip immediately to this track [not implemented]
|
||||||
|
"""
|
||||||
|
key: str
|
||||||
|
artist: str | None = None
|
||||||
|
song: str | None = None
|
||||||
|
artistsong: str | None = None
|
||||||
|
alsoSkip: bool = False
|
||||||
|
|
||||||
|
class ValidRadioNextRequest(BaseModel):
|
||||||
|
"""
|
||||||
|
- **key**: API Key
|
||||||
|
- **skipTo**: UUID to skip to [optional]
|
||||||
|
"""
|
||||||
|
key: str
|
||||||
|
skipTo: str|None = None
|
||||||
|
|
||||||
|
class ValidRadioReshuffleRequest(ValidRadioNextRequest):
|
||||||
|
"""
|
||||||
|
- **key**: API Key
|
||||||
|
"""
|
||||||
|
|
||||||
|
class ValidRadioQueueShiftRequest(BaseModel):
|
||||||
|
"""
|
||||||
|
- **key**: API Key
|
||||||
|
- **uuid**: UUID to shift
|
||||||
|
- **next**: Play next if true, immediately if false, default False
|
||||||
|
"""
|
||||||
|
key: str
|
||||||
|
uuid: str
|
||||||
|
next: bool = False
|
||||||
|
|
||||||
|
class ValidRadioQueueRemovalRequest(BaseModel):
|
||||||
|
"""
|
||||||
|
- **key**: API Key
|
||||||
|
- **uuid**: UUID to remove
|
||||||
|
"""
|
||||||
|
key: str
|
||||||
|
uuid: str
|
@ -9,34 +9,10 @@ import traceback
|
|||||||
import aiosqlite as sqlite3
|
import aiosqlite as sqlite3
|
||||||
from fastapi import FastAPI, Request, HTTPException
|
from fastapi import FastAPI, Request, HTTPException
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
from .constructors import ValidTopKarmaRequest, ValidKarmaRetrievalRequest,\
|
||||||
|
ValidKarmaUpdateRequest
|
||||||
|
|
||||||
|
|
||||||
class ValidKarmaUpdateRequest(BaseModel):
|
|
||||||
"""
|
|
||||||
Requires authentication
|
|
||||||
- **granter**: who updated the karma
|
|
||||||
- **keyword**: keyword to update karma for
|
|
||||||
- **flag**: either 0 (decrement) for --, or 1 (increment) for ++
|
|
||||||
"""
|
|
||||||
|
|
||||||
granter: str
|
|
||||||
keyword: str
|
|
||||||
flag: int
|
|
||||||
|
|
||||||
|
|
||||||
class ValidKarmaRetrievalRequest(BaseModel):
|
|
||||||
"""
|
|
||||||
- **keyword**: keyword to retrieve karma value of
|
|
||||||
"""
|
|
||||||
|
|
||||||
keyword: str
|
|
||||||
|
|
||||||
class ValidTopKarmaRequest(BaseModel):
|
|
||||||
"""
|
|
||||||
- **n**: Number of top results to return (default: 10)
|
|
||||||
"""
|
|
||||||
n: int | None = 10
|
|
||||||
|
|
||||||
class KarmaDB:
|
class KarmaDB:
|
||||||
"""Karma DB Util"""
|
"""Karma DB Util"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -5,54 +5,8 @@ import importlib
|
|||||||
import traceback
|
import traceback
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
from .constructors import ValidArtistSearchRequest, ValidAlbumDetailRequest,\
|
||||||
class ValidArtistSearchRequest(BaseModel):
|
ValidTrackInfoRequest
|
||||||
"""
|
|
||||||
- **a**: artist name
|
|
||||||
"""
|
|
||||||
|
|
||||||
a: str
|
|
||||||
|
|
||||||
class Config: # pylint: disable=missing-class-docstring
|
|
||||||
schema_extra = {
|
|
||||||
"example": {
|
|
||||||
"a": "eminem"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ValidAlbumDetailRequest(BaseModel):
|
|
||||||
"""
|
|
||||||
- **a**: artist name
|
|
||||||
- **a2**: album/release name (as sourced from here/LastFM)
|
|
||||||
"""
|
|
||||||
|
|
||||||
a: str
|
|
||||||
a2: str
|
|
||||||
|
|
||||||
class Config: # pylint: disable=missing-class-docstring
|
|
||||||
schema_extra = {
|
|
||||||
"example": {
|
|
||||||
"a": "eminem",
|
|
||||||
"a2": "houdini"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ValidTrackInfoRequest(BaseModel):
|
|
||||||
"""
|
|
||||||
- **a**: artist name
|
|
||||||
- **t**: track
|
|
||||||
"""
|
|
||||||
|
|
||||||
a: str
|
|
||||||
t: str
|
|
||||||
|
|
||||||
class Config: # pylint: disable=missing-class-docstring
|
|
||||||
schema_extra = {
|
|
||||||
"example": {
|
|
||||||
"a": "eminem",
|
|
||||||
"t": "rap god"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class LastFM(FastAPI):
|
class LastFM(FastAPI):
|
||||||
"""Last.FM Endpoints"""
|
"""Last.FM Endpoints"""
|
||||||
|
@ -12,52 +12,12 @@ import aiohttp
|
|||||||
import aiosqlite as sqlite3
|
import aiosqlite as sqlite3
|
||||||
from fastapi import FastAPI, HTTPException
|
from fastapi import FastAPI, HTTPException
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
from .constructors import ValidTypeAheadRequest, ValidLyricRequest
|
||||||
from lyric_search.sources import aggregate
|
from lyric_search.sources import aggregate
|
||||||
from lyric_search import notifier
|
from lyric_search import notifier
|
||||||
|
|
||||||
|
|
||||||
class ValidLyricRequest(BaseModel):
|
|
||||||
"""
|
|
||||||
- **a**: artist
|
|
||||||
- **s**: song
|
|
||||||
- **t**: track (artist and song combined) [used only if a & s are not used]
|
|
||||||
- **extra**: include extra details in response [optional, default: false]
|
|
||||||
- **lrc**: Request LRCs?
|
|
||||||
- **sub**: text to search within lyrics, if found lyrics will begin at found verse [optional]
|
|
||||||
- **src**: the script/utility which initiated the request
|
|
||||||
- **excluded_sources**: sources to exclude (new only)
|
|
||||||
"""
|
|
||||||
|
|
||||||
a: str | None = None
|
|
||||||
s: str | None = None
|
|
||||||
t: str | None = None
|
|
||||||
sub: str | None = None
|
|
||||||
extra: bool | None = False
|
|
||||||
lrc: bool | None = False
|
|
||||||
src: str
|
|
||||||
excluded_sources: list | None = None
|
|
||||||
|
|
||||||
model_config = {
|
|
||||||
"json_schema_extra": {
|
|
||||||
"examples": [
|
|
||||||
{
|
|
||||||
"a": "eminem",
|
|
||||||
"s": "rap god",
|
|
||||||
"src": "WEB",
|
|
||||||
"extra": True,
|
|
||||||
"lrc": False,
|
|
||||||
"excluded_sources": [],
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class ValidTypeAheadRequest(BaseModel):
|
|
||||||
"""
|
|
||||||
- **query**: query string
|
|
||||||
"""
|
|
||||||
pre_query: str|None = None
|
|
||||||
query: str
|
|
||||||
|
|
||||||
class CacheUtils:
|
class CacheUtils:
|
||||||
"""Lyrics Cache DB Utils"""
|
"""Lyrics Cache DB Utils"""
|
||||||
|
@ -11,6 +11,8 @@ import asyncio
|
|||||||
import regex
|
import regex
|
||||||
import music_tag
|
import music_tag
|
||||||
from . import radio_util
|
from . import radio_util
|
||||||
|
from .constructors import ValidRadioNextRequest, ValidRadioReshuffleRequest, ValidRadioQueueShiftRequest,\
|
||||||
|
ValidRadioQueueRemovalRequest, ValidRadioSongRequest, RadioException
|
||||||
from uuid import uuid4 as uuid
|
from uuid import uuid4 as uuid
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
@ -24,58 +26,7 @@ double_space = regex.compile(r'\s{2,}')
|
|||||||
TODO:
|
TODO:
|
||||||
minor refactoring/type annotations/docstrings
|
minor refactoring/type annotations/docstrings
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class RadioException(Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ValidRadioSongRequest(BaseModel):
|
|
||||||
"""
|
|
||||||
- **key**: API Key
|
|
||||||
- **artist**: artist to search
|
|
||||||
- **song**: song to search
|
|
||||||
- **artistsong**: may be used IN PLACE OF artist/song to perform a combined/string search in the format "artist - song"
|
|
||||||
- **alsoSkip**: Whether to skip immediately to this track [not implemented]
|
|
||||||
"""
|
|
||||||
key: str
|
|
||||||
artist: str | None = None
|
|
||||||
song: str | None = None
|
|
||||||
artistsong: str | None = None
|
|
||||||
alsoSkip: bool = False
|
|
||||||
|
|
||||||
class ValidRadioNextRequest(BaseModel):
|
|
||||||
"""
|
|
||||||
- **key**: API Key
|
|
||||||
- **skipTo**: UUID to skip to [optional]
|
|
||||||
"""
|
|
||||||
key: str
|
|
||||||
skipTo: str|None = None
|
|
||||||
|
|
||||||
class ValidRadioReshuffleRequest(ValidRadioNextRequest):
|
|
||||||
"""
|
|
||||||
- **key**: API Key
|
|
||||||
"""
|
|
||||||
|
|
||||||
class ValidRadioQueueShiftRequest(BaseModel):
|
|
||||||
"""
|
|
||||||
- **key**: API Key
|
|
||||||
- **uuid**: UUID to shift
|
|
||||||
- **next**: Play next if true, immediately if false, default False
|
|
||||||
"""
|
|
||||||
key: str
|
|
||||||
uuid: str
|
|
||||||
next: bool = False
|
|
||||||
|
|
||||||
class ValidRadioQueueRemovalRequest(BaseModel):
|
|
||||||
"""
|
|
||||||
- **key**: API Key
|
|
||||||
- **uuid**: UUID to remove
|
|
||||||
"""
|
|
||||||
key: str
|
|
||||||
uuid: str
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,13 +6,7 @@ from typing import Optional
|
|||||||
import aiosqlite as sqlite3
|
import aiosqlite as sqlite3
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
from .constructors import RandMsgRequest
|
||||||
class RandMsgRequest(BaseModel):
|
|
||||||
"""
|
|
||||||
- **short**: Short randmsg?
|
|
||||||
"""
|
|
||||||
|
|
||||||
short: Optional[bool] = False
|
|
||||||
|
|
||||||
class RandMsg(FastAPI):
|
class RandMsg(FastAPI):
|
||||||
"""Random Message Endpoint"""
|
"""Random Message Endpoint"""
|
||||||
|
@ -4,22 +4,8 @@ import os
|
|||||||
import aiosqlite as sqlite3
|
import aiosqlite as sqlite3
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
from .constructors import ValidShowEpisodeLineRequest, ValidShowEpisodeListRequest
|
||||||
|
|
||||||
class ValidShowEpisodeListRequest(BaseModel):
|
|
||||||
"""
|
|
||||||
- **s**: show id
|
|
||||||
"""
|
|
||||||
|
|
||||||
s: int
|
|
||||||
|
|
||||||
class ValidShowEpisodeLineRequest(BaseModel):
|
|
||||||
"""
|
|
||||||
- **s**: show id
|
|
||||||
- **e**: episode id
|
|
||||||
"""
|
|
||||||
|
|
||||||
s: int
|
|
||||||
e: int
|
|
||||||
|
|
||||||
class Transcriptions(FastAPI):
|
class Transcriptions(FastAPI):
|
||||||
"""Transcription Endpoints"""
|
"""Transcription Endpoints"""
|
||||||
|
@ -4,21 +4,7 @@
|
|||||||
from fastapi import FastAPI, Request, HTTPException
|
from fastapi import FastAPI, Request, HTTPException
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from aiohttp import ClientSession, ClientTimeout
|
from aiohttp import ClientSession, ClientTimeout
|
||||||
|
from .constructors import ValidXCRequest
|
||||||
class ValidXCRequest(BaseModel):
|
|
||||||
"""
|
|
||||||
- **key**: valid XC API key
|
|
||||||
- **bid**: bot id
|
|
||||||
- **cmd**: bot command
|
|
||||||
- **data**: command data
|
|
||||||
"""
|
|
||||||
|
|
||||||
key: str
|
|
||||||
bid: int
|
|
||||||
cmd: str
|
|
||||||
data: dict | None = None
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class XC(FastAPI):
|
class XC(FastAPI):
|
||||||
"""XC (CrossComm) Endpoints"""
|
"""XC (CrossComm) Endpoints"""
|
||||||
|
@ -3,14 +3,7 @@
|
|||||||
import importlib
|
import importlib
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
from .constructors import ValidYTSearchRequest
|
||||||
class ValidYTSearchRequest(BaseModel):
|
|
||||||
"""
|
|
||||||
- **t**: title to search
|
|
||||||
"""
|
|
||||||
|
|
||||||
t: str = "rick astley - never gonna give you up"
|
|
||||||
|
|
||||||
|
|
||||||
class YT(FastAPI):
|
class YT(FastAPI):
|
||||||
"""YT Endpoints"""
|
"""YT Endpoints"""
|
||||||
|
@ -12,7 +12,7 @@ class GPT:
|
|||||||
api_key=self.api_key,
|
api_key=self.api_key,
|
||||||
timeout=10.0,
|
timeout=10.0,
|
||||||
)
|
)
|
||||||
self.default_system_prompt = "You are a helpful assistant who will provide tidbits of info on songs the user may listen to."
|
self.default_system_prompt = "You are a helpful assistant who will provide only totally accurate tidbits of info on the specific songs the user may listen to."
|
||||||
|
|
||||||
async def get_completion(self, prompt: str, system_prompt: Optional[str] = None) -> None:
|
async def get_completion(self, prompt: str, system_prompt: Optional[str] = None) -> None:
|
||||||
if not system_prompt:
|
if not system_prompt:
|
||||||
@ -29,5 +29,6 @@ class GPT:
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
model="gpt-4o-mini",
|
model="gpt-4o-mini",
|
||||||
|
temperature=0.35,
|
||||||
)
|
)
|
||||||
return chat_completion.choices[0].message.content
|
return chat_completion.choices[0].message.content
|
Loading…
x
Reference in New Issue
Block a user