harrison/pswsl
Harrison Chase 1 year ago
parent 46354d4f64
commit 450be8d15f

@ -12,10 +12,10 @@ from langchain.python import PythonREPL
from langchain.requests import RequestsWrapper
from langchain.serpapi import SerpAPIWrapper
from langchain.utilities.bash import BashProcess
from langchain.utilities.wsl import WSLProcess
from langchain.utilities.powershell import PowerShellProcess
from langchain.utilities.google_search import GoogleSearchAPIWrapper
from langchain.utilities.powershell import PowerShellProcess
from langchain.utilities.wolfram_alpha import WolframAlphaAPIWrapper
from langchain.utilities.wsl import WSLProcess
def _get_python_repl() -> Tool:
@ -40,14 +40,16 @@ def _get_terminal() -> Tool:
BashProcess().run,
"Executes commands in a terminal. Input should be valid commands, and the output will be any output from running that command.",
)
def _get_wsl() -> Tool:
return Tool(
"WSL",
WSLProcess().run,
"Executes bash commands in a linux system running on Windows Subsystem for Linux (WSL). Input should be valid bash commands, and the output will be any output from running that command.",
)
def _get_powershell() -> Tool:
return Tool(
"PowerShell",
@ -55,6 +57,7 @@ def _get_powershell() -> Tool:
"Executes commands in PowerShell. Input should be valid commands, and the output will be any output from running that command.",
)
_BASE_TOOLS = {
"python_repl": _get_python_repl,
"requests": _get_requests,

@ -15,10 +15,12 @@ class PowerShellProcess:
if isinstance(commands, str):
commands = [commands]
commands = ";".join(commands)
try:
output = subprocess.check_output(["powershell.exe", "-Command", commands]).decode()
output = subprocess.check_output(
["powershell.exe", "-Command", commands]
).decode()
except subprocess.CalledProcessError as error:
return str(error)
if self.strip_newlines:

@ -15,10 +15,10 @@ class WSLProcess:
if isinstance(commands, str):
commands = [commands]
commands = ";".join(commands)
commands = 'wsl.exe ' + commands
commands = "wsl.exe " + commands
try:
output = subprocess.check_output(commands, shell=True).decode()
except subprocess.CalledProcessError as error:
return str(error)
if self.strip_newlines:

Loading…
Cancel
Save