-
Notifications
You must be signed in to change notification settings - Fork 2.5k
core[patch]: Fix RemoteRunnable streaming when used in sequences, add tracing #4882
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core[patch]: Fix RemoteRunnable streaming when used in sequences, add tracing #4882
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
0c657eb
to
42de19f
Compare
Thanks for this! Would be good to add a test confirming the fix? |
|
||
test("StreamIterator yield stream model output", async () => { | ||
const remote = new RemoteRunnable({ url: `${BASE_URL}/b` }); | ||
const streamIterator = await remote._streamIterator({ text: "What are the 5 best apples?" }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should test streaming usage in a chain though? That's what the issue was about:
e.g.
const chain = prompt.pipe(remote).stream();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought I would just test _streamIterator
function which I added. But, I think what you said make sense. Let me try with chain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated!!
3f93620
to
7ff83ad
Compare
…rahilvora/override_stream_iterator
Thanks! |
This PR is trying to solve issue where
RemoteRunnable
object does not support streaming withRunnableSequence
Code Flow
RunnableSequence
andRemoteRunnable
both the classes extendsRunnable
classRunnable
class has implementation ofstream
. Now,const chain = RunnableSequence.from([prompt, model])
returnsRunnableSequence
object.chain.stream
would call stream function onRunnable
class (parent class) asRunnableSequence
class (child class) does not have stream function on it.Now,
stream
function inRunnable
class callsthis._streamIterator
. In this context,this
isRunnableSequence
, Hence it will call_streamIterator
ofRunnableSequence
._streamIterator
callsobject.transform
function, which callstransform
function ofRunnable
class.transform
function internally callsthis._streamIterator
again. Now,this
isobject context
which isRemoteRunnable
But, in case of
RemoteRunnable
object (which is passed as model in above example), does not have implementation of_streamIterator
function hence it calls_streamIterator
of parent class i.e.Runnable class
which internally is yieldinginvoke
(this.invoke(input, options);
. Hence, this callsRemoteRunnable invoke function
.Fix
We need to override
_streamIterator
for RemoteRunnable class, so that it yieldstream
instead ofinvoke
.Fixes #4811