Add real-time SSE streaming for LLM chat responses - #330
Open
yoro1836 wants to merge 1 commit into
Open
Conversation
- Add StreamEvent model (Token, ToolCalls, Finished, Error) and accumulator - Add SseParser for line-by-line SSE reading from Ktor ByteReadChannel - Add OpenAICompatibleStreamParser for OpenAI-compatible SSE chunks - Add AnthropicStreamParser for Anthropic SSE events - Add streamingOpenAICompatibleChat() and streamingAnthropicChat() to Requests - Add stream field to request DTOs - Add streamingChat() to ToolLoopStrategy with batch fallback - Use placeholder History entries updated token-by-token in runToolLoop - Graceful fallback to batch API calls when streaming fails
kilvz
added a commit
to kilvz/Kai-custom
that referenced
this pull request
Jun 14, 2026
…onSchubert#330) - Add StreamEvent model (Token, ToolCalls, Finished, Error) and StreamAccumulator - Add SseParser for line-by-line SSE reading from Ktor ByteReadChannel - Add OpenAICompatibleStreamParser for OpenAI SSE chunks - Add AnthropicStreamParser for Anthropic SSE events - Add streamingOpenAICompatibleChat() and streamingAnthropicChat() to Requests - Add stream field to request DTOs - Add streamingChat() to ToolLoopStrategy with batch fallback - Use placeholder History entries updated token-by-token in runToolLoop - Graceful fallback to batch API calls when streaming fails
kilvz
added a commit
to kilvz/Kai-custom
that referenced
this pull request
Jun 14, 2026
…m PR SimonSchubert#330)" This reverts commit 11387b8.
|
Merge this please @SimonSchubert |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, the app only supports batch text generation, which forces users to wait until the entire response is completed. For longer outputs, this significantly harms the user experience as it feels like the app has frozen.
By implementing real-time SSE streaming, users can see the response token-by-token instantly. I also added a fallback mechanism to the existing batch implementation so that if streaming fails for any reason, it gracefully switches back to batch mode without interrupting the conversation.