fix: update generate_humor_dataset.py to use new OpenAI Python client API

This commit is contained in:
Kirill Igumenshchev (aider) 2025-05-18 17:23:57 -07:00
parent aa8a1ed416
commit 7e3f32b296

View file

@ -1,11 +1,11 @@
import os
import json
from dotenv import load_dotenv
import openai
from openai import OpenAI
def main():
load_dotenv()
openai.api_key = os.getenv("OPENAI_API_KEY")
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
comedians = [
"Norm Macdonald",
@ -31,7 +31,7 @@ def main():
f"Whats the best local LLM model to generate {fmt} jokes "
f"in the style of {comedian}? Please explain your reasoning step by step."
)
response = openai.ChatCompletion.create(
response = client.chat.completions.create(
model=model_name,
messages=[{"role": "user", "content": question}],
)