Skip to content
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

baidu-qianfan[patch]: Fix streaming mode of Qianfan #6661

Merged
merged 4 commits into from
Sep 10, 2024

Conversation

stanoswald
Copy link
Contributor

@stanoswald stanoswald commented Aug 29, 2024

Even when streaming is set to true, the original completionWithRetry function waits until all chunks are received before triggering the event and returning the result.
This PR updates the completionWithRetry, _generate and use _streamResponseChunks function to handle streaming chunk from BaiduQianFan.
The refactor also fixed the original error of Invalid "runId" provided to "handleLLMNewToken" callback.

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Aug 29, 2024
Copy link

vercel bot commented Aug 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchainjs-docs ✅ Ready (Inspect) Visit Preview Sep 10, 2024 8:24pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ⬜️ Ignored (Inspect) Sep 10, 2024 8:24pm

@dosubot dosubot bot added the auto:bug Related to a bug, vulnerability, unexpected error with an existing feature label Aug 29, 2024
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Aug 29, 2024
@stanoswald
Copy link
Contributor Author

@dl102306

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Aug 30, 2024
@jacoblee93
Copy link
Collaborator

Thanks for this @stanoswald!

This seems like a fairly big refactor, and while it all looks reasonable on the surface, I'd love @dl102306's opinion as well since I'm personally unable to test this integration.

Will give them a few more days and if they don't respond, will merge.

@jacoblee93 jacoblee93 added the hold On hold label Sep 4, 2024
@stanoswald
Copy link
Contributor Author

Thanks for this @stanoswald!

This seems like a fairly big refactor, and while it all looks reasonable on the surface, I'd love @dl102306's opinion as well since I'm personally unable to test this integration.

Will give them a few more days and if they don't respond, will merge.

Sure, I personally have used this branch in production for a while, but only in the usual way of non-streaming and streaming invocation. I'm not sure if this code was mainly maintained by the QianFan platform. As their client, I'll also try to contact them to see if they can review this PR and try to give it a full test to make sure it works well.

@dl102306
Copy link
Contributor

dl102306 commented Sep 5, 2024

@jacoblee93 @stanoswald Sorry for later response. This is a big changes. I need do some test to check this changes works fine today. Please wait for a day or two, thanks a lot.

@dl102306
Copy link
Contributor

dl102306 commented Sep 6, 2024

@jacoblee93 @stanoswald please merge these changes. I have tested these changes. It's work well. thanks~

@jacoblee93
Copy link
Collaborator

Thanks both of you!

@stanoswald
Copy link
Contributor Author

Thanks for looking into this guys! I'll make some further fixes for CI later.

@jacoblee93
Copy link
Collaborator

@stanoswald this is failing CI:

src/chat_models.ts(343,20): error TS18048: 'finalChunk.generationInfo' is possibly 'undefined'.

Can you fix?

Copy link

vercel bot commented Sep 7, 2024

@stanoswald is attempting to deploy a commit to the LangChain Team on Vercel.

A member of the Team first needs to authorize it.

@stanoswald
Copy link
Contributor Author

@jacoblee93 I just updated the code, it should be fixed now.

@stanoswald
Copy link
Contributor Author

@jacoblee93 Hello, could you authorize this to let the CI run?

@jacoblee93 jacoblee93 merged commit e00236d into langchain-ai:main Sep 10, 2024
27 checks passed
@jacoblee93
Copy link
Collaborator

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature hold On hold size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants