Refactor team management #26

Merged
Berack96 merged 14 commits from 21-team-monitoring into main 2025-10-15 14:00:39 +02:00
2 changed files with 11 additions and 8 deletions
Showing only changes of commit 6fa6691ad9 - Show all commits

View File

@@ -1,9 +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 typing import Callable 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, AppEvent, TeamRunEvent, RunEvent
from app.configs import AppConfig from app.configs import AppConfig
logging = logging.getLogger("pipeline") logging = logging.getLogger("pipeline")
@@ -63,7 +61,7 @@ class Pipeline:
# ====================== # ======================
# Core interaction # Core interaction
# ====================== # ======================
def interact(self, query: str, listeners: dict[str, Callable[[RunOutputEvent | TeamRunOutputEvent], None]] = {}) -> str: def interact(self, query: str, listeners: dict[RunEvent | TeamRunEvent, Callable[[AppEvent], 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.

View File

@@ -1,6 +1,6 @@
import asyncio import asyncio
from typing import Callable from typing import Callable
from agno.run.agent import RunOutputEvent from agno.agent import RunEvent, RunOutputEvent
from agno.team import Team, TeamRunEvent, TeamRunOutputEvent from agno.team import Team, TeamRunEvent, TeamRunOutputEvent
from agno.tools.reasoning import ReasoningTools from agno.tools.reasoning import ReasoningTools
from app.agents.prompts import * from app.agents.prompts import *
@@ -8,15 +8,20 @@ from app.configs import AppConfig, AppModel
from app.api.tools import * from app.api.tools import *
# Define a unified event type for team and agent events
AppEvent = TeamRunOutputEvent | RunOutputEvent
class AppTeam: class AppTeam:
def __init__(self, configs: AppConfig, team_models: AppModel, team_leader: AppModel | None = None): def __init__(self, configs: AppConfig, team_models: AppModel, team_leader: AppModel | None = None):
self.configs = configs self.configs = configs
self.team_models = team_models self.team_models = team_models
self.team_leader = team_leader or team_models self.team_leader = team_leader or team_models
self.listeners: dict[str, Callable[[RunOutputEvent | TeamRunOutputEvent], None]] = {} self.listeners: dict[str, Callable[[AppEvent], None]] = {}
def add_listener(self, event: str, listener: Callable[[RunOutputEvent | TeamRunOutputEvent], None]) -> None: def add_listener(self, event: RunEvent | TeamRunEvent, listener: Callable[[AppEvent], None]) -> None:
self.listeners[event] = listener self.listeners[event.value] = listener
def run_team(self, query: str) -> str: def run_team(self, query: str) -> str:
return asyncio.run(self.run_team_async(query)) return asyncio.run(self.run_team_async(query))