Update main.py
Browse files
main.py
CHANGED
|
@@ -264,8 +264,9 @@ async def process_gemini(client, chat_id, prompt):
|
|
| 264 |
else:
|
| 265 |
history.append({"role": "user", "parts":[{"text": prompt}]})
|
| 266 |
|
| 267 |
-
|
| 268 |
-
|
|
|
|
| 269 |
if history[0]["role"] == "model":
|
| 270 |
history = history[1:]
|
| 271 |
|
|
|
|
| 264 |
else:
|
| 265 |
history.append({"role": "user", "parts":[{"text": prompt}]})
|
| 266 |
|
| 267 |
+
# تغییر تاریخچه به ۴۰ مورد برای ذخیره کردن ۲۰ سوال و جواب (۲۰ پیام رفت و برگشت)
|
| 268 |
+
if len(history) > 40:
|
| 269 |
+
history = history[-40:]
|
| 270 |
if history[0]["role"] == "model":
|
| 271 |
history = history[1:]
|
| 272 |
|