BashProcess#
- class langchain_experimental.llm_bash.bash.BashProcess(strip_newlines: bool = False, return_err_output: bool = False, persistent: bool = False)[source]#
Wrapper for starting subprocesses.
Uses the python built-in subprocesses.run() Persistent processes are not available on Windows systems, as pexpect makes use of Unix pseudoterminals (ptys). MacOS and Linux are okay.
Example
from langchain_community.utilities.bash import BashProcess bash = BashProcess( strip_newlines = False, return_err_output = False, persistent = False ) bash.run('echo 'hello world'')
Initializes with default settings
Attributes
persistent
Whether or not to spawn a persistent session NOTE: Unavailable for Windows environments
return_err_output
Whether or not to return the output of a failed command, or just the error message and stacktrace
strip_newlines
Whether or not to run .strip() on the output
Methods
__init__
([strip_newlines,Β ...])Initializes with default settings
process_output
(output,Β command)Uses regex to remove the command from the output
run
(commands)Run commands in either an existing persistent subprocess or on in a new subprocess environment.
- Parameters:
strip_newlines (bool) β
return_err_output (bool) β
persistent (bool) β
- __init__(strip_newlines: bool = False, return_err_output: bool = False, persistent: bool = False)[source]#
Initializes with default settings
- Parameters:
strip_newlines (bool) β
return_err_output (bool) β
persistent (bool) β