class OpenaiClassifier():
def __init__(self, api_keys):
openai.api_key = api_keys['Openai']
def get_ratings(self, review):
prompt = f"Rate the following review as an integer from 1 to 5, where 1 is the worst and 5 is the best: \"{review}\""
response = openai.Completion.create(
engine="text-davinci-003",
prompt=prompt,
n=1,
max_tokens=5,
temperature=0.5,
top_p=1
)
try:
rating = int(response.choices[0].text.strip())
return rating
except ValueError:
return None
I wonder what's the main difference between /v1/completions and /v1/chat/completions endpoints, and how I can do text classification using these models: gpt-4, gpt-4-0314, gpt-4-32k, gpt-4-32k-0314, gpt-3.5-turbo, gpt-3.5-turbo-0301