Skip to content

feat: add streaming response support#50

Open
Isaccseven wants to merge 1 commit into
langflow-ai:mainfrom
Isaccseven:feat/streaming-responses
Open

feat: add streaming response support#50
Isaccseven wants to merge 1 commit into
langflow-ai:mainfrom
Isaccseven:feat/streaming-responses

Conversation

@Isaccseven
Copy link
Copy Markdown

Summary

  • Add token-by-token streaming display when stream="true" prop is set
  • Consume Langflow's existing SSE streaming API (POST /api/v1/run/{flow_id}?stream=true)
  • Bot messages render progressively instead of appearing all at once after completion
  • Backward-compatible: defaults to false, existing behavior unchanged when omitted

Changes

  • New: src/controllers/streamMessage.ts — streaming controller using fetch + ReadableStream with SSE parsing, AbortSignal support, and stream completion safety fallback
  • Modified: src/index.tsx — register stream: "boolean" web component prop
  • Modified: src/chatWidget/index.tsx — pass stream prop through to ChatWindow
  • Modified: src/chatWidget/chatWindow/index.tsx — streaming branch in handleClick() with requestAnimationFrame batched token updates, AbortController cleanup on unmount, placeholder hidden during streaming

Usage

<langflow-chat
  host_url="https://my-langflow.com"
  flow_id="abc-123"
  stream="true"
/>

Test plan

  • Verify stream="true" causes bot messages to render token-by-token
  • Verify omitting stream prop preserves existing non-streaming behavior
  • Verify input is disabled during streaming
  • Verify mid-stream errors preserve partial text with error styling
  • Verify session ID continuity across streamed messages
  • Verify closing widget during stream doesn't leak connections

Closes #44

Add token-by-token streaming display when `stream="true"` prop is set,
consuming Langflow's existing SSE streaming API. Bot messages now render
progressively instead of appearing all at once after completion.

Closes langflow-ai#44
@Isaccseven
Copy link
Copy Markdown
Author

Ready for review

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.

Support streaming responses

1 participant