File tree Expand file tree Collapse file tree 7 files changed +45
-4
lines changed
src/main/java/com/theokanning/openai Expand file tree Collapse file tree 7 files changed +45
-4
lines changed Original file line number Diff line number Diff line change 66 <parent >
77 <groupId >top.bella</groupId >
88 <artifactId >openai-java</artifactId >
9- <version >0.23.25 </version >
9+ <version >0.23.26 </version >
1010 </parent >
1111 <packaging >jar</packaging >
1212 <artifactId >openai-api</artifactId >
Original file line number Diff line number Diff line change @@ -20,4 +20,14 @@ public class CompletionTokensDetails {
2020
2121 @ JsonProperty ("rejected_prediction_tokens" )
2222 long rejectedPredictionTokens ;
23+
24+ public void add (CompletionTokensDetails details ) {
25+ if (details == null ) {
26+ return ;
27+ }
28+ this .reasoningTokens += details .getReasoningTokens ();
29+ this .audioTokens += details .getAudioTokens ();
30+ this .acceptedPredictionTokens += details .getAcceptedPredictionTokens ();
31+ this .rejectedPredictionTokens += details .getRejectedPredictionTokens ();
32+ }
2333}
Original file line number Diff line number Diff line change @@ -19,4 +19,12 @@ public class PromptTokensDetails {
1919 */
2020 @ JsonProperty ("audio_tokens" )
2121 long audioTokens ;
22+
23+ public void add (PromptTokensDetails details ) {
24+ if (details == null ) {
25+ return ;
26+ }
27+ this .cachedTokens += details .getCachedTokens ();
28+ this .audioTokens += details .getAudioTokens ();
29+ }
2230}
Original file line number Diff line number Diff line change @@ -37,4 +37,27 @@ public class Usage {
3737 */
3838 @ JsonProperty ("completion_tokens_details" )
3939 CompletionTokensDetails completionTokensDetails ;
40+
41+ public void add (Usage usage ) {
42+ if (usage == null ) {
43+ return ;
44+ }
45+ this .promptTokens += usage .getPromptTokens ();
46+ this .completionTokens += usage .getCompletionTokens ();
47+ this .totalTokens += usage .getTotalTokens ();
48+ if (usage .getPromptTokensDetails () != null ) {
49+ if (this .promptTokensDetails == null ) {
50+ this .promptTokensDetails = usage .getPromptTokensDetails ();
51+ } else {
52+ this .promptTokensDetails .add (usage .getPromptTokensDetails ());
53+ }
54+ }
55+ if (usage .getCompletionTokensDetails () != null ) {
56+ if (this .completionTokensDetails == null ) {
57+ this .completionTokensDetails = usage .getCompletionTokensDetails ();
58+ } else {
59+ this .completionTokensDetails .add (usage .getCompletionTokensDetails ());
60+ }
61+ }
62+ }
4063}
Original file line number Diff line number Diff line change 66 <parent >
77 <groupId >top.bella</groupId >
88 <artifactId >openai-java</artifactId >
9- <version >0.23.25 </version >
9+ <version >0.23.26 </version >
1010 </parent >
1111 <packaging >jar</packaging >
1212
Original file line number Diff line number Diff line change 55
66 <groupId >top.bella</groupId >
77 <artifactId >openai-java</artifactId >
8- <version >0.23.25 </version >
8+ <version >0.23.26 </version >
99 <packaging >pom</packaging >
1010 <description >openai java 版本</description >
1111 <name >openai-java</name >
Original file line number Diff line number Diff line change 66 <parent >
77 <groupId >top.bella</groupId >
88 <artifactId >openai-java</artifactId >
9- <version >0.23.25 </version >
9+ <version >0.23.26 </version >
1010 </parent >
1111 <packaging >jar</packaging >
1212
You can’t perform that action at this time.
0 commit comments