Update telegram interface #44
Reference in New Issue
Block a user
Delete Branch "update-telegram-interaction"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Change the telegram ineterface to integrate the new agents (check-team-teamLeader-report)
Pull Request Overview
This PR updates the Telegram interface to integrate a new multi-agent pipeline architecture with four distinct models (query checker, team leader, team, and report generator). The changes reorganize the conversation flow to allow users to configure individual model selections before executing queries.
Key changes:
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
@@ -119,3 +133,81 @@ class PipelineInputs:social_tool = SocialAPIsTool()Potential IndexError if
self.current >= len(steps)after all steps complete. Theupdate()method incrementsself.currentbeyond the list bounds when the last step finishes. Add bounds checking:if extra and self.current < len(steps):@@ -0,0 +20,4 @@# Lo stato cambia in base al valore di ritorno delle funzioni async# END state è già definito in telegram.ext.ConversationHandler# Un semplice schema delle interazioni:The comparison
self.name == self.MODEL_CHECK.namewill always be true whenselfisMODEL_CHECK. Consider using a dictionary mapping instead of if-elif chains for better maintainability. Example:model_map = {self.MODEL_CHECK.name: inputs.choose_query_checker, ...}thenmodel_map[self.name](new_value)@@ -0,0 +172,4 @@args: dict[str, Any] = {"text": "Please choose an option or write your query","parse_mode": 'MarkdownV2',"reply_markup": InlineKeyboardMarkup([Pattern mismatch: The pattern is
'^CANCEL$'but the callback data is set toself.namewhich would be 'CANCEL' without regex anchors. However,ConfigsChat.CANCEL.namereturns 'CANCEL', so this pattern should match correctly. The inconsistency is that line 110 and 114 use the same pattern but previous line 102 used lowercase 'cancel'. This could cause confusion - consider using consistent casing throughout.@@ -0,0 +235,4 @@logging.debug(f"@{user.username} --> {query.data}")req = self.user_requests[user]_, state, index = str(query.data).split(QUERY_SEP)Creating async tasks with
asyncio.create_taskwithout awaiting or tracking them can lead to unhandled exceptions and race conditions. The task may fail silently ifmsg.edit_textraises an exception. Consider usingawaitdirectly or implementing proper task tracking and error handling.The f-string uses backticks for markdown code formatting, but wraps the entire expression. If
e.agent_nameore.tool.tool_namecontain special MarkdownV2 characters, they should be escaped. Consider adding proper markdown escaping for user-facing content.@@ -0,0 +241,4 @@return await self.__go_to_start(update, context)async def __start_llms(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:message, user = self.handle_message(update)Changed from
config.valuetoconfig.name, but line 241 expects the string representation to matchConfigsChat[state]. This works correctly with.name, but the original code at line 240-247 comparedstate == str(ConfigsChat.MODEL_TEAM)which used string comparison with the enum value. The new implementation usingConfigsChat[state]is correct, but ensure this change is intentional and all call sites are updated.