Source code for langchain_community.tools.multion.close_session
fromtypingimportTYPE_CHECKING,Optional,Typefromlangchain_core.callbacksimport(CallbackManagerForToolRun,)fromlangchain_core.toolsimportBaseToolfrompydanticimportBaseModel,FieldifTYPE_CHECKING:# This is for linting and IDE typehintsimportmultionelse:try:# We do this so pydantic can resolve the types when instantiatingimportmultionexceptImportError:pass
[docs]classCloseSessionSchema(BaseModel):"""Input for UpdateSessionTool."""sessionId:str=Field(...,description="""The sessionId, received from one of the createSessions or updateSessions run before""",)
[docs]classMultionCloseSession(BaseTool):# type: ignore[override, override]"""Tool that closes an existing Multion Browser Window with provided fields. Attributes: name: The name of the tool. Default: "close_multion_session" description: The description of the tool. args_schema: The schema for the tool's arguments. Default: UpdateSessionSchema """name:str="close_multion_session"description:str="""Use this tool to close \an existing corresponding Multion Browser Window with provided fields. \Note: SessionId must be received from previous Browser window creation."""args_schema:Type[CloseSessionSchema]=CloseSessionSchemasessionId:str=""def_run(self,sessionId:str,run_manager:Optional[CallbackManagerForToolRun]=None,)->None:try:try:multion.close_session(sessionId)exceptExceptionase:print(f"{e}, retrying...")# noqa: T201exceptExceptionase:raiseException(f"An error occurred: {e}")