Spaces:
Running
on
Zero
Running
on
Zero
File size: 14,033 Bytes
2ec0d39 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
"""
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() |