|
|
@ -1,7 +1,7 @@
|
|
|
|
import asyncio
|
|
|
|
import asyncio
|
|
|
|
import platform
|
|
|
|
import platform
|
|
|
|
import warnings
|
|
|
|
import warnings
|
|
|
|
from typing import List, Optional, Type
|
|
|
|
from typing import List, Optional, Type, Union
|
|
|
|
|
|
|
|
|
|
|
|
from pydantic import BaseModel, Field, root_validator
|
|
|
|
from pydantic import BaseModel, Field, root_validator
|
|
|
|
|
|
|
|
|
|
|
@ -16,7 +16,7 @@ from langchain.utilities.bash import BashProcess
|
|
|
|
class ShellInput(BaseModel):
|
|
|
|
class ShellInput(BaseModel):
|
|
|
|
"""Commands for the Bash Shell tool."""
|
|
|
|
"""Commands for the Bash Shell tool."""
|
|
|
|
|
|
|
|
|
|
|
|
commands: List[str] = Field(
|
|
|
|
commands: Union[str, List[str]] = Field(
|
|
|
|
...,
|
|
|
|
...,
|
|
|
|
description="List of shell commands to run. Deserialized using json.loads",
|
|
|
|
description="List of shell commands to run. Deserialized using json.loads",
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -66,7 +66,7 @@ class ShellTool(BaseTool):
|
|
|
|
|
|
|
|
|
|
|
|
def _run(
|
|
|
|
def _run(
|
|
|
|
self,
|
|
|
|
self,
|
|
|
|
commands: List[str],
|
|
|
|
commands: Union[str, List[str]],
|
|
|
|
run_manager: Optional[CallbackManagerForToolRun] = None,
|
|
|
|
run_manager: Optional[CallbackManagerForToolRun] = None,
|
|
|
|
) -> str:
|
|
|
|
) -> str:
|
|
|
|
"""Run commands and return final output."""
|
|
|
|
"""Run commands and return final output."""
|
|
|
@ -74,7 +74,7 @@ class ShellTool(BaseTool):
|
|
|
|
|
|
|
|
|
|
|
|
async def _arun(
|
|
|
|
async def _arun(
|
|
|
|
self,
|
|
|
|
self,
|
|
|
|
commands: List[str],
|
|
|
|
commands: Union[str, List[str]],
|
|
|
|
run_manager: Optional[AsyncCallbackManagerForToolRun] = None,
|
|
|
|
run_manager: Optional[AsyncCallbackManagerForToolRun] = None,
|
|
|
|
) -> str:
|
|
|
|
) -> str:
|
|
|
|
"""Run commands asynchronously and return final output."""
|
|
|
|
"""Run commands asynchronously and return final output."""
|
|
|
|