Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,12 +18,13 @@ def chat():
|
|
| 18 |
|
| 19 |
prompt = data["prompt"]
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
| 24 |
)
|
| 25 |
|
| 26 |
-
return jsonify(response
|
| 27 |
|
| 28 |
except Exception as e:
|
| 29 |
return jsonify({"error": str(e)}), 500
|
|
|
|
| 18 |
|
| 19 |
prompt = data["prompt"]
|
| 20 |
|
| 21 |
+
# ✅ Use the new OpenAI API syntax
|
| 22 |
+
response = openai.chat.completions.create(
|
| 23 |
+
model="gpt-3.5-turbo", # Ensure correct model name
|
| 24 |
+
messages=[{"role": "user", "content": prompt}]
|
| 25 |
)
|
| 26 |
|
| 27 |
+
return jsonify({"response": response.choices[0].message.content})
|
| 28 |
|
| 29 |
except Exception as e:
|
| 30 |
return jsonify({"error": str(e)}), 500
|