Refactor team management #26

Merged
Berack96 merged 14 commits from 21-team-monitoring into main 2025-10-15 14:00:39 +02:00
Showing only changes of commit 0162071ea9 - Show all commits

View File

@@ -1,5 +1,7 @@
import logging import logging
copilot-pull-request-reviewer[bot] commented 2025-10-15 13:45:47 +02:00 (Migrated from github.com)
Review

The docstring incorrectly describes this method as choosing the model for the Team, but it actually chooses the team leader model.

        Sceglie il modello LLM da usare per il Team Leader.
The docstring incorrectly describes this method as choosing the model for the Team, but it actually chooses the team leader model. ```suggestion Sceglie il modello LLM da usare per il Team Leader. ```
from agno.run.agent import RunEvent from typing import Callable
from agno.run.agent import RunOutputEvent
from agno.run.team import TeamRunOutputEvent
from app.agents.prompts import * from app.agents.prompts import *
from app.agents.team import AppTeam from app.agents.team import AppTeam
from app.configs import AppConfig from app.configs import AppConfig
@@ -61,7 +63,7 @@ class Pipeline:
# ====================== # ======================
# Core interaction # Core interaction
# ====================== # ======================
def interact(self, query: str) -> str: def interact(self, query: str, listeners: dict[str, Callable[[RunOutputEvent | TeamRunOutputEvent], None]] = {}) -> str:
""" """
Esegue la pipeline di agenti per rispondere alla query dell'utente. Esegue la pipeline di agenti per rispondere alla query dell'utente.
1. Crea il Team di agenti. 1. Crea il Team di agenti.
@@ -73,16 +75,16 @@ class Pipeline:
Returns: Returns:
str: La risposta generata dagli agenti. str: La risposta generata dagli agenti.
""" """
logging.info(f"Pipeline received query: {query}")
# Step 1: Creazione Team # Step 1: Creazione Team
team = AppTeam(self.configs, self.team_model, self.leader_model) team = AppTeam(self.configs, self.team_model, self.leader_model)
# Step 2: Aggiunti listener per eventi # Step 2: Aggiunti listener per eventi
team.add_listener(RunEvent.tool_call_started, lambda e: print(f"Team tool call started: {e.agent_name}")) # type: ignore for event_name, listener in listeners.items():
team.add_listener(RunEvent.tool_call_completed, lambda e: print(f"Team tool call completed: {e.agent_name}")) # type: ignore team.add_listener(event_name, listener)
# Step 3: Esecuzione Team # Step 3: Esecuzione Team
logging.info(f"Pipeline received query: {query}")
# TODO migliorare prompt (?) # TODO migliorare prompt (?)
query = f"The user query is: {query}\n\n They requested a {self.strategy.label} investment strategy." query = f"The user query is: {query}\n\n They requested a {self.strategy.label} investment strategy."
result = team.run_team(query) result = team.run_team(query)