MCPcopy Index your code
hub / github.com/geekcomputers/Python / run_action

Function run_action

JARVIS/actions.py:69–93  ·  view source on GitHub ↗
(action)

Source from the content-addressed store, hash-verified

67
68
69def run_action(action):
70 if not action:
71 return ""
72 action = action.strip()
73 lowered = action.lower()
74 if lowered == "open_cmd":
75 os.startfile("cmd.exe")
76 return "Opening Command Prompt."
77 if lowered == "blocked" or is_dangerous_request(action):
78 return "I cannot do that for safety."
79 if lowered.startswith("open_web:"):
80 return open_web_target(action.split(":", 1)[1].strip())
81 if lowered.startswith("search_google:"):
82 query = action.split(":", 1)[1].strip().strip("<> ")
83 if not query or is_dangerous_request(query):
84 return "I cannot search that for safety."
85 webbrowser.open(f"https://www.google.com/search?q={quote_plus(query)}")
86 return f"Searching Google for {query}."
87 if lowered.startswith("open_app:"):
88 return open_application(action.split(":", 1)[1].strip())
89 if lowered.startswith("close_app:"):
90 return close_visible_window(action.split(":", 1)[1].strip())
91 if lowered == "chat":
92 return ""
93 return ""
94
95
96def rule_based_action(text):

Callers 1

handle_user_textFunction · 0.85

Calls 4

is_dangerous_requestFunction · 0.85
open_web_targetFunction · 0.85
open_applicationFunction · 0.85
close_visible_windowFunction · 0.85

Tested by

no test coverage detected