File size: 436 Bytes
7b28cbc
 
 
 
 
 
 
 
 
6199d6d
7b28cbc
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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