jisaacso219 commited on
Commit
9f5f4c0
·
verified ·
1 Parent(s): 67180b7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -44,9 +44,9 @@ def chat():
44
  "audio_url": None
45
  })
46
 
47
- # call OpenAI ChatCompletion with a cost-efficient model
48
  try:
49
- resp = openai.ChatCompletion.create(
50
  model="gpt-3.5-turbo",
51
  messages=[
52
  {"role": "system", "content": SYSTEM_PROMPT},
@@ -55,7 +55,7 @@ def chat():
55
  temperature=0.7,
56
  max_tokens=250,
57
  )
58
- reply = resp.choices[0].message.content.strip()
59
  except Exception as e:
60
  print(f"❌ OpenAI API error: {e}", file=sys.stderr)
61
  return jsonify({"error": "Model error", "details": str(e)}), 500
 
44
  "audio_url": None
45
  })
46
 
47
+ # call OpenAI using the new 1.x interface
48
  try:
49
+ completion = openai.chat.completions.create(
50
  model="gpt-3.5-turbo",
51
  messages=[
52
  {"role": "system", "content": SYSTEM_PROMPT},
 
55
  temperature=0.7,
56
  max_tokens=250,
57
  )
58
+ reply = completion.choices[0].message.content.strip()
59
  except Exception as e:
60
  print(f"❌ OpenAI API error: {e}", file=sys.stderr)
61
  return jsonify({"error": "Model error", "details": str(e)}), 500