Skip to content
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

Backport v0.1 - PR #177 - Fix streaming functionality with Bedrock guardrails (#176) #231

Merged
merged 1 commit into from
Oct 11, 2024

Commits on Oct 10, 2024

  1. Fix streaming functionality with Bedrock guardrails (langchain-ai#176) (

    langchain-ai#177)
    
    This PR addresses an issue where the streaming functionality in
    ChatBedrock breaks when Bedrock guardrails are applied. The problem was
    caused by a KeyError in the `_stream_response_to_generation_chunk`
    method when trying to access the 'stop_sequence' key, which may not
    always be present in the response structure when guardrails are active.
    
    ## Changes
    - Modified the `_stream_response_to_generation_chunk` method in
    `llms/bedrock.py` to use the `get()` method when accessing dictionary
    keys that may not always be present.
    
    
    ## Testing
    - Tested the streaming functionality with and without Bedrock guardrails
    applied.
    - Verified that the streaming works correctly in both scenarios without
    raising KeyErrors.
    ardf committed Oct 10, 2024
    Configuration menu
    Copy the full SHA
    2134873 View commit details
    Browse the repository at this point in the history