Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1374,6 +1374,77 @@ module "{module_name}" {{
|
|
| 1374 |
else:
|
| 1375 |
return f"❌ Unknown Terraform tool: {tool_name}. Available: generate_terraform_config, validate_terraform_config, get_deployment_workflow, convert_to_module, format_terraform_code, generate_terraform_docs"
|
| 1376 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1377 |
def select_cisco_tool_and_args(self, user_input: str) -> Dict[str, Any]:
|
| 1378 |
"""Analyze user input to select appropriate Cisco tool and arguments - using ACTUAL tool names"""
|
| 1379 |
user_lower = user_input.lower()
|
|
|
|
| 1374 |
else:
|
| 1375 |
return f"❌ Unknown Terraform tool: {tool_name}. Available: generate_terraform_config, validate_terraform_config, get_deployment_workflow, convert_to_module, format_terraform_code, generate_terraform_docs"
|
| 1376 |
|
| 1377 |
+
def select_linux_tool_and_args(self, user_input: str) -> Dict[str, Any]:
|
| 1378 |
+
"""Analyze user input to select appropriate Linux tool and arguments"""
|
| 1379 |
+
user_lower = user_input.lower()
|
| 1380 |
+
|
| 1381 |
+
# File operations
|
| 1382 |
+
if any(word in user_lower for word in ["list", "ls", "show files", "directory"]):
|
| 1383 |
+
if "detailed" in user_lower or "-l" in user_lower:
|
| 1384 |
+
return {"tool": "list_files", "args": {"path": ".", "detailed": True}}
|
| 1385 |
+
else:
|
| 1386 |
+
return {"tool": "list_files", "args": {"path": ".", "detailed": False}}
|
| 1387 |
+
|
| 1388 |
+
elif any(word in user_lower for word in ["read", "cat", "view", "show content"]):
|
| 1389 |
+
return {"tool": "read_file", "args": {"filepath": "/etc/hostname"}}
|
| 1390 |
+
|
| 1391 |
+
elif any(word in user_lower for word in ["write", "create file", "echo"]):
|
| 1392 |
+
return {"tool": "write_file", "args": {"filepath": "/tmp/test.txt", "content": "Hello from MCP"}}
|
| 1393 |
+
|
| 1394 |
+
# System information
|
| 1395 |
+
elif any(word in user_lower for word in ["system", "info", "uname", "system info"]):
|
| 1396 |
+
return {"tool": "get_system_info", "args": {}}
|
| 1397 |
+
|
| 1398 |
+
elif any(word in user_lower for word in ["processes", "ps", "running", "process list"]):
|
| 1399 |
+
return {"tool": "list_processes", "args": {"filter": ""}}
|
| 1400 |
+
|
| 1401 |
+
elif any(word in user_lower for word in ["memory", "mem", "ram", "memory usage"]):
|
| 1402 |
+
return {"tool": "get_memory_usage", "args": {}}
|
| 1403 |
+
|
| 1404 |
+
elif any(word in user_lower for word in ["disk", "storage", "df", "disk usage"]):
|
| 1405 |
+
return {"tool": "get_disk_usage", "args": {}}
|
| 1406 |
+
|
| 1407 |
+
# Network operations
|
| 1408 |
+
elif any(word in user_lower for word in ["network", "netstat", "connections"]):
|
| 1409 |
+
return {"tool": "get_network_info", "args": {}}
|
| 1410 |
+
|
| 1411 |
+
elif any(word in user_lower for word in ["ping", "connectivity", "test connection"]):
|
| 1412 |
+
return {"tool": "ping_host", "args": {"host": "google.com", "count": 4}}
|
| 1413 |
+
|
| 1414 |
+
# Process management
|
| 1415 |
+
elif any(word in user_lower for word in ["kill", "stop", "terminate"]):
|
| 1416 |
+
return {"tool": "kill_process", "args": {"pid_or_name": "example_process"}}
|
| 1417 |
+
|
| 1418 |
+
# Package management
|
| 1419 |
+
elif any(word in user_lower for word in ["install", "package", "apt", "yum"]):
|
| 1420 |
+
return {"tool": "manage_packages", "args": {"operation": "install", "package": "curl"}}
|
| 1421 |
+
|
| 1422 |
+
elif any(word in user_lower for word in ["search package", "find package"]):
|
| 1423 |
+
return {"tool": "manage_packages", "args": {"operation": "search", "package": "python"}}
|
| 1424 |
+
|
| 1425 |
+
# Service management
|
| 1426 |
+
elif any(word in user_lower for word in ["service", "systemctl", "start service", "stop service"]):
|
| 1427 |
+
if "start" in user_lower:
|
| 1428 |
+
return {"tool": "manage_services", "args": {"service": "nginx", "action": "start"}}
|
| 1429 |
+
elif "stop" in user_lower:
|
| 1430 |
+
return {"tool": "manage_services", "args": {"service": "nginx", "action": "stop"}}
|
| 1431 |
+
elif "status" in user_lower:
|
| 1432 |
+
return {"tool": "manage_services", "args": {"service": "nginx", "action": "status"}}
|
| 1433 |
+
else:
|
| 1434 |
+
return {"tool": "manage_services", "args": {"service": "nginx", "action": "status"}}
|
| 1435 |
+
|
| 1436 |
+
# Log viewing
|
| 1437 |
+
elif any(word in user_lower for word in ["log", "logs", "syslog", "journal"]):
|
| 1438 |
+
return {"tool": "view_logs", "args": {"log_type": "syslog", "lines": 50}}
|
| 1439 |
+
|
| 1440 |
+
# Environment variables
|
| 1441 |
+
elif any(word in user_lower for word in ["env", "environment", "variables"]):
|
| 1442 |
+
return {"tool": "get_environment", "args": {}}
|
| 1443 |
+
|
| 1444 |
+
# Default - show help
|
| 1445 |
+
else:
|
| 1446 |
+
return {"tool": "help", "args": {}}
|
| 1447 |
+
|
| 1448 |
def select_cisco_tool_and_args(self, user_input: str) -> Dict[str, Any]:
|
| 1449 |
"""Analyze user input to select appropriate Cisco tool and arguments - using ACTUAL tool names"""
|
| 1450 |
user_lower = user_input.lower()
|