14 lines
419 B
Python
14 lines
419 B
Python
from openai import OpenAI
|
|
#from config import Config
|
|
|
|
class OpenAIClient:
|
|
def __init__(self, api_key=None):
|
|
self.api_key = api_key #or Config.OPENAI_API_KEY
|
|
if not self.api_key:
|
|
raise ValueError("OpenAI API key not provided.")
|
|
self.client = OpenAI(api_key=api_key)
|
|
|
|
|
|
def create_completion(self, **kwargs):
|
|
return self.client.chat.completions.create(**kwargs)
|