Skip to content

Add Support for Simulated Streaming Toggle and Provider Compatibility Checks #209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

tuannvm
Copy link
Contributor

@tuannvm tuannvm commented May 10, 2025

Summary:

This PR introduces configuration options and logic to handle simulated streaming, allowing flexibility when native streaming support is unavailable from certain providers. It adds an environment-aware support check for multiple providers to prevent misconfiguration, ensuring the application only proceeds with simulated streaming when appropriate.

Provider Native Streaming Support Behavior with --enable-simulated-streaming=true (default) Behavior with --enable-simulated-streaming=false
openai No Works with simulated streaming Fails at startup with error message
grok No Works with simulated streaming Fails at startup with error message
gemini Yes Works with native streaming Works with native streaming
ollama No Works with native streaming Fails at startup with error message
llamacpp No Works with native streaming Fails at startup with error message
azopenai No Works with native streaming Fails at startup with error message
unknown Assumed No Works with simulated streaming Fails at startup with error message

When the application starts:

  1. If --enable-simulated-streaming=false, the code checks if the selected provider supports native streaming
  2. If native streaming is not supported, it fails immediately with an error message
  3. If native streaming is supported, it sets environment variables (KUBECTL_AI_REQUIRE_NATIVE_STREAMING=true and provider-specific variables) and continues

This approach ensures that applications that depend on real-time token-by-token streaming for UI updates or early termination can enforce this requirement at startup time.

Affected Modules:

  • cmd/main.go (Options definition, CLI flag binding, environment setup)
  • main logic flow (runtime streaming capability validation)
  • provider support detection (checkNativeStreamingSupport function)

Key Details:

  • Adds a new CLI flag --enable-simulated-streaming with a default value of true.
  • Implements checkNativeStreamingSupport() to determine if a provider natively supports streaming features, with default assumptions.
  • During runtime, if --enable-simulated-streaming=false is specified, the code verifies provider support before proceeding.
  • Ensures users are warned about provider limitations and configuration mismatches, preventing runtime errors.

Potential Impacts:

  • Users can explicitly disable simulated streaming, but only if their provider supports native streaming.
  • Prevents misconfiguration by aborting excessive unsupported setup attempts.
  • Enhances robustness across multiple providers with varying streaming capabilities.
  • Adds flexibility for future providers by expanding support checks in checkNativeStreamingSupport().

Testing Steps:

  • Run with --enable-simulated-streaming=false against providers known to support native streaming (gemini), verify normal operation.
  • Run with --enable-simulated-streaming=false against providers without native streaming support (azopenai, grok, llamacpp, ollama, openai) and confirm proper error handling.
  • Verify default behavior with --enable-simulated-streaming omitted, ensuring it defaults to allowing simulated streaming.
  • Confirm CLI flag parsing correctly sets the configuration and influences runtime validation.
  • Test warning logs for unknown providers to ensure future compatibility.

tuannvm added 2 commits May 10, 2025 09:22
Signed-off-by: Tommy Nguyen <tuannvm@hotmail.com>
Signed-off-by: Tommy Nguyen <tuannvm@hotmail.com>
@tuannvm tuannvm changed the title Feat/streaming toggle Add Support for Simulated Streaming Toggle and Provider Compatibility Checks May 10, 2025
@tuannvm tuannvm marked this pull request as ready for review May 10, 2025 16:37
Signed-off-by: Tommy Nguyen <tuannvm@hotmail.com>
@zvdy
Copy link
Contributor

zvdy commented May 11, 2025

Just realized this was open, perhaps #215 solves what is mentioned here

@droot
Copy link
Member

droot commented May 12, 2025

Just realized this was open, perhaps #215 solves what is mentioned here

I think so too. Awesome to see the progress on the streaming (and auto-detection/fallback).

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.

3 participants