Skip to content

Conversation

@Iamsdt
Copy link
Collaborator

@Iamsdt Iamsdt commented Nov 29, 2025

This pull request introduces improvements to streaming responses in the graph API by ensuring that streaming endpoints bypass GZip compression and are properly configured for event streaming. It also updates the streaming service to yield newline-delimited JSON strings for easier client consumption and simulates network delay in the mock weather service for more realistic behavior.

Streaming response improvements:

  • Added SelectiveGZipMiddleware in setup_middleware.py to exclude streaming endpoints (e.g., /v1/graph/stream) from GZip compression, ensuring immediate data transmission without buffering. [1] [2]
  • Updated the streaming endpoint in router.py to use media_type="text/event-stream", set headers to prevent unwanted transformations and buffering, and explicitly disabled content encoding to bypass GZip.

Streaming service changes:

  • Changed the return type of stream_graph in graph_service.py to yield newline-delimited JSON strings instead of Content objects, making streaming output easier to parse on the client side. [1] [2] [3] [4]

Testing and simulation:

  • Added a simulated network delay (sleep(1)) to the mock weather response in react.py for more realistic testing. [1] [2]

…nts from compression

fix: Update media type and headers for StreamingResponse in graph router
refactor: Change return type of graph streaming method to AsyncIterable[str] and ensure newline delimiters
chore: Simulate network delay in weather response function
@Iamsdt Iamsdt merged commit 612f52b into main Nov 29, 2025
1 check passed
@Iamsdt Iamsdt deleted the fix/streaming branch November 29, 2025 16:14
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