-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Stream never closes with LangChainStream using postman #97
Comments
Had the same issue and the workaround I used was to just overwrite the callback after |
@Itsnotaka Could I trouble you to share an example? |
I noticed the same issue with the example. One workaround to get to work is add an
The issue might be within the models in the langchain library to expose a completion event or callback. |
Here is another approach to trigger
|
Have had the same issue which makes onCompletion not work but also the onLoading in the UI. |
Thanks e-roy.
Is a good workaround 🙂 |
@e-roy thanks for the snippet, also solved my problem 👏 |
another solution:
|
This also causes isLoading from useChat() to never go back to false when using LangChainStream. However, e-roy's fix seems to work. |
I think the issue is caused by be90740 When you do what @nfcampos suggested overwriting the returned handlers const { stream, handlers } = LangChainStream();
const model = new ChatOpenAI({
temperature: 0,
streaming: true,
callbacks: CallbackManager.fromHandlers({
handleLLMNewToken: handlers.handleLLMNewToken,
handleChainEnd: async () => {
console.log("handleChainEnd");
await handlers.handleChainEnd();
},
handleLLMEnd: async () => {
console.log("handleLLMEnd");
await handlers.handleChainEnd();
},
handleLLMError: handlers.handleLLMError,
}),
});
It seems that depending on which chain/model you use, It looks like adding |
@aranlucas the issue is actually that you're passing handlers for chain events to the constructor of a chat model, therefore they will never be called. You should pass the handlers either to the constructor of the chain you're using or to the .call() method |
Yeah took me a while to get to that conclusion in #205 (comment). |
Have a few issues with LangChainStream:
Example code:
Example cURL:
Postman screenshot - Connection stays open and never ends. No data returns or streams.
Console output:
Something isn't connecting here I guess if we're getting an array of
undefined
. Any ideas where I'm going wrong here? Any help much appreciated!( additional side note: Would be so cool to have a useStream() for features that are not chat and are not completions! e.g. one off API calls formed from app data like mine. I am passing things to useChat({body: {title:, user_data}}) )
The text was updated successfully, but these errors were encountered: