readinglevelconverter / text_generator.py
Mjwarren3's picture
Update text_generator.py
6199d6d verified
raw
history blame
436 Bytes
from openai import OpenAI
import os
OPENAI_APIKEY = os.environ.get("OPENAI_APIKEY")
client = OpenAI(api_key=OPENAI_APIKEY)
def get_gpt_response(user_prompt, system_prompt):
completion = client.chat.completions.create(
model="gpt-4-turbo",
messages=[
{"role": "system", "content": system_prompt},
{"role": "user", "content": user_prompt}
],
)
return completion.choices[0].message.content