Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -44,9 +44,9 @@ def chat():
|
|
44 |
"audio_url": None
|
45 |
})
|
46 |
|
47 |
-
# call OpenAI
|
48 |
try:
|
49 |
-
|
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 =
|
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
|