Removed unnecessary awaits
This commit is contained in:
@@ -66,7 +66,6 @@ class BaseTelegramInferenceBot(ABC):
|
|||||||
if user_id in self.conversation_history:
|
if user_id in self.conversation_history:
|
||||||
del self.conversation_history[user_id]
|
del self.conversation_history[user_id]
|
||||||
|
|
||||||
# Assuming tool.clear() is for global state or doesn't need user_id
|
|
||||||
for tool in self.tools:
|
for tool in self.tools:
|
||||||
tool.clear()
|
tool.clear()
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ class OpenAICompatibleInferenceBot(BaseTelegramInferenceBot):
|
|||||||
tool_calls_from_response.extend(response.choices[0].message.tool_calls)
|
tool_calls_from_response.extend(response.choices[0].message.tool_calls)
|
||||||
|
|
||||||
tool_use_count = 0
|
tool_use_count = 0
|
||||||
MAX_TOOL_ITERATIONS = 5
|
MAX_TOOL_ITERATIONS = 200
|
||||||
|
|
||||||
while tool_calls_from_response and tool_use_count < MAX_TOOL_ITERATIONS:
|
while tool_calls_from_response and tool_use_count < MAX_TOOL_ITERATIONS:
|
||||||
tool_results_for_model = []
|
tool_results_for_model = []
|
||||||
|
|||||||
+5
-5
@@ -28,7 +28,7 @@ class TelegramHelper:
|
|||||||
|
|
||||||
async def clear(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
async def clear(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||||
user_id = update.effective_user.id
|
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!")
|
await update.message.reply_text("Conversation history cleared. Let's start fresh!")
|
||||||
|
|
||||||
async def status(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
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}")
|
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')]]))\
|
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)
|
self.bot.set_processing_status(user_id, status_message.message_id)
|
||||||
|
|
||||||
response = await self.bot.handle_message(user_id, user_message)
|
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 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("<think>", self.HTML_QUOTE_BLOCK_START).replace("</think>", self.HTML_QUOTE_BLOCK_END)
|
response = response.replace("<think>", self.HTML_QUOTE_BLOCK_START).replace("</think>", self.HTML_QUOTE_BLOCK_END)
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ class TelegramHelper:
|
|||||||
application.add_handler(CommandHandler("status", self.status))
|
application.add_handler(CommandHandler("status", self.status))
|
||||||
application.add_handler(CommandHandler("reboot", self.reboot))
|
application.add_handler(CommandHandler("reboot", self.reboot))
|
||||||
application.add_handler(CommandHandler("browse", self.browse))
|
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(self.abort_processing, pattern='^abort$'))
|
||||||
application.add_handler(CallbackQueryHandler(button_callback, pattern='^(browse|file):'))
|
application.add_handler(CallbackQueryHandler(button_callback, pattern='^(browse|file):'))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user