Spaces:
Running
on
Zero
Running
on
Zero
| """ | |
| Example Usage Scenarios for Secure AI Agents Suite | |
| Demonstrates real-world use cases for each agent | |
| """ | |
| import asyncio | |
| import json | |
| from datetime import datetime, timedelta | |
| from typing import Dict, List, Any | |
| # Import agents (would work after dependencies are installed) | |
| try: | |
| from enterprise.enterprise_agent import EnterpriseAgent | |
| from consumer.consumer_agent import ConsumerAgent | |
| from creative.creative_agent import CreativeAgent | |
| from voice.voice_agent import VoiceAgent | |
| except ImportError as e: | |
| print(f"Note: Import error (expected before dependencies): {e}") | |
| print("Run 'pip install -r requirements.txt' to install dependencies") | |
| class ScenarioRunner: | |
| """Runs example scenarios for all agents.""" | |
| def __init__(self): | |
| self.scenarios = { | |
| "enterprise": self._enterprise_scenarios(), | |
| "consumer": self._consumer_scenarios(), | |
| "creative": self._creative_scenarios(), | |
| "voice": self._voice_scenarios() | |
| } | |
| def _enterprise_scenarios(self) -> List[Dict[str, Any]]: | |
| """Enterprise Agent scenarios.""" | |
| return [ | |
| { | |
| "name": "CRM Customer Update", | |
| "description": "Update customer information in CRM system", | |
| "input": "Update customer 001 email to newemail@company.com", | |
| "expected_output": "Customer update confirmation with details" | |
| }, | |
| { | |
| "name": "Support Ticket Creation", | |
| "description": "Create a high-priority support ticket", | |
| "input": "Create ticket about login issues - high priority", | |
| "expected_output": "Ticket ID and confirmation message" | |
| }, | |
| { | |
| "name": "Calendar Scheduling", | |
| "description": "Schedule a team meeting", | |
| "input": "Schedule team meeting for tomorrow at 2 PM", | |
| "expected_output": "Event confirmation with details" | |
| }, | |
| { | |
| "name": "Contact Search", | |
| "description": "Search for specific contacts", | |
| "input": "Search for john contacts", | |
| "expected_output": "List of matching contacts with details" | |
| }, | |
| { | |
| "name": "Calendar View", | |
| "description": "View today's calendar events", | |
| "input": "Show calendar events for today", | |
| "expected_output": "List of scheduled events" | |
| }, | |
| { | |
| "name": "System Status Check", | |
| "description": "Check agent system status", | |
| "input": "Check system status", | |
| "expected_output": "Agent status and tool availability" | |
| } | |
| ] | |
| def _consumer_scenarios(self) -> List[Dict[str, Any]]: | |
| """Consumer Agent scenarios.""" | |
| return [ | |
| { | |
| "name": "Trip Planning", | |
| "description": "Plan a vacation to Pokhara", | |
| "input": "Plan a trip to Pokhara next week with medium budget", | |
| "expected_output": "Complete itinerary with activities and costs" | |
| }, | |
| { | |
| "name": "Reminder Creation", | |
| "description": "Set a personal reminder", | |
| "input": "Remind me to call mom tomorrow at 3 PM", | |
| "expected_output": "Reminder confirmation with scheduling details" | |
| }, | |
| { | |
| "name": "Document Summary", | |
| "description": "Summarize a document", | |
| "input": "Summarize this email about project deadlines", | |
| "expected_output": "Key points and summary" | |
| }, | |
| { | |
| "name": "Weather Check", | |
| "description": "Check weather for Kathmandu", | |
| "input": "What's the weather like in Kathmandu?", | |
| "expected_output": "Current weather and forecast" | |
| }, | |
| { | |
| "name": "Travel Search", | |
| "description": "Search for hotels in Delhi", | |
| "input": "Search for hotels in Delhi for December", | |
| "expected_output": "Hotel options with prices and features" | |
| }, | |
| { | |
| "name": "Expense Tracking", | |
| "description": "Check monthly budget", | |
| "input": "Show my travel budget report", | |
| "expected_output": "Budget summary with spending breakdown" | |
| } | |
| ] | |
| def _creative_scenarios(self) -> List[Dict[str, Any]]: | |
| """Creative Agent scenarios.""" | |
| return [ | |
| { | |
| "name": "Bilingual Content Carousel", | |
| "description": "Create a product presentation", | |
| "input": "Create a 5-slide carousel about our new product in English and Nepali", | |
| "expected_output": "Bilingual slides with content and formatting" | |
| }, | |
| { | |
| "name": "Commercial Script", | |
| "description": "Write a 60-second commercial", | |
| "input": "Write a 60-second commercial script for a tech startup", | |
| "expected_output": "Professional script with timing and dialogue" | |
| }, | |
| { | |
| "name": "Brand Guidelines", | |
| "description": "Create brand identity", | |
| "input": "Design brand guidelines for 'TechCorp Nepal'", | |
| "expected_output": "Complete brand book with colors, fonts, voice" | |
| }, | |
| { | |
| "name": "Translation Service", | |
| "description": "Translate text to Nepali", | |
| "input": "Translate 'Hello, welcome to our website' to Nepali", | |
| "expected_output": "Accurate translation with cultural context" | |
| }, | |
| { | |
| "name": "Asset Package", | |
| "description": "Package logo assets", | |
| "input": "Package logo assets in high resolution", | |
| "expected_output": "Downloadable asset bundle with formats" | |
| }, | |
| { | |
| "name": "Content Calendar", | |
| "description": "Create social media calendar", | |
| "input": "Create a content calendar for social media", | |
| "expected_output": "Monthly calendar with posting schedule" | |
| } | |
| ] | |
| def _voice_scenarios(self) -> List[Dict[str, Any]]: | |
| """Voice Agent scenarios.""" | |
| return [ | |
| { | |
| "name": "Speech Transcription", | |
| "description": "Convert speech to text", | |
| "input": "Transcribe this audio file", | |
| "expected_output": "Accurate text transcription with confidence scores" | |
| }, | |
| { | |
| "name": "Text-to-Speech", | |
| "description": "Generate natural speech", | |
| "input": "Say 'Hello, welcome to our voice AI' in a female voice", | |
| "expected_output": "Audio file with natural-sounding speech" | |
| }, | |
| { | |
| "name": "Voice Conversation", | |
| "description": "Start voice chat with AI", | |
| "input": "Start a voice conversation", | |
| "expected_output": "Full-duplex voice interaction setup" | |
| }, | |
| { | |
| "name": "Audio Analysis", | |
| "description": "Analyze audio sentiment", | |
| "input": "Analyze the sentiment of this audio", | |
| "expected_output": "Sentiment analysis and speaker insights" | |
| }, | |
| { | |
| "name": "Multilingual Voice", | |
| "description": "Process multilingual audio", | |
| "input": "Enable multilingual voice mode", | |
| "expected_output": "Language detection and processing setup" | |
| }, | |
| { | |
| "name": "Voice Search", | |
| "description": "Search voice recordings", | |
| "input": "Search for meeting recordings about project updates", | |
| "expected_output": "Search results with transcription matches" | |
| } | |
| ] | |
| def run_scenario(self, agent_type: str, scenario_index: int = 0) -> Dict[str, Any]: | |
| """Run a specific scenario.""" | |
| if agent_type not in self.scenarios: | |
| return {"error": f"Unknown agent type: {agent_type}"} | |
| scenarios = self.scenarios[agent_type] | |
| if scenario_index >= len(scenarios): | |
| return {"error": f"Scenario index {scenario_index} out of range"} | |
| scenario = scenarios[scenario_index] | |
| print(f"\n๐ฌ Running Scenario: {scenario['name']}") | |
| print(f"๐ Description: {scenario['description']}") | |
| print(f"๐ฌ Input: {scenario['input']}") | |
| print(f"๐ฏ Expected: {scenario['expected_output']}") | |
| # Simulate agent processing | |
| return { | |
| "scenario": scenario, | |
| "status": "simulated", | |
| "timestamp": datetime.utcnow().isoformat(), | |
| "note": "Run with actual agents after installing dependencies" | |
| } | |
| def run_all_scenarios(self, agent_type: str = None) -> List[Dict[str, Any]]: | |
| """Run all scenarios for an agent type or all agents.""" | |
| results = [] | |
| if agent_type: | |
| if agent_type not in self.scenarios: | |
| return [{"error": f"Unknown agent type: {agent_type}"}] | |
| agent_scenarios = {agent_type: self.scenarios[agent_type]} | |
| else: | |
| agent_scenarios = self.scenarios | |
| for current_agent, scenarios in agent_scenarios.items(): | |
| print(f"\n๐ Running {current_agent.upper()} AGENT SCENARIOS") | |
| print("=" * 50) | |
| for i, scenario in enumerate(scenarios): | |
| result = self.run_scenario(current_agent, i) | |
| results.append(result) | |
| print(f"โ Completed: {scenario['name']}") | |
| return results | |
| def print_scenario_guide(self): | |
| """Print a guide for using scenarios.""" | |
| print("\n" + "="*60) | |
| print("๐ฌ SECURE AI AGENTS SUITE - SCENARIO GUIDE") | |
| print("="*60) | |
| for agent_type, scenarios in self.scenarios.items(): | |
| print(f"\n๐ท๏ธ {agent_type.upper()} AGENT ({len(scenarios)} scenarios)") | |
| for i, scenario in enumerate(scenarios): | |
| print(f" {i+1}. {scenario['name']}") | |
| print(f" {scenario['description']}") | |
| def main(): | |
| """Main function to run scenarios.""" | |
| runner = ScenarioRunner() | |
| print("๐ฌ Secure AI Agents Suite - Example Scenarios") | |
| print("="*50) | |
| # Print scenario guide | |
| runner.print_scenario_guide() | |
| print("\n๐ก Usage Examples:") | |
| print(" # Run all scenarios") | |
| print(" python examples.py --all") | |
| print("") | |
| print(" # Run specific agent scenarios") | |
| print(" python examples.py --agent enterprise") | |
| print(" python examples.py --agent consumer") | |
| print(" python examples.py --agent creative") | |
| print(" python examples.py --agent voice") | |
| print("") | |
| print(" # Run specific scenario") | |
| print(" python examples.py --agent enterprise --scenario 0") | |
| print("") | |
| print(" # Interactive mode") | |
| print(" python examples.py --interactive") | |
| # Parse command line arguments (simplified) | |
| import sys | |
| if "--help" in sys.argv or "-h" in sys.argv: | |
| return | |
| if "--all" in sys.argv: | |
| print("\n๐ Running all scenarios...") | |
| results = runner.run_all_scenarios() | |
| print(f"\nโ Completed {len(results)} scenarios") | |
| elif "--agent" in sys.argv: | |
| agent_index = sys.argv.index("--agent") + 1 | |
| if agent_index < len(sys.argv): | |
| agent_type = sys.argv[agent_index] | |
| if "--scenario" in sys.argv: | |
| scenario_index = sys.argv.index("--scenario") + 1 | |
| if scenario_index < len(sys.argv): | |
| scenario_num = int(sys.argv[scenario_index]) - 1 | |
| result = runner.run_scenario(agent_type, scenario_num) | |
| print(f"\nโ Scenario result: {result}") | |
| else: | |
| print(f"\n๐ Running all {agent_type} scenarios...") | |
| results = runner.run_all_scenarios(agent_type) | |
| print(f"\nโ Completed {len(results)} scenarios") | |
| elif "--interactive" in sys.argv: | |
| print("\n๐ฎ Interactive Scenario Runner") | |
| print("Available agents: enterprise, consumer, creative, voice") | |
| while True: | |
| try: | |
| agent = input("\nEnter agent type (or 'quit'): ").strip().lower() | |
| if agent == 'quit': | |
| break | |
| if agent not in runner.scenarios: | |
| print("Invalid agent type. Try again.") | |
| continue | |
| scenarios = runner.scenarios[agent] | |
| print(f"\nAvailable scenarios for {agent}:") | |
| for i, scenario in enumerate(scenarios): | |
| print(f" {i+1}. {scenario['name']}") | |
| try: | |
| choice = int(input("Select scenario (number): ")) - 1 | |
| if 0 <= choice < len(scenarios): | |
| result = runner.run_scenario(agent, choice) | |
| print(f"\nโ Scenario completed!") | |
| else: | |
| print("Invalid scenario number.") | |
| except ValueError: | |
| print("Please enter a valid number.") | |
| except KeyboardInterrupt: | |
| print("\n๐ Goodbye!") | |
| break | |
| else: | |
| print("\n๐ก Use --help for usage examples") | |
| if __name__ == "__main__": | |
| main() |