Accept str or list[str] for shell (#4060)

Relax the requirements
This commit is contained in:
Zander Chase
2023-05-03 21:11:06 -07:00
committed by GitHub
parent 5a269d3175
commit 65c3b146c9
2 changed files with 13 additions and 7 deletions

View File

@@ -1,7 +1,7 @@
import asyncio
import platform
import warnings
from typing import List, Optional, Type
from typing import List, Optional, Type, Union
from pydantic import BaseModel, Field, root_validator
@@ -16,7 +16,7 @@ from langchain.utilities.bash import BashProcess
class ShellInput(BaseModel):
"""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",
)
@@ -66,7 +66,7 @@ class ShellTool(BaseTool):
def _run(
self,
commands: List[str],
commands: Union[str, List[str]],
run_manager: Optional[CallbackManagerForToolRun] = None,
) -> str:
"""Run commands and return final output."""
@@ -74,7 +74,7 @@ class ShellTool(BaseTool):
async def _arun(
self,
commands: List[str],
commands: Union[str, List[str]],
run_manager: Optional[AsyncCallbackManagerForToolRun] = None,
) -> str:
"""Run commands asynchronously and return final output."""