File tree Expand file tree Collapse file tree
instrumentation/opentelemetry-instrumentation-botocore/tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2626from botocore .response import StreamingBody
2727
2828from opentelemetry .instrumentation .botocore .extensions .bedrock_utils import (
29- ConverseStreamWrapper ,
3029 InvokeModelWithResponseStreamWrapper ,
30+ _Choice ,
3131)
3232from opentelemetry .semconv ._incubating .attributes .error_attributes import (
3333 ERROR_TYPE ,
@@ -3053,20 +3053,14 @@ def stream_error_callback(exc, ended):
30533053
30543054
30553055def test_converse_stream_with_missing_output_in_response ():
3056- """Test that converse stream handles malformed response missing output key."""
3056+ # Test malformed response missing "output" key
3057+ malformed_response = {"stopReason" : "end_turn" }
3058+ choice = _Choice .from_converse (malformed_response , capture_content = False )
30573059
3058- def stream_done_callback (response , ended ):
3059- pass
3060-
3061- wrapper = ConverseStreamWrapper (
3062- stream = mock .MagicMock (),
3063- stream_done_callback = stream_done_callback ,
3064- model_id = "amazon.nova-micro-v1:0" ,
3065- )
3060+ assert choice .finish_reason == "end_turn"
3061+ assert choice .message == {}
3062+ assert choice .index == 0
30663063
3067- bedrock_response = {"stopReason" : "end_turn" }
3068- result = wrapper ._complete_stream (bedrock_response )
3069- assert result is None
30703064
30713065def amazon_nova_messages ():
30723066 return [
You can’t perform that action at this time.
0 commit comments