cleanup
This commit is contained in:
@ -3,16 +3,18 @@ from typing import Optional
|
||||
from openai import AsyncOpenAI
|
||||
|
||||
class GPT:
|
||||
def __init__(self, constants):
|
||||
def __init__(self, constants) -> None:
|
||||
self.constants = constants
|
||||
self.api_key = self.constants.OPENAI_API_KEY
|
||||
self.client = AsyncOpenAI(
|
||||
self.api_key: str = self.constants.OPENAI_API_KEY
|
||||
self.client: AsyncOpenAI = AsyncOpenAI(
|
||||
api_key=self.api_key,
|
||||
timeout=10.0,
|
||||
)
|
||||
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."
|
||||
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."""
|
||||
|
||||
async def get_completion(self, prompt: str, system_prompt: Optional[str] = None) -> str:
|
||||
async def get_completion(self, prompt: str,
|
||||
system_prompt: Optional[str] = None) -> Optional[str]:
|
||||
if not system_prompt:
|
||||
system_prompt = self.default_system_prompt
|
||||
chat_completion = await self.client.chat.completions.create(
|
||||
@ -29,4 +31,5 @@ class GPT:
|
||||
model="gpt-4o-mini",
|
||||
temperature=0.35,
|
||||
)
|
||||
return chat_completion.choices[0].message.content
|
||||
response: Optional[str] = chat_completion.choices[0].message.content
|
||||
return response
|
Reference in New Issue
Block a user