Skip to content

Commit

Permalink
Fix combining runnable sequences (#8557)
Browse files Browse the repository at this point in the history
Combining runnable sequences was dropping a step in the middle.

@nfcampos @baskaryan
  • Loading branch information
jacoblee93 committed Aug 1, 2023
1 parent 3fbb737 commit 2a26cc6
Show file tree
Hide file tree
Showing 3 changed files with 511 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libs/langchain/langchain/schema/runnable.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def __or__(
if isinstance(other, RunnableSequence):
return RunnableSequence(
first=self.first,
middle=self.middle + [self.last] + other.middle,
middle=self.middle + [self.last] + [other.first] + other.middle,
last=other.last,
)
else:
Expand All @@ -235,7 +235,7 @@ def __ror__(
if isinstance(other, RunnableSequence):
return RunnableSequence(
first=other.first,
middle=other.middle + [other.last] + self.middle,
middle=other.middle + [other.last] + [self.first] + self.middle,
last=self.last,
)
else:
Expand Down

0 comments on commit 2a26cc6

Please sign in to comment.