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

[Feature] Add a callback for generation complete in streaming mode or some other signal like is_final_token #2451

Open
JohnDuncanScott opened this issue Jun 17, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@JohnDuncanScott
Copy link

Feature Request

The generate method in Python allows a callback to be provided so you can control the tokens being produced. However, there is no signal that the generation has completed. There should be some signal received, either a separate callback or perhaps a boolean in the callback like is_final_token.

The workarounds is for whatever is streaming the tokens to then signal it's received everything. However, this muddies the layers.

So for example:
Component A receives streaming input and displays it on screen
Component B is responsible for creating and managing the model and is what you call generate on
With the current API, Component B that owns the model itself doesn't know when the model is done. There are no methods on the model to ask is_generating or any param in the callback or another callback to signal it's done. This makes it difficult for Component B to do clean up or perform logic that should happen after generation is completed.

Hope that makes sense.

This should hopefully be really simple to implement but would make user logic much cleaner.

@JohnDuncanScott JohnDuncanScott added the enhancement New feature or request label Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant