Skip to content

Conversation

@Pouyanpi
Copy link
Collaborator

@Pouyanpi Pouyanpi commented Dec 12, 2025

feature: #1538

Greptile Summary

This PR updates the streaming documentation to reflect recent changes in how streaming works in NeMo Guardrails. The main changes are:

  • Simplified the title from "Global Streaming" to "Streaming"
  • Clarified that stream_async() is the primary method for streaming (rather than requiring YAML configuration first)
  • Added CLI usage instructions with --streaming flag
  • Marked StreamingHandler usage as deprecated in favor of stream_async()
  • Improved guidance on output rails streaming requirements and error handling
  • Enhanced examples and token usage tracking documentation

The documentation correctly explains that StreamingNotSupportedError is raised when output rails are configured without rails.output.streaming.enabled: True. The examples are clear and follow Python best practices.

feature: #1538
Revise streaming docs to clarify usage of stream_async(), remove
outdated global streaming config, and add CLI usage instructions.
Explain output rails streaming requirements and deprecation of
StreamingHandler. Improve examples and guidance for token usage
tracking.
@github-actions
Copy link
Contributor

Documentation preview

https://nvidia-nemo.github.io/Guardrails/review/pr-1542

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 12, 2025

Greptile Overview

Greptile Summary

This PR updates the streaming documentation to reflect recent changes in how streaming works in NeMo Guardrails. The main changes are:

  • Simplified the title from "Global Streaming" to "Streaming"
  • Clarified that stream_async() is the primary method for streaming (rather than requiring YAML configuration first)
  • Added CLI usage instructions with --streaming flag
  • Marked StreamingHandler usage as deprecated in favor of stream_async()
  • Improved guidance on output rails streaming requirements and error handling
  • Enhanced examples and token usage tracking documentation

The documentation correctly explains that InvalidRailsConfigurationError is raised when output rails are configured without rails.output.streaming.enabled: True. The examples are clear and follow Python best practices. One minor consideration: while the docs state "no configuration is required," the global streaming: True config is still used internally for enabling stream_usage on the LLM provider, though this is handled automatically by stream_async().

Confidence Score: 4/5

  • This PR is safe to merge with minimal risk - it's a documentation update that improves clarity
  • Score reflects that this is a documentation-only change with no code modifications. The documentation accurately reflects the API surface and provides correct examples. Minor deduction due to one statement that could be more precise about the global streaming config's role, but this doesn't affect functionality
  • No files require special attention - this is a straightforward documentation improvement

Important Files Changed

File Analysis

Filename Score Overview
docs/configure-rails/yaml-schema/streaming/global-streaming.md 4/5 Documentation refactor removes outdated global streaming config, clarifies usage with stream_async(), adds CLI instructions, and marks StreamingHandler as deprecated

Sequence Diagram

sequenceDiagram
    participant User
    participant LLMRails
    participant StreamingHandler
    participant LLM as LLM Provider
    participant OutputRails as Output Rails

    Note over User,LLM: Basic Streaming Flow (stream_async)
    User->>LLMRails: stream_async(messages)
    LLMRails->>LLMRails: _validate_streaming_with_output_rails()
    LLMRails->>StreamingHandler: Create StreamingHandler
    LLMRails->>LLMRails: generate_async(streaming_handler)
    LLMRails->>LLM: Request with streaming=True, stream_usage=True
    loop For each token
        LLM-->>StreamingHandler: Push token chunk
        StreamingHandler-->>User: Yield token chunk
    end
    LLM-->>LLMRails: Complete with usage stats
    
    Note over User,OutputRails: Streaming with Output Rails
    User->>LLMRails: stream_async(messages) [with output rails configured]
    LLMRails->>LLMRails: Check rails.output.streaming.enabled
    alt Output rails streaming disabled
        LLMRails-->>User: Raise InvalidRailsConfigurationError
    else Output rails streaming enabled
        LLMRails->>StreamingHandler: Create handler
        LLMRails->>LLM: Request streaming
        loop For each token
            LLM-->>StreamingHandler: Push token
            StreamingHandler->>OutputRails: Buffer for output rail check
            OutputRails-->>User: Yield validated token
        end
    end
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@Pouyanpi Pouyanpi self-assigned this Dec 12, 2025
@Pouyanpi Pouyanpi added the documentation Improvements or additions to documentation label Dec 12, 2025
@Pouyanpi Pouyanpi added this to the 0.20.0 milestone Dec 12, 2025
@miyoungc
Copy link
Collaborator

Thank you for starting the PR!

We need to have only config.yml-related content in this chapter. I want to avoid mixing it with the CLI server API/Python API usages. I'll submit a PR to improve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants