Spaces:
Sleeping
Sleeping
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 |