agent-system / tools /agent_visual_manager.py
sp103107's picture
Upload folder using huggingface_hub
e20bd8e verified
Raw History Blame Contribute Delete
3.74 kB
import logging
from art import text2art
from colorama import init, Fore, Style
from datetime import datetime
# Initialize colorama
init()
logger = logging.getLogger(__name__)
class AgentVisualManager:
"""Provides visual feedback for agent operations"""
def show_agent_status(self, agent_name: str, status: str):
"""Display agent status with visual feedback"""
colors = {
"initializing": Fore.YELLOW,
"processing": Fore.BLUE,
"completed": Fore.GREEN,
"error": Fore.RED,
"waiting": Fore.CYAN
}
stages = {
"initializing": f"""
{colors["initializing"]}β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Agent Init β”‚
β”‚ {agent_name:<14} β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜{Style.RESET_ALL}
""",
"processing": f"""
{colors["processing"]}β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Processing β”‚ βš™οΈ
β”‚ {agent_name:<14} β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜{Style.RESET_ALL}
""",
"completed": f"""
{colors["completed"]}β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Completed! β”‚ βœ…
β”‚ {agent_name:<14} β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜{Style.RESET_ALL}
""",
"error": f"""
{colors["error"]}β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Error! β”‚ ❌
β”‚ {agent_name:<14} β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜{Style.RESET_ALL}
""",
"waiting": f"""
{colors["waiting"]}β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Waiting β”‚ ⏳
β”‚ {agent_name:<14} β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜{Style.RESET_ALL}
"""
}
print(f"\n{datetime.now().strftime('%H:%M:%S')} - ", end="")
print(stages.get(status, ""))
def show_agent_communication(self, from_agent: str, to_agent: str, message_type: str = "request"):
"""Display agent communication flow"""
arrow = "──→" if message_type == "request" else "←──"
color = Fore.BLUE if message_type == "request" else Fore.GREEN
print(f"""
{color}β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” {arrow} β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ {from_agent:<11}β”‚ β”‚ {to_agent:<11}β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜{Style.RESET_ALL}
""")
def show_team_formation(self, team_leader: str, team_members: list):
"""Display team structure"""
print(Fore.CYAN + text2art("Team Formation") + Style.RESET_ALL)
print(f"""
{Fore.YELLOW}β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ LEADER β”‚
β”‚ {team_leader:<11}β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜{Style.RESET_ALL}
β”‚
""")
for member in team_members:
if member != team_leader:
print(f""" {Fore.BLUE} ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ {member:<11}β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜{Style.RESET_ALL}""")