diff --git a/libs/community/langchain_community/chat_models/gpt_router.py b/libs/community/langchain_community/chat_models/gpt_router.py index 1e53f41a3d7c4..ac91200ed4e3e 100644 --- a/libs/community/langchain_community/chat_models/gpt_router.py +++ b/libs/community/langchain_community/chat_models/gpt_router.py @@ -233,8 +233,8 @@ def _generate( self, messages: List[BaseMessage], stop: Optional[List[str]] = None, - run_manager: CallbackManagerForLLMRun | None = None, - stream: bool | None = None, + run_manager: Optional[CallbackManagerForLLMRun] = None, + stream: Optional[bool] = None, **kwargs: Any, ) -> ChatResult: should_stream = stream if stream is not None else self.streaming @@ -259,8 +259,8 @@ async def _agenerate( self, messages: List[BaseMessage], stop: Optional[List[str]] = None, - run_manager: AsyncCallbackManagerForLLMRun | None = None, - stream: bool | None = None, + run_manager: Optional[AsyncCallbackManagerForLLMRun] = None, + stream: Optional[bool] = None, **kwargs: Any, ) -> ChatResult: should_stream = stream if stream is not None else self.streaming diff --git a/libs/community/langchain_community/tools/e2b_data_analysis/tool.py b/libs/community/langchain_community/tools/e2b_data_analysis/tool.py index 0794b87469ef9..242b305e1bc51 100644 --- a/libs/community/langchain_community/tools/e2b_data_analysis/tool.py +++ b/libs/community/langchain_community/tools/e2b_data_analysis/tool.py @@ -5,7 +5,7 @@ import os from io import StringIO from sys import version_info -from typing import IO, TYPE_CHECKING, Any, Callable, List, Optional, Type +from typing import IO, TYPE_CHECKING, Any, Callable, List, Optional, Type, Union from langchain_core.callbacks import ( AsyncCallbackManagerForToolRun, @@ -197,11 +197,11 @@ def run_command( "exit_code": output.exit_code, } - def install_python_packages(self, package_names: str | List[str]) -> None: + def install_python_packages(self, package_names: Union[str, List[str]]) -> None: """Install python packages in the sandbox.""" self.session.install_python_packages(package_names) - def install_system_packages(self, package_names: str | List[str]) -> None: + def install_system_packages(self, package_names: Union[str, List[str]]) -> None: """Install system packages (via apt) in the sandbox.""" self.session.install_system_packages(package_names) diff --git a/libs/core/langchain_core/output_parsers/base.py b/libs/core/langchain_core/output_parsers/base.py index 4f8588b205862..c5c2e379e8c65 100644 --- a/libs/core/langchain_core/output_parsers/base.py +++ b/libs/core/langchain_core/output_parsers/base.py @@ -96,7 +96,7 @@ def invoke( async def ainvoke( self, - input: str | BaseMessage, + input: Union[str, BaseMessage], config: Optional[RunnableConfig] = None, **kwargs: Optional[Any], ) -> T: @@ -185,7 +185,7 @@ def invoke( async def ainvoke( self, - input: str | BaseMessage, + input: Union[str, BaseMessage], config: Optional[RunnableConfig] = None, **kwargs: Optional[Any], ) -> T: diff --git a/libs/core/langchain_core/tracers/base.py b/libs/core/langchain_core/tracers/base.py index a963fa02b3111..9d36e8d45bd47 100644 --- a/libs/core/langchain_core/tracers/base.py +++ b/libs/core/langchain_core/tracers/base.py @@ -118,7 +118,7 @@ def _get_execution_order(self, parent_run_id: Optional[str] = None) -> int: return parent_run.child_execution_order + 1 - def _get_run(self, run_id: UUID, run_type: str | None = None) -> Run: + def _get_run(self, run_id: UUID, run_type: Optional[str] = None) -> Run: try: run = self.run_map[str(run_id)] except KeyError as exc: