Nassiraaa commited on
Commit
b2bf633
·
verified ·
1 Parent(s): 9b1f4ee

Update openai_utils.py

Browse files
Files changed (1) hide show
  1. openai_utils.py +4 -3
openai_utils.py CHANGED
@@ -3,6 +3,7 @@ from openai import OpenAI
3
 
4
  # OpenAI configuration
5
  client = OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))
 
6
 
7
  def get_ai_response(messages):
8
  """
@@ -11,11 +12,11 @@ def get_ai_response(messages):
11
  :return: The content of the AI's response
12
  """
13
  try:
14
- chat_completion = client.chat.completions.create(
15
- model="gpt-3.5-turbo",
16
  messages=messages
17
  )
18
- return chat_completion.choices[0].message.content
19
  except Exception as e:
20
  print(f"Error getting AI response: {str(e)}")
21
  return None
 
3
 
4
  # OpenAI configuration
5
  client = OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))
6
+ OPENAI_MODEL = "gpt-3.5-turbo"
7
 
8
  def get_ai_response(messages):
9
  """
 
12
  :return: The content of the AI's response
13
  """
14
  try:
15
+ response = client.chat.completions.create(
16
+ model=OPENAI_MODEL,
17
  messages=messages
18
  )
19
+ return response.choices[0].message.content
20
  except Exception as e:
21
  print(f"Error getting AI response: {str(e)}")
22
  return None