Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link

Copilot AI Mar 20, 2026

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 as generator({prompt}), but Thread ultimately calls self._target(*self._args, ...) and *-unpacking a set passes its elements, not the set itself (for a single string element it becomes generator(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.

Copilot uses AI. Check for mistakes.
)
Comment on lines 134 to 136
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

Current unit tests for HuggingFaceTextCompletion streaming patch Thread but do not assert that it is constructed with args=(prompt,). Since this change fixes a subtle calling bug, please add an assertion in the existing streaming unit test to verify the exact Thread(..., args=..., kwargs=...) call so the regression is caught automatically.

Copilot uses AI. Check for mistakes.
thread.start()

Expand Down
Loading