From 0eed64cbb3035e5a2d49faf976ab65c15832f70e Mon Sep 17 00:00:00 2001 From: Jonathan Lucas Date: Mon, 2 Jun 2025 15:23:20 -0500 Subject: [PATCH] Removed unnecessary awaits --- base_telegram_inference_bot.py | 1 - openai_compatible_inference_bot.py | 2 +- telegram_helper.py | 10 +++++----- ...ndalone_llm_tool.py => standalone_llm_tool.py_test} | 0 4 files changed, 6 insertions(+), 7 deletions(-) rename tools/{standalone_llm_tool.py => standalone_llm_tool.py_test} (100%) diff --git a/base_telegram_inference_bot.py b/base_telegram_inference_bot.py index 410ce18..23e38ab 100644 --- a/base_telegram_inference_bot.py +++ b/base_telegram_inference_bot.py @@ -66,7 +66,6 @@ class BaseTelegramInferenceBot(ABC): if user_id in self.conversation_history: del self.conversation_history[user_id] - # Assuming tool.clear() is for global state or doesn't need user_id for tool in self.tools: tool.clear() diff --git a/openai_compatible_inference_bot.py b/openai_compatible_inference_bot.py index eae60fe..14e02cc 100644 --- a/openai_compatible_inference_bot.py +++ b/openai_compatible_inference_bot.py @@ -63,7 +63,7 @@ class OpenAICompatibleInferenceBot(BaseTelegramInferenceBot): tool_calls_from_response.extend(response.choices[0].message.tool_calls) tool_use_count = 0 - MAX_TOOL_ITERATIONS = 5 + MAX_TOOL_ITERATIONS = 200 while tool_calls_from_response and tool_use_count < MAX_TOOL_ITERATIONS: tool_results_for_model = [] diff --git a/telegram_helper.py b/telegram_helper.py index e3c83cc..9ede863 100644 --- a/telegram_helper.py +++ b/telegram_helper.py @@ -28,7 +28,7 @@ class TelegramHelper: async def clear(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: user_id = update.effective_user.id - await self.bot.clear_conversation_history(user_id) + self.bot.clear_conversation_history(user_id) await update.message.reply_text("Conversation history cleared. Let's start fresh!") async def status(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: @@ -61,13 +61,13 @@ class TelegramHelper: logging.info(f"Message from user {user_id}: {user_message}") - status_message = await update.message.reply_text("Processing your request...", reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("Abort", callback_data='abort')]]))\ - await self.bot.set_processing_status(user_id, status_message.message_id) + status_message = await update.message.reply_text("Processing your request...", reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("Abort", callback_data='abort')]])) + self.bot.set_processing_status(user_id, status_message.message_id) response = await self.bot.handle_message(user_id, user_message) await context.bot.delete_message(chat_id=update.effective_chat.id, message_id=status_message.message_id) - await self.bot.clear_processing_status(user_id) + self.bot.clear_processing_status(user_id) response = response.replace("", self.HTML_QUOTE_BLOCK_START).replace("", self.HTML_QUOTE_BLOCK_END) @@ -126,7 +126,7 @@ class TelegramHelper: application.add_handler(CommandHandler("status", self.status)) application.add_handler(CommandHandler("reboot", self.reboot)) application.add_handler(CommandHandler("browse", self.browse)) - application.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, self.handle_message))\ + application.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, self.handle_message)) application.add_handler(CallbackQueryHandler(self.abort_processing, pattern='^abort$')) application.add_handler(CallbackQueryHandler(button_callback, pattern='^(browse|file):')) diff --git a/tools/standalone_llm_tool.py b/tools/standalone_llm_tool.py_test similarity index 100% rename from tools/standalone_llm_tool.py rename to tools/standalone_llm_tool.py_test