-
Notifications
You must be signed in to change notification settings - Fork 4.5k
fix(huggingface): pass prompt as tuple to Thread args instead of a set #13677
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -132,7 +132,7 @@ async def _inner_get_streaming_text_contents( | |
| streamer = TextIteratorStreamer(AutoTokenizer.from_pretrained(self.ai_model_id)) | ||
| # See https://github.com/huggingface/transformers/blob/main/src/transformers/generation/streamers.py#L159 | ||
| thread = Thread( | ||
| target=self.generator, args={prompt}, kwargs=settings.prepare_settings_dict(streamer=streamer) | ||
| target=self.generator, args=(prompt,), kwargs=settings.prepare_settings_dict(streamer=streamer) | ||
| ) | ||
|
Comment on lines
134
to
136
|
||
| thread.start() | ||
|
|
||
|
|
||
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.
PR description states that passing
args={prompt}results in the target being called asgenerator({prompt}), butThreadultimately callsself._target(*self._args, ...)and*-unpacking a set passes its elements, not the set itself (for a single string element it becomesgenerator(prompt)). Consider updating the PR description to reflect the actual failure mode (wrong type and nondeterministic ordering, and potential issues if more args are ever added) so the rationale is technically accurate.