Skip to content

Deliver streamed tokens live instead of after generation completes - #195

Open
james-333i wants to merge 1 commit into
huggingface:mainfrom
james-333i:fix/llama-token-streaming
Open

Deliver streamed tokens live instead of after generation completes#195
james-333i wants to merge 1 commit into
huggingface:mainfrom
james-333i:fix/llama-token-streaming

Conversation

@james-333i

@james-333i james-333i commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

streamResponse ran the whole generation loop before the consuming task received anything, so tokens arrived in one burst at the end. This yields each token as it is sampled.

@mattt

mattt commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

@james-333i This one picked up a conflict after #196 went in as a squash. Would you rebase it onto main? I'll merge as soon as it's green.

streamResponse consumed an inner AsyncThrowingStream whose builder ran
the entire generation loop synchronously on the consuming task, so
every snapshot buffered and arrived in one burst after generation
finished.

Yield snapshots directly from the generation loop on the streaming
task, and check for task cancellation between tokens so an abandoned
stream stops decoding promptly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants