Skip to content

The agent engineering platform.

Update return type for Runnable.__or__ (#12880)

Nuno Camposb2b94424db78
diff --git a/libs/langchain/langchain/schema/runnable/base.py b/libs/langchain/langchain/schema/runnable/base.py
index b99fce2c83..39c99d1463 100644
--- a/libs/langchain/langchain/schema/runnable/base.py
+++ b/libs/langchain/langchain/schema/runnable/base.py
@@ -258,7 +258,7 @@ class Runnable(Generic[Input, Output], ABC):
Callable[[Iterator[Any]], Iterator[Other]],
Mapping[str, Union[Runnable[Any, Other], Callable[[Any], Other], Any]],
],
- ) -> Runnable[Input, Other]:
+ ) -> RunnableSerializable[Input, Other]:
"""Compose this runnable with another object to create a RunnableSequence."""
return RunnableSequence(first=self, last=coerce_to_runnable(other))
@@ -270,7 +270,7 @@ class Runnable(Generic[Input, Output], ABC):
Callable[[Iterator[Other]], Iterator[Any]],
Mapping[str, Union[Runnable[Other, Any], Callable[[Other], Any], Any]],
],
- ) -> Runnable[Other, Output]:
+ ) -> RunnableSerializable[Other, Output]:
"""Compose this runnable with another object to create a RunnableSequence."""
return RunnableSequence(first=coerce_to_runnable(other), last=self)
@@ -1162,7 +1162,7 @@ class RunnableSequence(RunnableSerializable[Input, Output]):
Callable[[Iterator[Any]], Iterator[Other]],
Mapping[str, Union[Runnable[Any, Other], Callable[[Any], Other], Any]],
],
- ) -> Runnable[Input, Other]:
+ ) -> RunnableSerializable[Input, Other]:
if isinstance(other, RunnableSequence):
return RunnableSequence(
first=self.first,
@@ -1184,7 +1184,7 @@ class RunnableSequence(RunnableSerializable[Input, Output]):
Callable[[Iterator[Other]], Iterator[Any]],
Mapping[str, Union[Runnable[Other, Any], Callable[[Other], Any], Any]],
],
- ) -> Runnable[Other, Output]:
+ ) -> RunnableSerializable[Other, Output]:
if isinstance(other, RunnableSequence):
return RunnableSequence(
first=other.first,