Skip to content

Added async progres checker function in refineDocuments chain #3591

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

faysal515
Copy link

Improvement made in the Document Refine Chain. This will help show the progress it has made on the refinement process.

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Dec 8, 2023
Copy link

vercel bot commented Dec 8, 2023

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

Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 18, 2023 5:31am
langchainjs-docs ✅ Ready (Inspect) Visit Preview Dec 18, 2023 5:31am

Copy link
Collaborator

@jacoblee93 jacoblee93 left a comment

Choose a reason for hiding this comment

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

Thank you! Makes sense, but possibly could be more generalizable?

@jacoblee93 jacoblee93 added the question Further information is requested label Dec 13, 2023
@faysal515
Copy link
Author

faysal515 commented Dec 18, 2023

@jacoblee93 Sure. Updated

2. progress value trimmed to 2 decimal point
@@ -439,6 +443,10 @@ export class RefineDocumentsChain
runManager?.getChild("refine")
);
refineSteps.push(res);
if (this.onDocumentProcessed) {
const progress = (i / currentDocs.length).toFixed(2); // Progress calculation
await this.onDocumentProcessed(Number(progress)); // Emitting the progress
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, was also suggesting that this emits the actual document in addition to just a fraction. User could calculate a progress meter on their own.

Let's actually hold off on this though - we're starting to look more at these older chains to see how we can modernize them more with LCEL principles.

Copy link
Author

Choose a reason for hiding this comment

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

Right, instead of calculating and returning the progress, would make more sense to return the document itself,
and maybe the current loop number, It'd allow more freedom in the code side.

I understand that this is currently on hold to adapt and implement in LECL way, any tentative plan for when is this feature might be picked up? (I kind of need this for my project)

Thanks

Copy link
Collaborator

Choose a reason for hiding this comment

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

So sorry for missing this reply - could this work with the existing callback system by adding a handleLLMEnd callback to the model?

https://js.langchain.com/docs/modules/callbacks/how_to/create_handler

@jacoblee93 jacoblee93 added the hold On hold label Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:improvement Medium size change to existing code to handle new use-cases hold On hold question Further information is requested size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants