Skip to content

Commit

Permalink
fix: migrate to latest openai api
Browse files Browse the repository at this point in the history
  • Loading branch information
geeknik committed Feb 12, 2025
1 parent 26972a7 commit 1b4798e
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions hypertune/core.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import openai
from openai import OpenAI

client = OpenAI()
import numpy as np
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.metrics.pairwise import cosine_similarity
Expand All @@ -25,19 +27,17 @@ def generate(self):
frequency_penalty = round(random.uniform(0.0, 2.0), 2)
presence_penalty = round(random.uniform(0.0, 2.0), 2)

response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": self.prompt}
],
temperature=temperature,
top_p=top_p,
frequency_penalty=frequency_penalty,
presence_penalty=presence_penalty
)
response = client.chat.completions.create(model="gpt-4o",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": self.prompt}
],
temperature=temperature,
top_p=top_p,
frequency_penalty=frequency_penalty,
presence_penalty=presence_penalty)
results.append({
'text': response['choices'][0]['message']['content'],
'text': response.choices[0].message.content,
'hyperparameters': {
'temperature': temperature,
'top_p': top_p,
Expand Down

0 comments on commit 1b4798e

Please sign in to comment.