@@ -417,7 +417,8 @@ private ChatResponse internalCall(Prompt prompt, ChatResponse previousChatRespon
417
417
Usage currentUsage = (usage .isPresent ()) ? new DefaultUsage (usage .get ().promptTokenCount ().orElse (0 ),
418
418
usage .get ().candidatesTokenCount ().orElse (0 )) : new EmptyUsage ();
419
419
Usage cumulativeUsage = UsageCalculator .getCumulativeUsage (currentUsage , previousChatResponse );
420
- ChatResponse chatResponse = new ChatResponse (generations , toChatResponseMetadata (cumulativeUsage ));
420
+ ChatResponse chatResponse = new ChatResponse (generations ,
421
+ toChatResponseMetadata (cumulativeUsage , generateContentResponse .modelVersion ().get ()));
421
422
422
423
observationContext .setResponse (chatResponse );
423
424
return chatResponse ;
@@ -531,7 +532,8 @@ public Flux<ChatResponse> internalStream(Prompt prompt, ChatResponse previousCha
531
532
var usage = response .usageMetadata ();
532
533
Usage currentUsage = usage .isPresent () ? getDefaultUsage (usage .get ()) : new EmptyUsage ();
533
534
Usage cumulativeUsage = UsageCalculator .getCumulativeUsage (currentUsage , previousChatResponse );
534
- ChatResponse chatResponse = new ChatResponse (generations , toChatResponseMetadata (cumulativeUsage ));
535
+ ChatResponse chatResponse = new ChatResponse (generations ,
536
+ toChatResponseMetadata (cumulativeUsage , response .modelVersion ().get ()));
535
537
return Flux .just (chatResponse );
536
538
});
537
539
@@ -626,8 +628,8 @@ protected List<Generation> responseCandidateToGeneration(Candidate candidate) {
626
628
}
627
629
}
628
630
629
- private ChatResponseMetadata toChatResponseMetadata (Usage usage ) {
630
- return ChatResponseMetadata .builder ().usage (usage ).build ();
631
+ private ChatResponseMetadata toChatResponseMetadata (Usage usage , String modelVersion ) {
632
+ return ChatResponseMetadata .builder ().usage (usage ).model ( modelVersion ). build ();
631
633
}
632
634
633
635
private DefaultUsage getDefaultUsage (com .google .genai .types .GenerateContentResponseUsageMetadata usageMetadata ) {
0 commit comments