dudynets / Telegram-Summarize-Bot

A Telegram bot that summarizes messages from a chat using AI.
MIT License
31 stars 7 forks source link

Too many requests #2

Open abatie opened 1 month ago

abatie commented 1 month ago

I installed the bot and added it to a test group on Telegram, with just a handful of test messages. When I do a /summarize reply to one of the first messages, after the apg/generate, there are three getUpdates calls, the first one has 10 editMessageText calls after it, the next one 7, and the third one 3, then it gets "HTTP/1.1 429 Too Many Requests" (the number of calls for the 2nd and 3rd call vary, but add up to 10 each time). It does generate some output, but stops in the middle, presumably because of the errors...

botlog.txt

abatie commented 1 month ago

Here's a patch; the x='' is a hack, I admit, as I'm rusty with python and not sure how to get it to loop with no body, but it works...

diff --git a/src/app.py b/src/app.py
index 3feba02..3b25b55 100644
--- a/src/app.py
+++ b/src/app.py
@@ -61,10 +61,15 @@ async def summarize_handler(update: Update, context: CallbackContext) -> None:

     for partial_response in summary_generator:
         try:
-            await response_message.edit_text(partial_response)
+            x = ''
         except Exception:
             pass

+    try:
+        await response_message.edit_text(partial_response)
+    except Exception:
+        pass
+

 def error_handler(update: Update, context: CallbackContext):
     """