Update telegram interface #44

Merged
Berack96 merged 6 commits from update-telegram-interaction into main 2025-10-27 12:42:14 +01:00
Berack96 commented 2025-10-23 11:24:50 +02:00 (Migrated from github.com)

Change the telegram ineterface to integrate the new agents (check-team-teamLeader-report)

Change the telegram ineterface to integrate the new agents (check-team-teamLeader-report)
trojanhorse47 (Migrated from github.com) reviewed 2025-10-23 11:24:50 +02:00
copilot-pull-request-reviewer[bot] (Migrated from github.com) reviewed 2025-10-23 15:07:19 +02:00
copilot-pull-request-reviewer[bot] (Migrated from github.com) left a comment

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:

  • Added new agent model selection options (Check, Team Leader, Team, Report)
  • Implemented a new conversation state (SELECT_MODEL) for model configuration
  • Enhanced runtime feedback with step-by-step progress tracking using RunMessage class

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
src/app/interface/telegram.py Major refactoring to support new multi-agent workflow with enhanced model selection UI and real-time progress updates
src/app/interface/init.py Fixed import path from telegram_app to telegram module
src/app/agents/core.py Added new model selection methods and RunMessage class for progress tracking

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

## 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: - Added new agent model selection options (Check, Team Leader, Team, Report) - Implemented a new conversation state (SELECT_MODEL) for model configuration - Enhanced runtime feedback with step-by-step progress tracking using RunMessage class ### Reviewed Changes Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments. | File | Description | | ---- | ----------- | | src/app/interface/telegram.py | Major refactoring to support new multi-agent workflow with enhanced model selection UI and real-time progress updates | | src/app/interface/__init__.py | Fixed import path from telegram_app to telegram module | | src/app/agents/core.py | Added new model selection methods and RunMessage class for progress tracking | --- <sub>**Tip:** Customize your code reviews with copilot-instructions.md. <a href="/Berack96/upo-appAI/new/main/.github?filename=copilot-instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Create the file</a> or <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">learn how to get started</a>.</sub>
@@ -119,3 +133,81 @@ class PipelineInputs:
social_tool = SocialAPIsTool()
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-10-23 15:07:19 +02:00

Potential IndexError if self.current >= len(steps) after all steps complete. The update() method increments self.current beyond the list bounds when the last step finishes. Add bounds checking: if extra and self.current < len(steps):

        if extra and self.current < len(steps):
Potential IndexError if `self.current >= len(steps)` after all steps complete. The `update()` method increments `self.current` beyond the list bounds when the last step finishes. Add bounds checking: `if extra and self.current < len(steps):` ```suggestion 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:
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-10-23 15:07:18 +02:00

The comparison self.name == self.MODEL_CHECK.name will always be true when self is MODEL_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, ...} then model_map[self.name](new_value)

        model_map = {
            self.MODEL_CHECK.name: inputs.choose_query_checker,
            self.MODEL_TEAM_LEADER.name: inputs.choose_team_leader,
            self.MODEL_TEAM.name: inputs.choose_team,
            self.MODEL_REPORT.name: inputs.choose_report_generator,
            self.STRATEGY.name: inputs.choose_strategy,
        }
        func = model_map.get(self.name)
        if func:
            func(new_value)
The comparison `self.name == self.MODEL_CHECK.name` will always be true when `self` is `MODEL_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, ...}` then `model_map[self.name](new_value)` ```suggestion model_map = { self.MODEL_CHECK.name: inputs.choose_query_checker, self.MODEL_TEAM_LEADER.name: inputs.choose_team_leader, self.MODEL_TEAM.name: inputs.choose_team, self.MODEL_REPORT.name: inputs.choose_report_generator, self.STRATEGY.name: inputs.choose_strategy, } func = model_map.get(self.name) if func: func(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([
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-10-23 15:07:18 +02:00

Pattern mismatch: The pattern is '^CANCEL$' but the callback data is set to self.name which would be 'CANCEL' without regex anchors. However, ConfigsChat.CANCEL.name returns '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.

Pattern mismatch: The pattern is `'^CANCEL$'` but the callback data is set to `self.name` which would be 'CANCEL' without regex anchors. However, `ConfigsChat.CANCEL.name` returns '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)
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-10-23 15:07:19 +02:00

Creating async tasks with asyncio.create_task without awaiting or tracking them can lead to unhandled exceptions and race conditions. The task may fail silently if msg.edit_text raises an exception. Consider using await directly or implementing proper task tracking and error handling.

Creating async tasks with `asyncio.create_task` without awaiting or tracking them can lead to unhandled exceptions and race conditions. The task may fail silently if `msg.edit_text` raises an exception. Consider using `await` directly or implementing proper task tracking and error handling.
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-10-23 15:07:19 +02:00

The f-string uses backticks for markdown code formatting, but wraps the entire expression. If e.agent_name or e.tool.tool_name contain special MarkdownV2 characters, they should be escaped. Consider adding proper markdown escaping for user-facing content.

The f-string uses backticks for markdown code formatting, but wraps the entire expression. If `e.agent_name` or `e.tool.tool_name` contain 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)
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-10-23 15:07:18 +02:00

Changed from config.value to config.name, but line 241 expects the string representation to match ConfigsChat[state]. This works correctly with .name, but the original code at line 240-247 compared state == str(ConfigsChat.MODEL_TEAM) which used string comparison with the enum value. The new implementation using ConfigsChat[state] is correct, but ensure this change is intentional and all call sites are updated.

Changed from `config.value` to `config.name`, but line 241 expects the string representation to match `ConfigsChat[state]`. This works correctly with `.name`, but the original code at line 240-247 compared `state == str(ConfigsChat.MODEL_TEAM)` which used string comparison with the enum value. The new implementation using `ConfigsChat[state]` is correct, but ensure this change is intentional and all call sites are updated.
Simo93-rgb (Migrated from github.com) approved these changes 2025-10-27 12:42:12 +01:00
Sign in to join this conversation.