-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_usage.py
More file actions
159 lines (125 loc) ยท 6.04 KB
/
example_usage.py
File metadata and controls
159 lines (125 loc) ยท 6.04 KB
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
#!/usr/bin/env python3
"""
Example usage of the Ultimate AI System Automation Agent
This script demonstrates various features and capabilities of the automation agent.
"""
import time
from datetime import datetime, timedelta
from main import UltimateAIAutomationAgent
def main():
"""Example usage of the automation agent"""
print("๐ Ultimate AI System Automation Agent - Example Usage")
print("=" * 60)
# Initialize the agent
print("Initializing automation agent...")
agent = UltimateAIAutomationAgent()
# Start the agent
print("Starting automation agent...")
agent.start()
try:
# Example 1: System Information
print("\n๐ System Information:")
print("-" * 30)
system_info = agent.system_executor.get_system_info()
print(f"Platform: {system_info.get('platform', 'Unknown')}")
print(f"CPU Count: {system_info.get('cpu_count', 'Unknown')}")
print(f"Memory Total: {system_info.get('memory_total', 0) / (1024**3):.2f} GB")
# Example 2: File Operations
print("\n๐ File Operations:")
print("-" * 30)
# Create a test file
test_file = "test_automation.txt"
content = f"Created by Ultimate AI Automation Agent at {datetime.now()}"
if agent.file_manager.create_file(test_file, content):
print(f"โ
Created file: {test_file}")
# Get file info
file_info = agent.file_manager.get_file_info(test_file)
print(f"File size: {file_info.get('size', 0)} bytes")
print(f"Created: {file_info.get('created', 'Unknown')}")
# Example 3: Process Monitoring
print("\n๐ Process Monitoring:")
print("-" * 30)
# Get top processes by CPU usage
processes = agent.process_monitor.get_processes(sort_by="cpu", limit=5)
print("Top 5 processes by CPU usage:")
for i, proc in enumerate(processes, 1):
print(f"{i}. {proc.name}: {proc.cpu_percent:.1f}% CPU, {proc.memory_mb:.1f} MB RAM")
# Example 4: System Health Check
print("\n๐ฅ System Health Check:")
print("-" * 30)
# Perform health check
agent.system_health_check()
# Get system info
system_info = agent.process_monitor.get_system_info()
print(f"CPU Usage: {system_info.get('cpu', {}).get('percent', 0):.1f}%")
print(f"Memory Usage: {system_info.get('memory', {}).get('percent', 0):.1f}%")
print(f"Disk Usage: {system_info.get('disk', {}).get('percent', 0):.1f}%")
# Example 5: Voice Commands (if available)
print("\n๐ค Voice Commands:")
print("-" * 30)
# Add some example voice commands
agent.voice_processor.add_voice_command(
command="show status",
callback=lambda: print("System status displayed!"),
description="Show current system status"
)
agent.voice_processor.add_voice_command(
command="clean files",
callback=lambda: agent.cleanup_temp_files(),
description="Clean up temporary files"
)
print("Voice commands added:")
commands = agent.voice_processor.get_available_commands()
for cmd, desc in commands.items():
print(f" - '{cmd}': {desc}")
# Example 6: AI Chatbot (if configured)
print("\n๐ค AI Chatbot:")
print("-" * 30)
# Test AI response (will use fallback if no API configured)
test_message = "Hello, how are you today?"
response = agent.ai_chatbot.generate_response(test_message)
print(f"User: {test_message}")
print(f"AI: {response}")
# Example 7: Task Management
print("\n๐ Task Management:")
print("-" * 30)
# List all registered tasks
print("Registered automation tasks:")
for task_id, task in agent.tasks.items():
status = "โ
Enabled" if task.enabled else "โ Disabled"
print(f" - {task.name} ({task_id}): {status}")
# Example 8: Safety Features
print("\n๐ก๏ธ Safety Features:")
print("-" * 30)
# Check safety status
safety_status = agent.safety_manager.get_safety_status()
print(f"Safety logging enabled: {safety_status.get('safety_config', {}).get('log_all_actions', False)}")
print(f"Total actions logged: {safety_status.get('total_actions_logged', 0)}")
print(f"Quarantine directory: {safety_status.get('quarantine_directory', 'Not set')}")
# Example 9: Configuration
print("\nโ๏ธ Configuration:")
print("-" * 30)
# Get configuration info
config_info = agent.config_manager.get_config_info()
print(f"Config file: {config_info.get('config_file', 'Unknown')}")
print(f"Version: {config_info.get('version', 'Unknown')}")
print(f"Last updated: {config_info.get('updated_at', 'Unknown')}")
# Example 10: Cleanup
print("\n๐งน Cleanup:")
print("-" * 30)
# Clean up the test file
if agent.file_manager.delete_file(test_file, confirm=False):
print(f"โ
Deleted test file: {test_file}")
print("\nโจ Example completed successfully!")
print("The automation agent is running in the background.")
print("You can now use the interactive mode or let it run automated tasks.")
# Keep the agent running for demonstration
print("\nPress Ctrl+C to stop the agent...")
while True:
time.sleep(1)
except KeyboardInterrupt:
print("\n\n๐ Shutting down automation agent...")
agent.stop()
print("โ
Agent stopped successfully!")
if __name__ == "__main__":
main()