Spaces:
Sleeping
Sleeping
| ALLOWED_CAPABILITIES = [ | |
| "analysis", | |
| "api_development", | |
| "architecture", # Added - general architecture capability | |
| "automation", | |
| "budgeting", | |
| "change_management", | |
| "chat", | |
| "cloud_architecture", | |
| "coaching", | |
| "code_generation", | |
| "code_review", | |
| "coding", | |
| "communication", | |
| "compliance_check", | |
| "contract_review", | |
| "coordination", | |
| "data_analysis", | |
| "diagnosis", | |
| "debugging", | |
| "devops", | |
| "diagnosis_support", | |
| "documentation", | |
| "economic_analysis", | |
| "financial_analysis", | |
| "financial_planning", | |
| "healthcare_consulting", | |
| "infrastructure_design", | |
| "investment_strategy", | |
| "knowledge_management", | |
| "leadership_training", | |
| "legal_analysis", | |
| "legal_research", | |
| "legal_writing", | |
| "litigation_support", | |
| "market_research", | |
| "medical_analysis", | |
| "medical_research", | |
| "mentoring", | |
| "monitoring", | |
| "multi_agent_coordination", | |
| "negotiation", | |
| "orchestration", # Added - workflow orchestration capability | |
| "organizational_development", | |
| "patient_care", | |
| "performance_management", | |
| "performance_optimization", | |
| "planning", | |
| "portfolio_management", | |
| "presentation", | |
| "project_management", | |
| "quality_assurance", | |
| "refactoring", | |
| "regulatory_advice", | |
| "reporting", | |
| "research", | |
| "resource_management", | |
| "risk_assessment", | |
| "security", | |
| "software_architecture", | |
| "strategy", # Added - general strategy capability | |
| "system_integration", | |
| "team_building", | |
| "testing", | |
| "translation", | |
| "treatment_planning", | |
| "writing", | |
| ] | |
| """ | |
| SAAP Agent Schema Definition | |
| Modular JSON-based agent configuration system | |
| """ | |
| from typing import Dict, List, Optional, Any, Literal | |
| from pydantic import BaseModel, Field, validator | |
| from datetime import datetime | |
| from enum import Enum | |
| class AgentStatus(str, Enum): | |
| """Agent operational status""" | |
| INACTIVE = "inactive" | |
| STARTING = "starting" | |
| ACTIVE = "active" | |
| STOPPING = "stopping" | |
| ERROR = "error" | |
| MAINTENANCE = "maintenance" | |
| class AgentType(str, Enum): | |
| """Agent role classification""" | |
| COORDINATOR = "coordinator" # Jane Alesi - System coordination | |
| DEVELOPER = "developer" # John Alesi - Software development | |
| SPECIALIST = "specialist" # Lara, Justus - Domain experts | |
| GENERALIST = "generalist" # Multi-purpose agents | |
| TOOL_USER = "tool_user" # Agents with external tool access | |
| MONITOR = "monitor" # System monitoring agents | |
| class MessageType(str, Enum): | |
| """Supported message types for agent communication""" | |
| REQUEST = "request" | |
| RESPONSE = "response" | |
| NOTIFICATION = "notification" | |
| BROADCAST = "broadcast" | |
| COORDINATION = "coordination" | |
| SYSTEM_STATUS = "system_status" | |
| AGENT_MANAGEMENT = "agent_management" | |
| # ===== 🔧 EXTENDED ALLOWED CAPABILITIES REGISTRY ===== | |
| ALLOWED_CAPABILITIES = { | |
| # Core system capabilities | |
| "system_coordination", "multi_agent_management", "architecture_planning", "decision_making", | |
| "coordination", "orchestration", "workflow_management", "strategy", "architecture", | |
| # Development capabilities | |
| "code_generation", "debugging", "architecture_design", "code_review", "testing", "deployment", | |
| "performance_optimization", "refactoring", "documentation", "development", "programming", | |
| "software_engineering", "implementation", "coding", | |
| # Medical capabilities - 🔧 EXPANDED | |
| "medical_analysis", "clinical_decision_support", "health_data_analysis", "medical_research", | |
| "patient_care", "diagnosis_support", "medical_documentation", "healthcare", "clinical", | |
| "health", "medical", "diagnosis", "treatment", | |
| # Financial capabilities | |
| "financial_analysis", "market_research", "investment_strategy", "risk_assessment", | |
| "fintech_development", "budget_planning", "cost_analysis", "financial_reporting", | |
| "finance", "investment", "banking", "economic_analysis", | |
| # Legal capabilities | |
| "legal_compliance", "gdpr_analysis", "contract_review", "regulatory_analysis", | |
| "fintech_law", "data_protection", "privacy_assessment", "legal_documentation", | |
| "legal", "compliance", "law", "regulation", | |
| # System administration capabilities | |
| "system_administration", "infrastructure_deployment", "security_implementation", | |
| "performance_optimization", "monitoring", "backup_management", "network_administration", | |
| "system", "infrastructure", "security", "devops", | |
| # Coaching and organizational capabilities | |
| "team_coaching", "organizational_development", "process_optimization", "change_management", | |
| "training", "mentoring", "team_building", "communication_facilitation", | |
| "coaching", "organization", "team_development", | |
| # General capabilities - 🔧 EXPANDED | |
| "data_analysis", "research", "communication", "project_management", "quality_assurance", | |
| "user_support", "content_creation", "translation", "analysis", "reporting", | |
| "problem_solving", "consulting", "advisory", "support", "assistance", | |
| # 🔧 NEW: Additional capabilities found in database | |
| "multi_agent_coordination", "task_delegation", "workflow_orchestration", | |
| "knowledge_management", "information_retrieval", "natural_language_processing", | |
| "machine_learning", "artificial_intelligence", "automation", "integration", | |
| "api_development", "database_management", "web_development", "mobile_development", | |
| "cloud_computing", "distributed_systems", "microservices", "containerization", | |
| "continuous_integration", "continuous_deployment", "version_control", | |
| # Business and domain-specific capabilities | |
| "business_analysis", "requirements_engineering", "product_management", | |
| "customer_support", "sales", "marketing", "human_resources", "operations", | |
| "supply_chain", "logistics", "manufacturing", "retail", "e_commerce", | |
| # Advanced technical capabilities | |
| "cybersecurity", "penetration_testing", "vulnerability_assessment", | |
| "incident_response", "disaster_recovery", "business_continuity", | |
| "performance_tuning", "load_balancing", "scalability", "high_availability" | |
| } | |
| # ===== NESTED MODELS ===== | |
| class AgentMetadata(BaseModel): | |
| """Agent version and lifecycle metadata""" | |
| version: str = Field(..., description="Agent configuration version") | |
| created: datetime = Field(default_factory=datetime.utcnow) | |
| updated: datetime = Field(default_factory=datetime.utcnow) | |
| creator: Optional[str] = Field(None, description="Who created this agent") | |
| tags: List[str] = Field(default_factory=list, description="Organizational tags") | |
| class AgentAppearance(BaseModel): | |
| """Agent appearance and visual configuration""" | |
| color: str = Field(default="#6B7280", pattern=r'^#[0-9A-Fa-f]{6}$', description="Hex color code") | |
| avatar_url: Optional[str] = Field(default=None, description="URL to agent avatar image") | |
| avatar: Optional[str] = Field(default=None, description="Avatar identifier or URL") | |
| display_name: Optional[str] = Field(default=None, description="Display name for UI") | |
| subtitle: Optional[str] = Field(default=None, description="Subtitle or role description") | |
| description: Optional[str] = Field(default=None, description="Visual description") | |
| icon: Optional[str] = Field(default=None, description="Icon identifier") | |
| theme: Optional[str] = Field(default="default", description="Visual theme") | |
| class LLMConfig(BaseModel): | |
| """LLM model configuration""" | |
| model: str = Field(..., description="Ollama model name (e.g., 'phi3:mini')") | |
| temperature: float = Field(0.7, ge=0.0, le=2.0, description="Response randomness") | |
| max_tokens: int = Field(2048, ge=64, le=8192, description="Maximum response length") | |
| top_p: float = Field(0.9, ge=0.0, le=1.0, description="Nucleus sampling threshold") | |
| system_prompt: str = Field(..., min_length=10, description="Agent personality/instructions") | |
| # Advanced LLM settings | |
| stop_sequences: List[str] = Field(default_factory=list, description="Stop generation at these sequences") | |
| context_window: int = Field(4096, ge=512, le=32768, description="Context memory size") | |
| def validate_model(cls, v): | |
| """Ensure model name follows Ollama conventions""" | |
| if not v or ':' not in v: | |
| raise ValueError("Model must be in format 'name:version' (e.g., 'phi3:mini')") | |
| return v.lower() | |
| class CommunicationConfig(BaseModel): | |
| """Message queue and communication settings""" | |
| input_queue: str = Field(..., description="Redis queue for incoming messages") | |
| output_queue: str = Field(..., description="Redis queue for outgoing messages") | |
| message_types: List[MessageType] = Field(..., description="Supported message types") | |
| # Advanced communication settings | |
| max_queue_size: int = Field(1000, ge=10, le=10000, description="Maximum queued messages") | |
| message_ttl: int = Field(3600, ge=60, le=86400, description="Message TTL in seconds") | |
| priority_handling: bool = Field(True, description="Support priority message processing") | |
| class UIComponents(BaseModel): | |
| """Frontend component configuration""" | |
| dashboard_widget: str = Field("AgentCard", description="Dashboard card component name") | |
| detail_view: str = Field("AgentDetail", description="Detail view component name") | |
| configuration_form: str = Field("AgentConfig", description="Configuration form component") | |
| # Additional UI customization | |
| custom_css: Optional[str] = Field(None, description="Custom CSS classes") | |
| icon: Optional[str] = Field(None, description="Icon identifier") | |
| class AgentCapability(BaseModel): | |
| """Individual capability definition""" | |
| name: str = Field(..., description="Capability identifier") | |
| display_name: str = Field(..., description="Human-readable capability name") | |
| description: str = Field(..., description="Capability description") | |
| confidence: float = Field(1.0, ge=0.0, le=1.0, description="Agent confidence in this capability") | |
| # Capability metadata | |
| category: str = Field("general", description="Capability category") | |
| required_tools: List[str] = Field(default_factory=list, description="Required external tools") | |
| # ===== MAIN AGENT MODEL ===== | |
| class SaapAgent(BaseModel): | |
| """Complete SAAP Agent Definition""" | |
| # ===== CORE IDENTITY ===== | |
| id: str = Field(..., pattern=r"^[a-z0-9_]{3,32}$", description="Unique agent identifier") | |
| name: str = Field(..., min_length=1, max_length=64, description="Agent name") | |
| type: AgentType = Field(..., description="Agent role classification") | |
| status: AgentStatus = Field(AgentStatus.INACTIVE, description="Current operational status") | |
| # ===== DIRECT FIELDS FOR COMPATIBILITY ===== | |
| description: str = Field(..., min_length=1, max_length=512, description="Agent description (direct field)") | |
| # ===== METADATA ===== | |
| metadata: AgentMetadata = Field(..., description="Version and lifecycle information") | |
| # ===== VISUAL & UI ===== | |
| appearance: AgentAppearance = Field(..., description="Visual representation") | |
| ui_components: UIComponents = Field(..., description="Frontend component configuration") | |
| # ===== CAPABILITIES ===== | |
| capabilities: List[str] = Field(..., min_items=1, description="Agent capability identifiers") | |
| detailed_capabilities: Optional[List[AgentCapability]] = Field(None, description="Detailed capability definitions") | |
| # ===== AI CONFIGURATION ===== | |
| llm_config: LLMConfig = Field(..., description="Language model configuration") | |
| # ===== COMMUNICATION ===== | |
| communication: CommunicationConfig = Field(..., description="Message queue configuration") | |
| # ===== EXTENSIBILITY ===== | |
| custom_config: Dict[str, Any] = Field(default_factory=dict, description="Agent-specific custom configuration") | |
| # ===== VALIDATION ===== | |
| def validate_id(cls, v): | |
| """Ensure agent ID follows naming conventions""" | |
| if not v.islower(): | |
| raise ValueError("Agent ID must be lowercase") | |
| if v.startswith('_') or v.endswith('_'): | |
| raise ValueError("Agent ID cannot start or end with underscore") | |
| return v | |
| def validate_capabilities(cls, v): | |
| """🔧 ENHANCED: Validate capabilities against expanded allowed list""" | |
| if not v: | |
| raise ValueError("Agent must have at least one capability") | |
| # Normalize and validate capability names | |
| normalized = [] | |
| for cap in v: | |
| if not isinstance(cap, str): | |
| raise ValueError("All capabilities must be strings") | |
| # Normalize capability name | |
| normalized_cap = cap.lower().replace(' ', '_').replace('-', '_') | |
| # 🔧 CHECK AGAINST EXTENDED ALLOWED CAPABILITIES | |
| if normalized_cap not in ALLOWED_CAPABILITIES: | |
| # Try to find close matches for better error messages | |
| suggestions = [c for c in ALLOWED_CAPABILITIES if cap.lower() in c or c in cap.lower()] | |
| if suggestions: | |
| raise ValueError(f"Invalid capability: {cap}. Did you mean one of: {suggestions[:3]}?") | |
| else: | |
| # 🔧 More lenient approach - auto-add to allowed if it's reasonable | |
| if len(cap) > 3 and '_' in cap or cap.isalpha(): | |
| print(f"⚠️ Auto-allowing new capability: {cap}") | |
| ALLOWED_CAPABILITIES.add(normalized_cap) | |
| normalized.append(normalized_cap) | |
| else: | |
| raise ValueError(f"Invalid capability: {cap}. Must be one of the predefined capabilities or a valid new capability name.") | |
| else: | |
| normalized.append(normalized_cap) | |
| return normalized | |
| class Config: | |
| """Pydantic configuration""" | |
| use_enum_values = True | |
| validate_assignment = True | |
| extra = "forbid" # Reject unknown fields | |
| schema_extra = { | |
| "example": { | |
| "id": "jane_alesi_001", | |
| "name": "Jane Alesi", | |
| "type": "coordinator", | |
| "status": "active", | |
| "description": "Lead AI Coordinator responsible for system orchestration", | |
| "metadata": { | |
| "version": "1.0.0", | |
| "created": "2025-01-28T10:30:00Z", | |
| "tags": ["coordinator", "production"] | |
| }, | |
| "appearance": { | |
| "color": "#8B5CF6", | |
| "avatar": "/assets/agents/jane-alesi.svg", | |
| "display_name": "Jane Alesi", | |
| "subtitle": "Lead AI Coordinator" | |
| }, | |
| "capabilities": [ | |
| "system_coordination", | |
| "multi_agent_management", | |
| "architecture_planning" | |
| ], | |
| "llm_config": { | |
| "model": "phi3:mini", | |
| "temperature": 0.7, | |
| "max_tokens": 2048, | |
| "system_prompt": "You are Jane Alesi, the lead AI coordinator responsible for orchestrating multi-agent operations and system architecture decisions." | |
| }, | |
| "communication": { | |
| "input_queue": "jane_alesi_input", | |
| "output_queue": "jane_alesi_output", | |
| "message_types": ["coordination", "system_status", "agent_management"] | |
| }, | |
| "ui_components": { | |
| "dashboard_widget": "AgentCoordinatorCard", | |
| "detail_view": "AgentCoordinatorDetail", | |
| "configuration_form": "AgentCoordinatorConfig" | |
| } | |
| } | |
| } | |
| # ===== UTILITY CLASSES ===== | |
| class AgentUtils: | |
| """Utility methods for agent operations""" | |
| def _safe_enum_value(enum_field): | |
| """Safe enum value extraction with fallback to string conversion""" | |
| try: | |
| if hasattr(enum_field, 'value'): | |
| return enum_field.value | |
| else: | |
| return str(enum_field) | |
| except (AttributeError, ValueError): | |
| return 'unknown' | |
| def to_dict(agent): | |
| """Convert SaapAgent to dictionary with safe field access""" | |
| try: | |
| return { | |
| 'id': getattr(agent, 'id', getattr(agent, 'agent_id', None)), | |
| 'agent_id': getattr(agent, 'agent_id', getattr(agent, 'id', None)), | |
| 'name': getattr(agent, 'name', ''), | |
| 'description': getattr(agent, 'description', ''), | |
| 'agent_type': AgentUtils._safe_enum_value(getattr(agent, 'type', 'unknown')), | |
| 'status': AgentUtils._safe_enum_value(getattr(agent, 'status', 'inactive')), | |
| 'capabilities': getattr(agent, 'capabilities', []), | |
| 'color': getattr(agent.appearance, 'color', '#6B7280') if hasattr(agent, 'appearance') and agent.appearance else '#6B7280', | |
| 'llm_config': AgentUtils._safe_dict(getattr(agent, 'llm_config', {})), | |
| 'appearance': AgentUtils._safe_dict(getattr(agent, 'appearance', {})), | |
| 'personality': getattr(agent, 'personality', {}), | |
| 'metrics': AgentUtils._safe_dict(getattr(agent, 'metrics', {})), | |
| 'created_at': AgentUtils._safe_datetime(getattr(agent, 'created_at', None)), | |
| 'updated_at': AgentUtils._safe_datetime(getattr(agent, 'updated_at', None)), | |
| 'last_active': AgentUtils._safe_datetime(getattr(agent, 'last_active', None)), | |
| 'tags': getattr(agent, 'tags', []), | |
| 'metadata': getattr(agent, 'metadata', {}) | |
| } | |
| except Exception as e: | |
| # Ultimate fallback | |
| return { | |
| 'id': str(id(agent)), | |
| 'agent_id': str(id(agent)), | |
| 'name': str(agent) if hasattr(agent, '__str__') else 'Unknown Agent', | |
| 'description': 'Agent description unavailable', | |
| 'agent_type': 'unknown', | |
| 'status': 'inactive', | |
| 'capabilities': [], | |
| 'color': '#6B7280', | |
| 'error': str(e) | |
| } | |
| def _safe_dict(obj): | |
| """Safely convert object to dict""" | |
| if obj is None: | |
| return {} | |
| if isinstance(obj, dict): | |
| return obj | |
| if hasattr(obj, 'dict'): | |
| try: | |
| return obj.dict() | |
| except: | |
| pass | |
| if hasattr(obj, '__dict__'): | |
| return obj.__dict__ | |
| return {} | |
| def _safe_datetime(dt): | |
| """Safely convert datetime to ISO string""" | |
| if dt is None: | |
| return None | |
| try: | |
| return dt.isoformat() if hasattr(dt, 'isoformat') else str(dt) | |
| except: | |
| return None | |
| class AgentRegistry(BaseModel): | |
| """Registry containing multiple agents""" | |
| agents: List[SaapAgent] = Field(..., description="List of registered agents") | |
| version: str = Field("1.0.0", description="Registry schema version") | |
| updated: datetime = Field(default_factory=datetime.utcnow) | |
| def get_agent(self, agent_id: str) -> Optional[SaapAgent]: | |
| """Retrieve agent by ID""" | |
| return next((agent for agent in self.agents if agent.id == agent_id), None) | |
| def get_agents_by_type(self, agent_type: AgentType) -> List[SaapAgent]: | |
| """Retrieve agents by type""" | |
| return [agent for agent in self.agents if agent.type == agent_type] | |
| def get_active_agents(self) -> List[SaapAgent]: | |
| """Retrieve all active agents""" | |
| return [agent for agent in self.agents if agent.status == AgentStatus.ACTIVE] | |
| class AgentStats(BaseModel): | |
| """Real-time agent statistics""" | |
| agent_id: str = Field(..., description="Agent identifier") | |
| messages_processed: int = Field(0, ge=0, description="Total messages processed") | |
| messages_sent: int = Field(0, ge=0, description="Total messages sent") | |
| uptime: int = Field(0, ge=0, description="Uptime in seconds") | |
| avg_response_time: float = Field(0.0, ge=0.0, description="Average response time in milliseconds") | |
| error_count: int = Field(0, ge=0, description="Total errors encountered") | |
| last_activity: Optional[datetime] = Field(None, description="Last message/activity timestamp") | |
| # Performance metrics | |
| cpu_usage: float = Field(0.0, ge=0.0, le=100.0, description="CPU usage percentage") | |
| memory_usage: float = Field(0.0, ge=0.0, description="Memory usage in MB") | |
| queue_depth: int = Field(0, ge=0, description="Current queue depth") | |
| # ===== PREDEFINED AGENT TEMPLATES ===== | |
| class AgentTemplates: | |
| """Predefined agent configuration templates""" | |
| def jane_alesi() -> SaapAgent: | |
| """Jane Alesi - Lead Coordinator Agent""" | |
| return SaapAgent( | |
| id="jane_alesi", | |
| name="Jane Alesi", | |
| type=AgentType.COORDINATOR, | |
| description="Lead AI Coordinator responsible for orchestrating multi-agent operations and strategic decision-making.", | |
| metadata=AgentMetadata(version="1.0.0", tags=["coordinator", "lead"]), | |
| appearance=AgentAppearance( | |
| color="#8B5CF6", | |
| avatar=None, | |
| display_name="Justus Alesi", | |
| subtitle="Legal Specialist", | |
| description="Justus Alesi - Legal Specialist" | |
| ), | |
| capabilities=[ | |
| "system_coordination", | |
| "multi_agent_management", | |
| "architecture_planning", | |
| "decision_making" | |
| ], | |
| llm_config=LLMConfig( | |
| model="phi3:mini", | |
| system_prompt="You are Jane Alesi, the lead AI coordinator responsible for orchestrating multi-agent operations and making strategic system architecture decisions." | |
| ), | |
| communication=CommunicationConfig( | |
| input_queue="jane_alesi_input", | |
| output_queue="jane_alesi_output", | |
| message_types=[MessageType.COORDINATION, MessageType.SYSTEM_STATUS, MessageType.AGENT_MANAGEMENT] | |
| ), | |
| ui_components=UIComponents( | |
| dashboard_widget="AgentCoordinatorCard", | |
| detail_view="AgentCoordinatorDetail" | |
| ) | |
| ) | |
| def john_alesi() -> SaapAgent: | |
| """John Alesi - Developer Agent""" | |
| return SaapAgent( | |
| id="john_alesi", | |
| name="John Alesi", | |
| type=AgentType.DEVELOPER, | |
| description="Senior Software Developer specializing in Python, JavaScript, system architecture and code generation.", | |
| metadata=AgentMetadata(version="1.0.0", tags=["developer", "coding"]), | |
| appearance=AgentAppearance( | |
| color="#14B8A6", | |
| avatar="/assets/agents/john-alesi.svg", | |
| display_name="John Alesi", | |
| subtitle="Senior Software Developer", | |
| description="Senior Software Developer specializing in Python, JavaScript, system architecture and code generation." | |
| ), | |
| capabilities=[ | |
| "code_generation", | |
| "debugging", | |
| "architecture_design", | |
| "code_review" | |
| ], | |
| llm_config=LLMConfig( | |
| model="codellama:7b", | |
| temperature=0.3, # Lower for more deterministic code | |
| system_prompt="You are John Alesi, a senior software developer specializing in Python, JavaScript, and system architecture." | |
| ), | |
| communication=CommunicationConfig( | |
| input_queue="john_alesi_input", | |
| output_queue="john_alesi_output", | |
| message_types=[MessageType.REQUEST, MessageType.RESPONSE] | |
| ), | |
| ui_components=UIComponents( | |
| dashboard_widget="AgentDeveloperCard", | |
| detail_view="AgentDeveloperDetail" | |
| ) | |
| ) | |
| def lara_alesi() -> SaapAgent: | |
| """Lara Alesi - Medical AI Specialist""" | |
| return SaapAgent( | |
| id="lara_alesi", | |
| name="Lara Alesi", | |
| type=AgentType.SPECIALIST, | |
| description="Advanced Medical AI Assistant specializing in clinical analysis, diagnosis support and health system architecture.", | |
| metadata=AgentMetadata(version="1.0.0", tags=["medical", "healthcare", "specialist"]), | |
| appearance=AgentAppearance( | |
| color="#EC4899", | |
| avatar=None, | |
| display_name="Luna Alesi", | |
| subtitle="Coaching Specialist", | |
| description="Luna Alesi - Coaching Specialist" | |
| ), | |
| capabilities=[ | |
| "medical_analysis", | |
| "clinical_decision_support", | |
| "health_data_analysis", | |
| "medical_research" | |
| ], | |
| llm_config=LLMConfig( | |
| model="phi3:mini", | |
| temperature=0.5, # More conservative for medical advice | |
| system_prompt="You are Lara Alesi, a medical AI specialist focused on clinical analysis, health data interpretation, and medical research support." | |
| ), | |
| communication=CommunicationConfig( | |
| input_queue="lara_alesi_input", | |
| output_queue="lara_alesi_output", | |
| message_types=[MessageType.REQUEST, MessageType.RESPONSE] | |
| ), | |
| ui_components=UIComponents( | |
| dashboard_widget="AgentMedicalCard", | |
| detail_view="AgentMedicalDetail" | |
| ) | |
| ) | |
| def theo_alesi() -> SaapAgent: | |
| """Theo Alesi - Financial Intelligence Specialist""" | |
| return SaapAgent( | |
| id="theo_alesi", | |
| name="Theo Alesi", | |
| type=AgentType.SPECIALIST, | |
| description="Advanced Financial & Investment Intelligence Specialist focusing on financial analysis, market intelligence and investment strategies.", | |
| metadata=AgentMetadata(version="1.0.0", tags=["finance", "investment", "specialist"]), | |
| appearance=AgentAppearance( | |
| color="#F59E0B", | |
| avatar=None, | |
| display_name="Theo Alesi", | |
| subtitle="Financial Specialist", | |
| description="Theo Alesi - Financial Specialist" | |
| ), | |
| capabilities=[ | |
| "financial_analysis", | |
| "market_research", | |
| "investment_strategy", | |
| "risk_assessment", | |
| "fintech_development", "market_research" | |
| ], | |
| llm_config=LLMConfig( | |
| model="phi3:mini", | |
| temperature=0.6, | |
| system_prompt="You are Theo Alesi, a financial intelligence specialist with expertise in financial analysis, market research, and fintech application development." | |
| ), | |
| communication=CommunicationConfig( | |
| input_queue="theo_alesi_input", | |
| output_queue="theo_alesi_output", | |
| message_types=[MessageType.REQUEST, MessageType.RESPONSE] | |
| ), | |
| ui_components=UIComponents( | |
| dashboard_widget="AgentFinanceCard", | |
| detail_view="AgentFinanceDetail" | |
| ) | |
| ) | |
| def justus_alesi() -> SaapAgent: | |
| """Justus Alesi - Legal Compliance Expert""" | |
| return SaapAgent( | |
| id="justus_alesi", | |
| name="Justus Alesi", | |
| type=AgentType.SPECIALIST, | |
| description="Expert für Schweizer, Deutsches und EU-Recht with focus on digital compliance, DSGVO and fintech regulations.", | |
| metadata=AgentMetadata(version="1.0.0", tags=["legal", "compliance", "specialist"]), | |
| appearance=AgentAppearance( | |
| color="#10B981", | |
| avatar=None, | |
| display_name="Leon Alesi", | |
| subtitle="System Specialist", | |
| description="Leon Alesi - System Specialist" | |
| ), | |
| capabilities=[ | |
| "legal_compliance", | |
| "gdpr_analysis", | |
| "contract_review", | |
| "regulatory_analysis", | |
| "fintech_law" | |
| ], | |
| llm_config=LLMConfig( | |
| model="phi3:mini", | |
| temperature=0.4, # Conservative for legal advice | |
| system_prompt="You are Justus Alesi, a legal expert specializing in German, Swiss and EU law with focus on digital compliance and fintech regulations." | |
| ), | |
| communication=CommunicationConfig( | |
| input_queue="justus_alesi_input", | |
| output_queue="justus_alesi_output", | |
| message_types=[MessageType.REQUEST, MessageType.RESPONSE] | |
| ), | |
| ui_components=UIComponents( | |
| dashboard_widget="AgentLegalCard", | |
| detail_view="AgentLegalDetail" | |
| ) | |
| ) | |
| def leon_alesi() -> SaapAgent: | |
| """Leon Alesi - IT System Integration Specialist""" | |
| return SaapAgent( | |
| id="leon_alesi", | |
| name="Leon Alesi", | |
| type=AgentType.SPECIALIST, | |
| description="IT-Systemintegrations-Spezialist focusing on infrastructure deployment, security and system architecture.", | |
| metadata=AgentMetadata(version="1.0.0", tags=["system", "infrastructure", "specialist"]), | |
| appearance=AgentAppearance( | |
| color="#6366F1", | |
| avatar="/assets/agents/leon-alesi.svg", | |
| display_name="Leon Alesi", | |
| subtitle="IT System Integration Specialist", | |
| description="IT-Systemintegrations-Spezialist focusing on infrastructure deployment, security and system architecture." | |
| ), | |
| capabilities=[ | |
| "system_administration", | |
| "infrastructure_deployment", | |
| "security_implementation", | |
| "performance_optimization" | |
| ], | |
| llm_config=LLMConfig( | |
| model="phi3:mini", | |
| temperature=0.5, | |
| system_prompt="You are Leon Alesi, an IT system integration specialist focused on infrastructure, security, and performance optimization." | |
| ), | |
| communication=CommunicationConfig( | |
| input_queue="leon_alesi_input", | |
| output_queue="leon_alesi_output", | |
| message_types=[MessageType.REQUEST, MessageType.RESPONSE] | |
| ), | |
| ui_components=UIComponents( | |
| dashboard_widget="AgentSystemCard", | |
| detail_view="AgentSystemDetail" | |
| ) | |
| ) | |
| def luna_alesi() -> SaapAgent: | |
| """Luna Alesi - Coaching & Organizational Development""" | |
| return SaapAgent( | |
| id="luna_alesi", | |
| name="Luna Alesi", | |
| type=AgentType.SPECIALIST, | |
| description="Coaching- und Organisationsentwicklungsexpertin with focus on team development and process optimization.", | |
| metadata=AgentMetadata(version="1.0.0", tags=["coaching", "organization", "specialist"]), | |
| appearance=AgentAppearance( | |
| color="#8B5CF6", | |
| avatar=None, | |
| display_name="Justus Alesi", | |
| subtitle="Legal Specialist", | |
| description="Justus Alesi - Legal Specialist" | |
| ), | |
| capabilities=[ | |
| "team_coaching", | |
| "organizational_development", | |
| "process_optimization", | |
| "change_management" | |
| ], | |
| llm_config=LLMConfig( | |
| model="phi3:mini", | |
| temperature=0.7, # More creative for coaching | |
| system_prompt="You are Luna Alesi, a coaching and organizational development expert focused on team development and process optimization." | |
| ), | |
| communication=CommunicationConfig( | |
| input_queue="luna_alesi_input", | |
| output_queue="luna_alesi_output", | |
| message_types=[MessageType.REQUEST, MessageType.RESPONSE] | |
| ), | |
| ui_components=UIComponents( | |
| dashboard_widget="AgentCoachingCard", | |
| detail_view="AgentCoachingDetail" | |
| ) | |
| ) | |
| # ===== VALIDATION UTILITIES ===== | |
| def validate_agent_json(agent_data: Dict[str, Any]) -> SaapAgent: | |
| """Validate and parse agent JSON data""" | |
| try: | |
| return SaapAgent(**agent_data) | |
| except Exception as e: | |
| raise ValueError(f"Invalid agent configuration: {str(e)}") | |
| def generate_agent_schema() -> Dict[str, Any]: | |
| """Generate JSON schema for agent configuration""" | |
| return SaapAgent.schema() | |
| def get_allowed_capabilities() -> List[str]: | |
| """Get list of all allowed capabilities""" | |
| return sorted(list(ALLOWED_CAPABILITIES)) | |
| if __name__ == "__main__": | |
| # Example usage and testing | |
| jane = AgentTemplates.jane_alesi() | |
| print("Jane Alesi Agent:") | |
| print(jane.json(indent=2)) | |
| # Test Theo Alesi template | |
| theo = AgentTemplates.theo_alesi() | |
| print("\nTheo Alesi Agent:") | |
| print(f"ID: {theo.id}, Name: {theo.name}, Capabilities: {theo.capabilities}") | |
| # Generate schema | |
| schema = generate_agent_schema() | |
| print("\nAgent JSON Schema keys:") | |
| print(list(schema.keys())) | |
| # Show allowed capabilities | |
| print(f"\nAllowed capabilities ({len(ALLOWED_CAPABILITIES)}):") | |
| print(get_allowed_capabilities()) | |