-
Notifications
You must be signed in to change notification settings - Fork 2k
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
feat: Add streaming to HuggingFaceLocalGenerator
#7377
Conversation
streaming_callback
parameter to the HuggingFaceLocalGenerator
HuggingFaceLocalGenerator
Pull Request Test Coverage Report for Build 8375520678Details
💛 - Coveralls |
|
||
|
||
# used to test serialization of streaming_callback | ||
def streaming_callback_handler(x): |
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.
I think it makes more sense to define this inside the test_run_with_streaming(self)
itself, since it's only used there
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.
Good suggestion @davidsbatista - I would but the serialization mechanism doesn't see the namespace of the function IIRC.
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.
Nevermind, it can be done, thanks for the suggestion
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.
just a small suggestions, other than that LGTM
7e9460c
to
12e63ad
Compare
@davidsbatista rebased to latest main, resolved a few conflicts, should be ready to go now, just waiting for green signal from CI |
* Inital streaming impl * Add unit tests * Add release note
Why:
The change introduces a new
streaming_callback
parameter to theHuggingFaceLocalGenerator
class, allowing users to handle streaming responses. This enhancement provides greater flexibility and customization in managing real-time responses from Hugging Face's local models.HuggingFaceLocalGenerator
- streaming/stream handler support #6048What:
Modifies
haystack/components/generators/hugging_face_local.py
:streaming_callback
as an optional parameter to theHuggingFaceLocalGenerator
class.streaming_callback
functionality within therun
method.to_dict
andfrom_dict
methods to serialize and deserialize thestreaming_callback
parameter.Adds
releasenotes/notes/hugging-face-local-generator-streaming-callback-38a77d37199f9672.yaml
to document the new feature.Modifies
test/components/generators/test_hugging_face_local_generator.py
to include tests for thestreaming_callback
parameter.How can it be used:
streaming_callback
when initializing aHuggingFaceLocalGenerator
instance to handle streaming responses:streaming_callback
function to handle streaming responses as desired, for example:How did you test it:
streaming_callback
by creating tests for:run
methodNotes for the reviewer:
streaming_callback
function is compatible with the async context of theHuggingFaceLocalGenerator
'srun
method.streaming_callback
parameter.