Spaces:
Runtime error
Runtime error
File size: 688 Bytes
3e22b88 e22d4b7 3e22b88 e22d4b7 3e22b88 e22d4b7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
from openai import OpenAI
import os
client = OpenAI()
class BaseLLM:
def __init__(self, model):
self.model = model
def get_response(self, system_prompt, query):
raise NotImplementedError
class OpenAILLM(BaseLLM):
def __init__(self, model):
self.model = model
def get_response(self, system_prompt, query, **kwargs):
response = client.chat.completions.create(
model=self.model,
messages=[
{"role": "system", "content": system_prompt},
{"role": "user", "content": query},
],
**kwargs,
)
return response.choices[0].message.content |