@@ -1112,11 +1112,18 @@ def assert_message_in_logs(log: LogData, event_name: str, expected_content: dict
11121112@pytest .mark .vcr
11131113def test_anthropic_converse_with_caching (instrument_legacy , brt , span_exporter , reader ):
11141114 response_write = brt .converse (
1115- modelId = "anthropic.claude-3-haiku-20240307-v1:0" ,
1116- messages = [{"role" : "user" , "content" : [{"text" : "Hello, this is a test prompt for caching." }]}],
1117- inferenceConfig = {"maxTokens" : 50 },
1118- additionalModelRequestFields = {"cacheControl" : {"type" : "ephemeral" }},
1119- )
1115+ modelId = "anthropic.claude-3-haiku-20240307-v1:0" ,
1116+ messages = [
1117+ {
1118+ "role" : "user" ,
1119+ "content" : [
1120+ {"text" : "Hello, this is a test prompt for caching." },
1121+ {"cachePoint" : {"type" : "ephemeral" }}, # <-- Correct method
1122+ ],
1123+ }
1124+ ],
1125+ inferenceConfig = {"maxTokens" : 50 },
1126+ )
11201127 usage_write = response_write ["usage" ]
11211128 assert usage_write ["cache_read_input_tokens" ] == 0
11221129 assert usage_write ["cache_creation_input_tokens" ] > 0
@@ -1137,14 +1144,14 @@ def test_anthropic_converse_with_caching(instrument_legacy, brt, span_exporter,
11371144 span_write = spans [0 ]
11381145 assert span_write .name == "bedrock.converse"
11391146 attributes_write = span_write .attributes
1140- assert attributes_write [SpanAttributes . LLM_REQUEST_MODEL ] == "claude-3-haiku-20240307-v1:0"
1147+ assert attributes_write [GenAIAttributes . GEN_AI_REQUEST_MODEL ] == "claude-3-haiku-20240307-v1:0"
11411148 assert attributes_write [CacheSpanAttrs .CACHED ] == "write"
11421149 assert attributes_write ["gen_ai.usage.cache_creation_input_tokens" ] == usage_write ["cache_creation_input_tokens" ]
11431150
11441151 span_read = spans [1 ]
11451152 assert span_read .name == "bedrock.converse"
11461153 attributes_read = span_read .attributes
1147- assert attributes_read [SpanAttributes . LLM_REQUEST_MODEL ] == "claude-3-haiku-20240307-v1:0"
1154+ assert attributes_read [GenAIAttributes . GEN_AI_REQUEST_MODEL ] == "claude-3-haiku-20240307-v1:0"
11481155 assert attributes_read [CacheSpanAttrs .CACHED ] == "read"
11491156 assert attributes_read ["gen_ai.usage.cache_read_input_tokens" ] == usage_read ["cache_read_input_tokens" ]
11501157
0 commit comments