Source code for langchain_community.tools.multion.update_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]classUpdateSessionSchema(BaseModel):"""Input for UpdateSessionTool."""sessionId:str=Field(...,description="""The sessionID, received from one of the createSessions run before""",)query:str=Field(...,description="The query to run in multion agent.",)url:str=Field("https://www.google.com/",description="""The Url to run the agent at. \ Note: accepts only secure links having https://""",)
[docs]classMultionUpdateSession(BaseTool):# type: ignore[override, override]"""Tool that updates an existing Multion Browser Window with provided fields. Attributes: name: The name of the tool. Default: "update_multion_session" description: The description of the tool. args_schema: The schema for the tool's arguments. Default: UpdateSessionSchema """name:str="update_multion_session"description:str="""Use this tool to update \an existing corresponding Multion Browser Window with provided fields. \Note: sessionId must be received from previous Browser window creation."""args_schema:Type[UpdateSessionSchema]=UpdateSessionSchemasessionId:str=""def_run(self,sessionId:str,query:str,url:Optional[str]="https://www.google.com/",run_manager:Optional[CallbackManagerForToolRun]=None,)->dict:try:try:response=multion.update_session(sessionId,{"input":query,"url":url})content={"sessionId":sessionId,"Response":response["message"]}self.sessionId=sessionIdreturncontentexceptExceptionase:print(f"{e}, retrying...")# noqa: T201return{"error":f"{e}","Response":"retrying..."}exceptExceptionase:raiseException(f"An error occurred: {e}")