-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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.
Thank you! Makes sense, but possibly could be more generalizable?
@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 |
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.
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.
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.
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
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.
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
Improvement made in the Document Refine Chain. This will help show the progress it has made on the refinement process.