core: add a no_collect: bool=False
param to RunnableLambda, enables per-chunk processing instead of whole collected input
#21413
+187
−141
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a new param
no_collect: bool
toRunnableLambda.__init__
. This flags allows for the_transform
and_atransform
methods to not collect input before processing but rather to process each individual chunk viaself.func/self.afunc
. This is particularly useful when we want to keep the input stream flowing as it gets transformed. One specific issue this implementation has solved on my part is being able to have a streamed conversation chain whilst being able to save the final chain output in a context memory. This is a problem some other ppl have encountered in this issue: #11945Example usage:
twitter: @rhighs_