Medvira commited on
Commit
09887b9
·
verified ·
1 Parent(s): ff9c6e0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -8,7 +8,7 @@ OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
8
  if not OPENAI_API_KEY:
9
  raise ValueError("API key not found. Please set the OPENAI_API_KEY environment variable.")
10
 
11
- openai.api_key = OPENAI_API_KEY
12
 
13
  global_system_prompt = None
14
  global_model = 'gpt-4'
@@ -57,7 +57,7 @@ def convert_history_to_openai_format(history):
57
 
58
  def bot(history):
59
  global global_model
60
- response = openai.ChatCompletion.create(
61
  model=global_model,
62
  messages=convert_history_to_openai_format(history)
63
  )
 
8
  if not OPENAI_API_KEY:
9
  raise ValueError("API key not found. Please set the OPENAI_API_KEY environment variable.")
10
 
11
+ client = OpenAI(api_key=OPENAI_API_KEY)
12
 
13
  global_system_prompt = None
14
  global_model = 'gpt-4'
 
57
 
58
  def bot(history):
59
  global global_model
60
+ response = client.chat.completions.create(
61
  model=global_model,
62
  messages=convert_history_to_openai_format(history)
63
  )