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

Ensure that run managers are returned from handleLLMStart/handleChatModelStart always in the same order as the prompts passed in #1779

Merged
merged 1 commit into from
Jun 27, 2023

Conversation

nfcampos
Copy link
Collaborator

What was happening was that the runManager was only added to the managers array after the callback handlers finished executing, so eg if the callback handlers for the second run finished first the runManager for prompt #2 would actually be in position #1 of the returned array.

Fixes # (issue)

…odelStart always in the same order as the prompts passed in

What was happening was that the runManager was only added to the managers array after the callback handlers finished executing, so eg if the callback handlers for the second run finished first the runManager for prompt #2 would actually be in position #1 of the returned array.
@nfcampos nfcampos requested a review from agola11 June 27, 2023 13:39
@vercel
Copy link

vercel bot commented Jun 27, 2023

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

Name Status Preview Updated (UTC)
langchainjs-docs ✅ Ready (Inspect) Visit Preview Jun 27, 2023 1:46pm

const managers: CallbackManagerForLLMRun[] = [];

await Promise.all(
return Promise.all(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's tricky. So the callback in Promise.map() is executed whenever that promise is actually finished but then the result of it all is still ordered?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the promises in promise.all are all executed simultaneously, all starting at the same time. But promise.all does guarantee that no matter what the order in which they finish the returned array will hold the return values of each in the order they were passed in.

@agola11 agola11 merged commit 78e00a3 into main Jun 27, 2023
@agola11 agola11 deleted the nc/fix-multi-prompt-run-split branch June 27, 2023 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants