@@ -55,6 +55,11 @@ def test_converse(
5555 client .converse (
5656 modelId = "anthropic.claude-3-sonnet-20240229-v1:0" ,
5757 messages = [{"role" : "user" , "content" : [{"text" : "Hi" }]}],
58+ inferenceConfig = {
59+ "maxTokens" : 256 ,
60+ "temperature" : 0.7 ,
61+ "topP" : 0.9 ,
62+ },
5863 )
5964
6065 sentry_sdk .flush ()
@@ -68,13 +73,22 @@ def test_converse(
6873 assert span ["attributes" ][SPANDATA .GEN_AI_PROVIDER_NAME ] == "aws.bedrock"
6974 assert span ["attributes" ][SPANDATA .GEN_AI_OPERATION_NAME ] == "chat"
7075 assert span ["attributes" ][SPANDATA .GEN_AI_RESPONSE_STREAMING ] is False
76+
77+ assert span ["attributes" ][SPANDATA .GEN_AI_REQUEST_MAX_TOKENS ] == 256
78+ assert span ["attributes" ][SPANDATA .GEN_AI_REQUEST_TEMPERATURE ] == 0.7
79+ assert span ["attributes" ][SPANDATA .GEN_AI_REQUEST_TOP_P ] == 0.9
7180 else :
7281 events = capture_events ()
7382
7483 with stubber , sentry_sdk .start_transaction (name = "parent" ):
7584 client .converse (
7685 modelId = "anthropic.claude-3-sonnet-20240229-v1:0" ,
7786 messages = [{"role" : "user" , "content" : [{"text" : "Hi" }]}],
87+ inferenceConfig = {
88+ "maxTokens" : 256 ,
89+ "temperature" : 0.7 ,
90+ "topP" : 0.9 ,
91+ },
7892 )
7993
8094 (transaction ,) = events
@@ -84,6 +98,10 @@ def test_converse(
8498 assert span ["data" ][SPANDATA .GEN_AI_OPERATION_NAME ] == "chat"
8599 assert span ["data" ][SPANDATA .GEN_AI_RESPONSE_STREAMING ] is False
86100
101+ assert span ["data" ][SPANDATA .GEN_AI_REQUEST_MAX_TOKENS ] == 256
102+ assert span ["data" ][SPANDATA .GEN_AI_REQUEST_TEMPERATURE ] == 0.7
103+ assert span ["data" ][SPANDATA .GEN_AI_REQUEST_TOP_P ] == 0.9
104+
87105
88106@pytest .mark .parametrize ("span_streaming" , [True , False ])
89107@pytest .mark .parametrize ("stream_gen_ai_spans" , [True , False ])
@@ -193,6 +211,11 @@ def test_converse_stream(
193211 client .converse_stream (
194212 modelId = "anthropic.claude-3-sonnet-20240229-v1:0" ,
195213 messages = [{"role" : "user" , "content" : [{"text" : "Hi" }]}],
214+ inferenceConfig = {
215+ "maxTokens" : 256 ,
216+ "temperature" : 0.7 ,
217+ "topP" : 0.9 ,
218+ },
196219 )
197220
198221 sentry_sdk .flush ()
@@ -206,13 +229,22 @@ def test_converse_stream(
206229 assert span ["attributes" ][SPANDATA .GEN_AI_PROVIDER_NAME ] == "aws.bedrock"
207230 assert span ["attributes" ][SPANDATA .GEN_AI_OPERATION_NAME ] == "chat"
208231 assert span ["attributes" ][SPANDATA .GEN_AI_RESPONSE_STREAMING ] is True
232+
233+ assert span ["attributes" ][SPANDATA .GEN_AI_REQUEST_MAX_TOKENS ] == 256
234+ assert span ["attributes" ][SPANDATA .GEN_AI_REQUEST_TEMPERATURE ] == 0.7
235+ assert span ["attributes" ][SPANDATA .GEN_AI_REQUEST_TOP_P ] == 0.9
209236 else :
210237 events = capture_events ()
211238
212239 with stubber , sentry_sdk .start_transaction (name = "parent" ):
213240 client .converse_stream (
214241 modelId = "anthropic.claude-3-sonnet-20240229-v1:0" ,
215242 messages = [{"role" : "user" , "content" : [{"text" : "Hi" }]}],
243+ inferenceConfig = {
244+ "maxTokens" : 256 ,
245+ "temperature" : 0.7 ,
246+ "topP" : 0.9 ,
247+ },
216248 )
217249
218250 (transaction ,) = events
@@ -222,6 +254,10 @@ def test_converse_stream(
222254 assert span ["data" ][SPANDATA .GEN_AI_OPERATION_NAME ] == "chat"
223255 assert span ["data" ][SPANDATA .GEN_AI_RESPONSE_STREAMING ] is True
224256
257+ assert span ["data" ][SPANDATA .GEN_AI_REQUEST_MAX_TOKENS ] == 256
258+ assert span ["data" ][SPANDATA .GEN_AI_REQUEST_TEMPERATURE ] == 0.7
259+ assert span ["data" ][SPANDATA .GEN_AI_REQUEST_TOP_P ] == 0.9
260+
225261
226262@pytest .mark .parametrize ("span_streaming" , [True , False ])
227263@pytest .mark .parametrize ("stream_gen_ai_spans" , [True , False ])
0 commit comments