This commit is contained in:
Harrison Chase 2023-02-09 23:50:27 -08:00
parent 46354d4f64
commit 450be8d15f
3 changed files with 14 additions and 9 deletions

View File

@ -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:
@ -41,6 +41,7 @@ def _get_terminal() -> Tool:
"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",
@ -48,6 +49,7 @@ def _get_wsl() -> Tool:
"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,

View File

@ -17,7 +17,9 @@ class PowerShellProcess:
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)

View File

@ -15,7 +15,7 @@ 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()