Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -42,13 +42,16 @@ def chat_bot():
|
|
| 42 |
first_message = False
|
| 43 |
history.append({"role": "user", "content": message})
|
| 44 |
|
| 45 |
-
# Use the
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
| 52 |
history.append({"role": "assistant", "content": response})
|
| 53 |
|
| 54 |
# Trim history to keep within the word limit
|
|
|
|
| 42 |
first_message = False
|
| 43 |
history.append({"role": "user", "content": message})
|
| 44 |
|
| 45 |
+
# Use the Cosmo-RP model for the completion request
|
| 46 |
+
try:
|
| 47 |
+
response = openai.Completion.create(
|
| 48 |
+
model="Cosmo-RP",
|
| 49 |
+
prompt="\n".join([msg['content'] for msg in history]),
|
| 50 |
+
max_tokens=150
|
| 51 |
+
).choices[0].text.strip()
|
| 52 |
+
except Exception as e:
|
| 53 |
+
return jsonify({"error": str(e)}), 500
|
| 54 |
+
|
| 55 |
history.append({"role": "assistant", "content": response})
|
| 56 |
|
| 57 |
# Trim history to keep within the word limit
|