@@ -75,8 +75,7 @@ pub fn build_message_response(
7575 model : String ,
7676 content : Vec < ContentBlock > ,
7777 stop_reason : Option < String > ,
78- input_tokens : u32 ,
79- output_tokens : u32 ,
78+ usage : Usage ,
8079) -> CreateMessageResponse {
8180 CreateMessageResponse {
8281 _id : id,
@@ -85,12 +84,7 @@ pub fn build_message_response(
8584 content,
8685 _model : model,
8786 stop_reason,
88- usage : Usage {
89- input_tokens,
90- output_tokens,
91- cache_read_input_tokens : None ,
92- cache_creation_input_tokens : None ,
93- } ,
87+ usage,
9488 }
9589}
9690
@@ -601,8 +595,12 @@ mod tests {
601595 "test-model" . into ( ) ,
602596 vec ! [ ] ,
603597 Some ( "max_tokens" . into ( ) ) ,
604- 100 ,
605- 50 ,
598+ Usage {
599+ input_tokens : 100 ,
600+ output_tokens : 50 ,
601+ cache_read_input_tokens : Some ( 40 ) ,
602+ cache_creation_input_tokens : Some ( 10 ) ,
603+ } ,
606604 ) ;
607605 assert_eq ! ( r. _id, "id-42" ) ;
608606 assert_eq ! ( r. _model, "test-model" ) ;
@@ -611,6 +609,8 @@ mod tests {
611609 assert_eq ! ( r. stop_reason. as_deref( ) , Some ( "max_tokens" ) ) ;
612610 assert_eq ! ( r. usage. input_tokens, 100 ) ;
613611 assert_eq ! ( r. usage. output_tokens, 50 ) ;
612+ assert_eq ! ( r. usage. cache_read_input_tokens, Some ( 40 ) ) ;
613+ assert_eq ! ( r. usage. cache_creation_input_tokens, Some ( 10 ) ) ;
614614 assert ! ( r. content. is_empty( ) ) ;
615615 }
616616
0 commit comments