readinglevelconverter / text_generator.py
Mjwarren3's picture
Addind real application
7b28cbc
raw
history blame
438 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-3.5-turbo",
messages=[
{"role": "system", "content": system_prompt},
{"role": "user", "content": user_prompt}
],
)
return completion.choices[0].message.content