From 16bca83e3157104fab0494c231a2e1c142132bd9 Mon Sep 17 00:00:00 2001 From: SAP Cloud SDK Bot Date: Sun, 21 Dec 2025 00:10:39 +0000 Subject: [PATCH 1/2] Update orchestration based on rel-0.110.13 --- .../sdk/orchestration/model/TokenUsage.java | 181 +++++++--- .../TokenUsageCompletionTokensDetails.java | 323 ++++++++++++++++++ .../model/TokenUsagePromptTokensDetails.java | 214 ++++++++++++ .../main/resources/spec/orchestration.yaml | 56 ++- 4 files changed, 717 insertions(+), 57 deletions(-) create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/TokenUsageCompletionTokensDetails.java create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/TokenUsagePromptTokensDetails.java diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/TokenUsage.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/TokenUsage.java index 87af49a97..9cbd7be4d 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/TokenUsage.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/TokenUsage.java @@ -28,15 +28,21 @@ public class TokenUsage // CHECKSTYLE:ON { - @JsonProperty("completion_tokens") - private Integer completionTokens; - @JsonProperty("prompt_tokens") private Integer promptTokens; + @JsonProperty("completion_tokens") + private Integer completionTokens; + @JsonProperty("total_tokens") private Integer totalTokens; + @JsonProperty("prompt_tokens_details") + private TokenUsagePromptTokensDetails promptTokensDetails; + + @JsonProperty("completion_tokens_details") + private TokenUsageCompletionTokensDetails completionTokensDetails; + @JsonAnySetter @JsonAnyGetter private final Map cloudSdkCustomFields = new LinkedHashMap<>(); @@ -44,71 +50,71 @@ public class TokenUsage protected TokenUsage() {} /** - * Set the completionTokens of this {@link TokenUsage} instance and return the same instance. + * Set the promptTokens of this {@link TokenUsage} instance and return the same instance. * - * @param completionTokens Number of tokens used in the input + * @param promptTokens Number of tokens in the prompt. * @return The same instance of this {@link TokenUsage} class */ @Nonnull - public TokenUsage completionTokens(@Nonnull final Integer completionTokens) { - this.completionTokens = completionTokens; + public TokenUsage promptTokens(@Nonnull final Integer promptTokens) { + this.promptTokens = promptTokens; return this; } /** - * Number of tokens used in the input + * Number of tokens in the prompt. * - * @return completionTokens The completionTokens of this {@link TokenUsage} instance. + * @return promptTokens The promptTokens of this {@link TokenUsage} instance. */ @Nonnull - public Integer getCompletionTokens() { - return completionTokens; + public Integer getPromptTokens() { + return promptTokens; } /** - * Set the completionTokens of this {@link TokenUsage} instance. + * Set the promptTokens of this {@link TokenUsage} instance. * - * @param completionTokens Number of tokens used in the input + * @param promptTokens Number of tokens in the prompt. */ - public void setCompletionTokens(@Nonnull final Integer completionTokens) { - this.completionTokens = completionTokens; + public void setPromptTokens(@Nonnull final Integer promptTokens) { + this.promptTokens = promptTokens; } /** - * Set the promptTokens of this {@link TokenUsage} instance and return the same instance. + * Set the completionTokens of this {@link TokenUsage} instance and return the same instance. * - * @param promptTokens Number of tokens used in the output + * @param completionTokens Number of tokens in the generated completion. * @return The same instance of this {@link TokenUsage} class */ @Nonnull - public TokenUsage promptTokens(@Nonnull final Integer promptTokens) { - this.promptTokens = promptTokens; + public TokenUsage completionTokens(@Nonnull final Integer completionTokens) { + this.completionTokens = completionTokens; return this; } /** - * Number of tokens used in the output + * Number of tokens in the generated completion. * - * @return promptTokens The promptTokens of this {@link TokenUsage} instance. + * @return completionTokens The completionTokens of this {@link TokenUsage} instance. */ @Nonnull - public Integer getPromptTokens() { - return promptTokens; + public Integer getCompletionTokens() { + return completionTokens; } /** - * Set the promptTokens of this {@link TokenUsage} instance. + * Set the completionTokens of this {@link TokenUsage} instance. * - * @param promptTokens Number of tokens used in the output + * @param completionTokens Number of tokens in the generated completion. */ - public void setPromptTokens(@Nonnull final Integer promptTokens) { - this.promptTokens = promptTokens; + public void setCompletionTokens(@Nonnull final Integer completionTokens) { + this.completionTokens = completionTokens; } /** * Set the totalTokens of this {@link TokenUsage} instance and return the same instance. * - * @param totalTokens Total number of tokens used + * @param totalTokens Total number of tokens used in the request (prompt + completion). * @return The same instance of this {@link TokenUsage} class */ @Nonnull @@ -118,7 +124,7 @@ public TokenUsage totalTokens(@Nonnull final Integer totalTokens) { } /** - * Total number of tokens used + * Total number of tokens used in the request (prompt + completion). * * @return totalTokens The totalTokens of this {@link TokenUsage} instance. */ @@ -130,12 +136,80 @@ public Integer getTotalTokens() { /** * Set the totalTokens of this {@link TokenUsage} instance. * - * @param totalTokens Total number of tokens used + * @param totalTokens Total number of tokens used in the request (prompt + completion). */ public void setTotalTokens(@Nonnull final Integer totalTokens) { this.totalTokens = totalTokens; } + /** + * Set the promptTokensDetails of this {@link TokenUsage} instance and return the same instance. + * + * @param promptTokensDetails The promptTokensDetails of this {@link TokenUsage} + * @return The same instance of this {@link TokenUsage} class + */ + @Nonnull + public TokenUsage promptTokensDetails( + @Nullable final TokenUsagePromptTokensDetails promptTokensDetails) { + this.promptTokensDetails = promptTokensDetails; + return this; + } + + /** + * Get promptTokensDetails + * + * @return promptTokensDetails The promptTokensDetails of this {@link TokenUsage} instance. + */ + @Nonnull + public TokenUsagePromptTokensDetails getPromptTokensDetails() { + return promptTokensDetails; + } + + /** + * Set the promptTokensDetails of this {@link TokenUsage} instance. + * + * @param promptTokensDetails The promptTokensDetails of this {@link TokenUsage} + */ + public void setPromptTokensDetails( + @Nullable final TokenUsagePromptTokensDetails promptTokensDetails) { + this.promptTokensDetails = promptTokensDetails; + } + + /** + * Set the completionTokensDetails of this {@link TokenUsage} instance and return the same + * instance. + * + * @param completionTokensDetails The completionTokensDetails of this {@link TokenUsage} + * @return The same instance of this {@link TokenUsage} class + */ + @Nonnull + public TokenUsage completionTokensDetails( + @Nullable final TokenUsageCompletionTokensDetails completionTokensDetails) { + this.completionTokensDetails = completionTokensDetails; + return this; + } + + /** + * Get completionTokensDetails + * + * @return completionTokensDetails The completionTokensDetails of this {@link TokenUsage} + * instance. + */ + @Nonnull + public TokenUsageCompletionTokensDetails getCompletionTokensDetails() { + return completionTokensDetails; + } + + /** + * Set the completionTokensDetails of this {@link TokenUsage} instance. + * + * @param completionTokensDetails The completionTokensDetails of this {@link TokenUsage} + */ + public void setCompletionTokensDetails( + @Nullable final TokenUsageCompletionTokensDetails completionTokensDetails) { + this.completionTokensDetails = completionTokensDetails; + } + /** * Get the names of the unrecognizable properties of the {@link TokenUsage}. * @@ -174,9 +248,12 @@ public Object getCustomField(@Nonnull final String name) throws NoSuchElementExc @Nonnull public Map toMap() { final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); - if (completionTokens != null) declaredFields.put("completionTokens", completionTokens); if (promptTokens != null) declaredFields.put("promptTokens", promptTokens); + if (completionTokens != null) declaredFields.put("completionTokens", completionTokens); if (totalTokens != null) declaredFields.put("totalTokens", totalTokens); + if (promptTokensDetails != null) declaredFields.put("promptTokensDetails", promptTokensDetails); + if (completionTokensDetails != null) + declaredFields.put("completionTokensDetails", completionTokensDetails); return declaredFields; } @@ -202,14 +279,22 @@ public boolean equals(@Nullable final java.lang.Object o) { } final TokenUsage tokenUsage = (TokenUsage) o; return Objects.equals(this.cloudSdkCustomFields, tokenUsage.cloudSdkCustomFields) - && Objects.equals(this.completionTokens, tokenUsage.completionTokens) && Objects.equals(this.promptTokens, tokenUsage.promptTokens) - && Objects.equals(this.totalTokens, tokenUsage.totalTokens); + && Objects.equals(this.completionTokens, tokenUsage.completionTokens) + && Objects.equals(this.totalTokens, tokenUsage.totalTokens) + && Objects.equals(this.promptTokensDetails, tokenUsage.promptTokensDetails) + && Objects.equals(this.completionTokensDetails, tokenUsage.completionTokensDetails); } @Override public int hashCode() { - return Objects.hash(completionTokens, promptTokens, totalTokens, cloudSdkCustomFields); + return Objects.hash( + promptTokens, + completionTokens, + totalTokens, + promptTokensDetails, + completionTokensDetails, + cloudSdkCustomFields); } @Override @@ -217,9 +302,15 @@ public int hashCode() { public String toString() { final StringBuilder sb = new StringBuilder(); sb.append("class TokenUsage {\n"); - sb.append(" completionTokens: ").append(toIndentedString(completionTokens)).append("\n"); sb.append(" promptTokens: ").append(toIndentedString(promptTokens)).append("\n"); + sb.append(" completionTokens: ").append(toIndentedString(completionTokens)).append("\n"); sb.append(" totalTokens: ").append(toIndentedString(totalTokens)).append("\n"); + sb.append(" promptTokensDetails: ") + .append(toIndentedString(promptTokensDetails)) + .append("\n"); + sb.append(" completionTokensDetails: ") + .append(toIndentedString(completionTokensDetails)) + .append("\n"); cloudSdkCustomFields.forEach( (k, v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); @@ -242,35 +333,35 @@ private String toIndentedString(final java.lang.Object o) { * with all required arguments. */ public static Builder create() { - return (completionTokens) -> - (promptTokens) -> + return (promptTokens) -> + (completionTokens) -> (totalTokens) -> new TokenUsage() - .completionTokens(completionTokens) .promptTokens(promptTokens) + .completionTokens(completionTokens) .totalTokens(totalTokens); } /** Builder helper class. */ public interface Builder { /** - * Set the completionTokens of this {@link TokenUsage} instance. + * Set the promptTokens of this {@link TokenUsage} instance. * - * @param completionTokens Number of tokens used in the input + * @param promptTokens Number of tokens in the prompt. * @return The TokenUsage builder. */ - Builder1 completionTokens(@Nonnull final Integer completionTokens); + Builder1 promptTokens(@Nonnull final Integer promptTokens); } /** Builder helper class. */ public interface Builder1 { /** - * Set the promptTokens of this {@link TokenUsage} instance. + * Set the completionTokens of this {@link TokenUsage} instance. * - * @param promptTokens Number of tokens used in the output + * @param completionTokens Number of tokens in the generated completion. * @return The TokenUsage builder. */ - Builder2 promptTokens(@Nonnull final Integer promptTokens); + Builder2 completionTokens(@Nonnull final Integer completionTokens); } /** Builder helper class. */ @@ -278,7 +369,7 @@ public interface Builder2 { /** * Set the totalTokens of this {@link TokenUsage} instance. * - * @param totalTokens Total number of tokens used + * @param totalTokens Total number of tokens used in the request (prompt + completion). * @return The TokenUsage instance. */ TokenUsage totalTokens(@Nonnull final Integer totalTokens); diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/TokenUsageCompletionTokensDetails.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/TokenUsageCompletionTokensDetails.java new file mode 100644 index 000000000..333a60ae9 --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/TokenUsageCompletionTokensDetails.java @@ -0,0 +1,323 @@ +/* + * Internal Orchestration Service API + * Orchestration is an inference service which provides common additional capabilities for business AI scenarios, such as content filtering and data masking. At the core of the service is the LLM module which allows for an easy, harmonized access to the language models of gen AI hub. The service is designed to be modular and extensible, allowing for the addition of new modules in the future. Each module can be configured independently and at runtime, allowing for a high degree of flexibility in the orchestration of AI services. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.ai.sdk.orchestration.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** Breakdown of tokens used in a completion. */ +// CHECKSTYLE:OFF +public class TokenUsageCompletionTokensDetails +// CHECKSTYLE:ON +{ + @JsonProperty("accepted_prediction_tokens") + private Integer acceptedPredictionTokens; + + @JsonProperty("audio_tokens") + private Integer audioTokens; + + @JsonProperty("reasoning_tokens") + private Integer reasoningTokens; + + @JsonProperty("rejected_prediction_tokens") + private Integer rejectedPredictionTokens; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for TokenUsageCompletionTokensDetails. */ + protected TokenUsageCompletionTokensDetails() {} + + /** + * Set the acceptedPredictionTokens of this {@link TokenUsageCompletionTokensDetails} instance and + * return the same instance. + * + * @param acceptedPredictionTokens When using Predicted Outputs, the number of tokens in the + * prediction that appeared in the completion. + * @return The same instance of this {@link TokenUsageCompletionTokensDetails} class + */ + @Nonnull + public TokenUsageCompletionTokensDetails acceptedPredictionTokens( + @Nullable final Integer acceptedPredictionTokens) { + this.acceptedPredictionTokens = acceptedPredictionTokens; + return this; + } + + /** + * When using Predicted Outputs, the number of tokens in the prediction that appeared in the + * completion. + * + * @return acceptedPredictionTokens The acceptedPredictionTokens of this {@link + * TokenUsageCompletionTokensDetails} instance. + */ + @Nonnull + public Integer getAcceptedPredictionTokens() { + return acceptedPredictionTokens; + } + + /** + * Set the acceptedPredictionTokens of this {@link TokenUsageCompletionTokensDetails} instance. + * + * @param acceptedPredictionTokens When using Predicted Outputs, the number of tokens in the + * prediction that appeared in the completion. + */ + public void setAcceptedPredictionTokens(@Nullable final Integer acceptedPredictionTokens) { + this.acceptedPredictionTokens = acceptedPredictionTokens; + } + + /** + * Set the audioTokens of this {@link TokenUsageCompletionTokensDetails} instance and return the + * same instance. + * + * @param audioTokens Audio input tokens generated by the model. + * @return The same instance of this {@link TokenUsageCompletionTokensDetails} class + */ + @Nonnull + public TokenUsageCompletionTokensDetails audioTokens(@Nullable final Integer audioTokens) { + this.audioTokens = audioTokens; + return this; + } + + /** + * Audio input tokens generated by the model. + * + * @return audioTokens The audioTokens of this {@link TokenUsageCompletionTokensDetails} instance. + */ + @Nonnull + public Integer getAudioTokens() { + return audioTokens; + } + + /** + * Set the audioTokens of this {@link TokenUsageCompletionTokensDetails} instance. + * + * @param audioTokens Audio input tokens generated by the model. + */ + public void setAudioTokens(@Nullable final Integer audioTokens) { + this.audioTokens = audioTokens; + } + + /** + * Set the reasoningTokens of this {@link TokenUsageCompletionTokensDetails} instance and return + * the same instance. + * + * @param reasoningTokens Tokens generated by the model for reasoning. + * @return The same instance of this {@link TokenUsageCompletionTokensDetails} class + */ + @Nonnull + public TokenUsageCompletionTokensDetails reasoningTokens( + @Nullable final Integer reasoningTokens) { + this.reasoningTokens = reasoningTokens; + return this; + } + + /** + * Tokens generated by the model for reasoning. + * + * @return reasoningTokens The reasoningTokens of this {@link TokenUsageCompletionTokensDetails} + * instance. + */ + @Nonnull + public Integer getReasoningTokens() { + return reasoningTokens; + } + + /** + * Set the reasoningTokens of this {@link TokenUsageCompletionTokensDetails} instance. + * + * @param reasoningTokens Tokens generated by the model for reasoning. + */ + public void setReasoningTokens(@Nullable final Integer reasoningTokens) { + this.reasoningTokens = reasoningTokens; + } + + /** + * Set the rejectedPredictionTokens of this {@link TokenUsageCompletionTokensDetails} instance and + * return the same instance. + * + * @param rejectedPredictionTokens When using Predicted Outputs, the number of tokens in the + * prediction that did not appear in the completion. However, like reasoning tokens, these + * tokens are still counted in the total completion tokens for purposes of billing, output, + * and context window limits. + * @return The same instance of this {@link TokenUsageCompletionTokensDetails} class + */ + @Nonnull + public TokenUsageCompletionTokensDetails rejectedPredictionTokens( + @Nullable final Integer rejectedPredictionTokens) { + this.rejectedPredictionTokens = rejectedPredictionTokens; + return this; + } + + /** + * When using Predicted Outputs, the number of tokens in the prediction that did not appear in the + * completion. However, like reasoning tokens, these tokens are still counted in the total + * completion tokens for purposes of billing, output, and context window limits. + * + * @return rejectedPredictionTokens The rejectedPredictionTokens of this {@link + * TokenUsageCompletionTokensDetails} instance. + */ + @Nonnull + public Integer getRejectedPredictionTokens() { + return rejectedPredictionTokens; + } + + /** + * Set the rejectedPredictionTokens of this {@link TokenUsageCompletionTokensDetails} instance. + * + * @param rejectedPredictionTokens When using Predicted Outputs, the number of tokens in the + * prediction that did not appear in the completion. However, like reasoning tokens, these + * tokens are still counted in the total completion tokens for purposes of billing, output, + * and context window limits. + */ + public void setRejectedPredictionTokens(@Nullable final Integer rejectedPredictionTokens) { + this.rejectedPredictionTokens = rejectedPredictionTokens; + } + + /** + * Get the names of the unrecognizable properties of the {@link + * TokenUsageCompletionTokensDetails}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link TokenUsageCompletionTokensDetails} + * instance. + * + * @deprecated Use {@link #toMap()} instead. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + @Deprecated + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "TokenUsageCompletionTokensDetails has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link TokenUsageCompletionTokensDetails} instance + * including unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (acceptedPredictionTokens != null) + declaredFields.put("acceptedPredictionTokens", acceptedPredictionTokens); + if (audioTokens != null) declaredFields.put("audioTokens", audioTokens); + if (reasoningTokens != null) declaredFields.put("reasoningTokens", reasoningTokens); + if (rejectedPredictionTokens != null) + declaredFields.put("rejectedPredictionTokens", rejectedPredictionTokens); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link TokenUsageCompletionTokensDetails} instance. If + * the map previously contained a mapping for the key, the old value is replaced by the specified + * value. + * + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final TokenUsageCompletionTokensDetails tokenUsageCompletionTokensDetails = + (TokenUsageCompletionTokensDetails) o; + return Objects.equals( + this.cloudSdkCustomFields, tokenUsageCompletionTokensDetails.cloudSdkCustomFields) + && Objects.equals( + this.acceptedPredictionTokens, + tokenUsageCompletionTokensDetails.acceptedPredictionTokens) + && Objects.equals(this.audioTokens, tokenUsageCompletionTokensDetails.audioTokens) + && Objects.equals(this.reasoningTokens, tokenUsageCompletionTokensDetails.reasoningTokens) + && Objects.equals( + this.rejectedPredictionTokens, + tokenUsageCompletionTokensDetails.rejectedPredictionTokens); + } + + @Override + public int hashCode() { + return Objects.hash( + acceptedPredictionTokens, + audioTokens, + reasoningTokens, + rejectedPredictionTokens, + cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class TokenUsageCompletionTokensDetails {\n"); + sb.append(" acceptedPredictionTokens: ") + .append(toIndentedString(acceptedPredictionTokens)) + .append("\n"); + sb.append(" audioTokens: ").append(toIndentedString(audioTokens)).append("\n"); + sb.append(" reasoningTokens: ").append(toIndentedString(reasoningTokens)).append("\n"); + sb.append(" rejectedPredictionTokens: ") + .append(toIndentedString(rejectedPredictionTokens)) + .append("\n"); + cloudSdkCustomFields.forEach( + (k, v) -> + sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** Create a new {@link TokenUsageCompletionTokensDetails} instance. No arguments are required. */ + public static TokenUsageCompletionTokensDetails create() { + return new TokenUsageCompletionTokensDetails(); + } +} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/TokenUsagePromptTokensDetails.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/TokenUsagePromptTokensDetails.java new file mode 100644 index 000000000..66b535d26 --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/TokenUsagePromptTokensDetails.java @@ -0,0 +1,214 @@ +/* + * Internal Orchestration Service API + * Orchestration is an inference service which provides common additional capabilities for business AI scenarios, such as content filtering and data masking. At the core of the service is the LLM module which allows for an easy, harmonized access to the language models of gen AI hub. The service is designed to be modular and extensible, allowing for the addition of new modules in the future. Each module can be configured independently and at runtime, allowing for a high degree of flexibility in the orchestration of AI services. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.ai.sdk.orchestration.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** Details of the prompt tokens. */ +// CHECKSTYLE:OFF +public class TokenUsagePromptTokensDetails +// CHECKSTYLE:ON +{ + @JsonProperty("audio_tokens") + private Integer audioTokens; + + @JsonProperty("cached_tokens") + private Integer cachedTokens; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for TokenUsagePromptTokensDetails. */ + protected TokenUsagePromptTokensDetails() {} + + /** + * Set the audioTokens of this {@link TokenUsagePromptTokensDetails} instance and return the same + * instance. + * + * @param audioTokens Audio input tokens present in the prompt. + * @return The same instance of this {@link TokenUsagePromptTokensDetails} class + */ + @Nonnull + public TokenUsagePromptTokensDetails audioTokens(@Nullable final Integer audioTokens) { + this.audioTokens = audioTokens; + return this; + } + + /** + * Audio input tokens present in the prompt. + * + * @return audioTokens The audioTokens of this {@link TokenUsagePromptTokensDetails} instance. + */ + @Nonnull + public Integer getAudioTokens() { + return audioTokens; + } + + /** + * Set the audioTokens of this {@link TokenUsagePromptTokensDetails} instance. + * + * @param audioTokens Audio input tokens present in the prompt. + */ + public void setAudioTokens(@Nullable final Integer audioTokens) { + this.audioTokens = audioTokens; + } + + /** + * Set the cachedTokens of this {@link TokenUsagePromptTokensDetails} instance and return the same + * instance. + * + * @param cachedTokens Cached tokens present in the prompt. + * @return The same instance of this {@link TokenUsagePromptTokensDetails} class + */ + @Nonnull + public TokenUsagePromptTokensDetails cachedTokens(@Nullable final Integer cachedTokens) { + this.cachedTokens = cachedTokens; + return this; + } + + /** + * Cached tokens present in the prompt. + * + * @return cachedTokens The cachedTokens of this {@link TokenUsagePromptTokensDetails} instance. + */ + @Nonnull + public Integer getCachedTokens() { + return cachedTokens; + } + + /** + * Set the cachedTokens of this {@link TokenUsagePromptTokensDetails} instance. + * + * @param cachedTokens Cached tokens present in the prompt. + */ + public void setCachedTokens(@Nullable final Integer cachedTokens) { + this.cachedTokens = cachedTokens; + } + + /** + * Get the names of the unrecognizable properties of the {@link TokenUsagePromptTokensDetails}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link TokenUsagePromptTokensDetails} + * instance. + * + * @deprecated Use {@link #toMap()} instead. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + @Deprecated + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "TokenUsagePromptTokensDetails has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link TokenUsagePromptTokensDetails} instance + * including unrecognized properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (audioTokens != null) declaredFields.put("audioTokens", audioTokens); + if (cachedTokens != null) declaredFields.put("cachedTokens", cachedTokens); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link TokenUsagePromptTokensDetails} instance. If the + * map previously contained a mapping for the key, the old value is replaced by the specified + * value. + * + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final TokenUsagePromptTokensDetails tokenUsagePromptTokensDetails = + (TokenUsagePromptTokensDetails) o; + return Objects.equals( + this.cloudSdkCustomFields, tokenUsagePromptTokensDetails.cloudSdkCustomFields) + && Objects.equals(this.audioTokens, tokenUsagePromptTokensDetails.audioTokens) + && Objects.equals(this.cachedTokens, tokenUsagePromptTokensDetails.cachedTokens); + } + + @Override + public int hashCode() { + return Objects.hash(audioTokens, cachedTokens, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class TokenUsagePromptTokensDetails {\n"); + sb.append(" audioTokens: ").append(toIndentedString(audioTokens)).append("\n"); + sb.append(" cachedTokens: ").append(toIndentedString(cachedTokens)).append("\n"); + cloudSdkCustomFields.forEach( + (k, v) -> + sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** Create a new {@link TokenUsagePromptTokensDetails} instance. No arguments are required. */ + public static TokenUsagePromptTokensDetails create() { + return new TokenUsagePromptTokensDetails(); + } +} diff --git a/orchestration/src/main/resources/spec/orchestration.yaml b/orchestration/src/main/resources/spec/orchestration.yaml index ed68f259e..ddbaf8000 100644 --- a/orchestration/src/main/resources/spec/orchestration.yaml +++ b/orchestration/src/main/resources/spec/orchestration.yaml @@ -817,26 +817,58 @@ components: finish_reason: type: string description: Reason for stopping the model + + # Copied from the azure openai spec https://github.com/Azure/azure-rest-api-specs/blob/91e3aca0bfa4b59a9f578959d0b214a26b90df40/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2025-02-01-preview/inference.yaml#L4615-L4669 TokenUsage: type: object description: Usage of tokens in the response - required: - - completion_tokens - - prompt_tokens - - total_tokens properties: - completion_tokens: - type: integer - description: Number of tokens used in the input - example: 20 prompt_tokens: type: integer - description: Number of tokens used in the output - example: 30 + description: Number of tokens in the prompt. + completion_tokens: + type: integer + description: Number of tokens in the generated completion. total_tokens: type: integer - description: Total number of tokens used - example: 50 + description: Total number of tokens used in the request (prompt + completion). + prompt_tokens_details: + type: object + description: Details of the prompt tokens. + properties: + audio_tokens: + type: integer + description: Audio input tokens present in the prompt. + cached_tokens: + type: integer + description: Cached tokens present in the prompt. + completion_tokens_details: + type: object + description: Breakdown of tokens used in a completion. + properties: + accepted_prediction_tokens: + type: integer + description: | + When using Predicted Outputs, the number of tokens in the + prediction that appeared in the completion. + audio_tokens: + type: integer + description: Audio input tokens generated by the model. + reasoning_tokens: + type: integer + description: Tokens generated by the model for reasoning. + rejected_prediction_tokens: + type: integer + description: > + When using Predicted Outputs, the number of tokens in the + prediction that did not appear in the completion. However, like + reasoning tokens, these tokens are still counted in the total + completion tokens for purposes of billing, output, and context + window limits. + required: + - prompt_tokens + - completion_tokens + - total_tokens # --- Prompt Templating Module --- PromptTemplatingModuleConfig: From 70182e963c6170c0acd78b83b303b8a5fe6a72a2 Mon Sep 17 00:00:00 2001 From: SAP Cloud SDK Bot Date: Sun, 11 Jan 2026 00:11:05 +0000 Subject: [PATCH 2/2] Update orchestration based on rel-0.110.13 --- .../ai/sdk/orchestration/model/Citation.java | 343 ++++++++++++++++++ .../orchestration/model/LLMModuleResult.java | 64 +++- .../model/LLMModuleResultStreaming.java | 65 +++- .../main/resources/spec/orchestration.yaml | 31 ++ 4 files changed, 499 insertions(+), 4 deletions(-) create mode 100644 orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/Citation.java diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/Citation.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/Citation.java new file mode 100644 index 000000000..e42e572fe --- /dev/null +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/Citation.java @@ -0,0 +1,343 @@ +/* + * Internal Orchestration Service API + * Orchestration is an inference service which provides common additional capabilities for business AI scenarios, such as content filtering and data masking. At the core of the service is the LLM module which allows for an easy, harmonized access to the language models of gen AI hub. The service is designed to be modular and extensible, allowing for the addition of new modules in the future. Each module can be configured independently and at runtime, allowing for a high degree of flexibility in the orchestration of AI services. + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.ai.sdk.orchestration.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** Citation */ +// CHECKSTYLE:OFF +public class Citation +// CHECKSTYLE:ON +{ + @JsonProperty("ref_id") + private Integer refId; + + @JsonProperty("title") + private String title; + + @JsonProperty("url") + private String url; + + @JsonProperty("start_index") + private Integer startIndex; + + @JsonProperty("end_index") + private Integer endIndex; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** Default constructor for Citation. */ + protected Citation() {} + + /** + * Set the refId of this {@link Citation} instance and return the same instance. + * + * @param refId Unique identifier for inline citation + * @return The same instance of this {@link Citation} class + */ + @Nonnull + public Citation refId(@Nullable final Integer refId) { + this.refId = refId; + return this; + } + + /** + * Unique identifier for inline citation + * + * @return refId The refId of this {@link Citation} instance. + */ + @Nonnull + public Integer getRefId() { + return refId; + } + + /** + * Set the refId of this {@link Citation} instance. + * + * @param refId Unique identifier for inline citation + */ + public void setRefId(@Nullable final Integer refId) { + this.refId = refId; + } + + /** + * Set the title of this {@link Citation} instance and return the same instance. + * + * @param title Title of the citation + * @return The same instance of this {@link Citation} class + */ + @Nonnull + public Citation title(@Nonnull final String title) { + this.title = title; + return this; + } + + /** + * Title of the citation + * + * @return title The title of this {@link Citation} instance. + */ + @Nonnull + public String getTitle() { + return title; + } + + /** + * Set the title of this {@link Citation} instance. + * + * @param title Title of the citation + */ + public void setTitle(@Nonnull final String title) { + this.title = title; + } + + /** + * Set the url of this {@link Citation} instance and return the same instance. + * + * @param url URL of the citation + * @return The same instance of this {@link Citation} class + */ + @Nonnull + public Citation url(@Nonnull final String url) { + this.url = url; + return this; + } + + /** + * URL of the citation + * + * @return url The url of this {@link Citation} instance. + */ + @Nonnull + public String getUrl() { + return url; + } + + /** + * Set the url of this {@link Citation} instance. + * + * @param url URL of the citation + */ + public void setUrl(@Nonnull final String url) { + this.url = url; + } + + /** + * Set the startIndex of this {@link Citation} instance and return the same instance. + * + * @param startIndex Start index of the citation in the response text + * @return The same instance of this {@link Citation} class + */ + @Nonnull + public Citation startIndex(@Nullable final Integer startIndex) { + this.startIndex = startIndex; + return this; + } + + /** + * Start index of the citation in the response text + * + * @return startIndex The startIndex of this {@link Citation} instance. + */ + @Nonnull + public Integer getStartIndex() { + return startIndex; + } + + /** + * Set the startIndex of this {@link Citation} instance. + * + * @param startIndex Start index of the citation in the response text + */ + public void setStartIndex(@Nullable final Integer startIndex) { + this.startIndex = startIndex; + } + + /** + * Set the endIndex of this {@link Citation} instance and return the same instance. + * + * @param endIndex End index of the citation in the response text + * @return The same instance of this {@link Citation} class + */ + @Nonnull + public Citation endIndex(@Nullable final Integer endIndex) { + this.endIndex = endIndex; + return this; + } + + /** + * End index of the citation in the response text + * + * @return endIndex The endIndex of this {@link Citation} instance. + */ + @Nonnull + public Integer getEndIndex() { + return endIndex; + } + + /** + * Set the endIndex of this {@link Citation} instance. + * + * @param endIndex End index of the citation in the response text + */ + public void setEndIndex(@Nullable final Integer endIndex) { + this.endIndex = endIndex; + } + + /** + * Get the names of the unrecognizable properties of the {@link Citation}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link Citation} instance. + * + * @deprecated Use {@link #toMap()} instead. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + @Deprecated + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException("Citation has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Get the value of all properties of this {@link Citation} instance including unrecognized + * properties. + * + * @return The map of all properties + */ + @JsonIgnore + @Nonnull + public Map toMap() { + final Map declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); + if (refId != null) declaredFields.put("refId", refId); + if (title != null) declaredFields.put("title", title); + if (url != null) declaredFields.put("url", url); + if (startIndex != null) declaredFields.put("startIndex", startIndex); + if (endIndex != null) declaredFields.put("endIndex", endIndex); + return declaredFields; + } + + /** + * Set an unrecognizable property of this {@link Citation} instance. If the map previously + * contained a mapping for the key, the old value is replaced by the specified value. + * + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final Citation citation = (Citation) o; + return Objects.equals(this.cloudSdkCustomFields, citation.cloudSdkCustomFields) + && Objects.equals(this.refId, citation.refId) + && Objects.equals(this.title, citation.title) + && Objects.equals(this.url, citation.url) + && Objects.equals(this.startIndex, citation.startIndex) + && Objects.equals(this.endIndex, citation.endIndex); + } + + @Override + public int hashCode() { + return Objects.hash(refId, title, url, startIndex, endIndex, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class Citation {\n"); + sb.append(" refId: ").append(toIndentedString(refId)).append("\n"); + sb.append(" title: ").append(toIndentedString(title)).append("\n"); + sb.append(" url: ").append(toIndentedString(url)).append("\n"); + sb.append(" startIndex: ").append(toIndentedString(startIndex)).append("\n"); + sb.append(" endIndex: ").append(toIndentedString(endIndex)).append("\n"); + cloudSdkCustomFields.forEach( + (k, v) -> + sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Create a type-safe, fluent-api builder object to construct a new {@link Citation} instance with + * all required arguments. + */ + public static Builder create() { + return (title) -> (url) -> new Citation().title(title).url(url); + } + + /** Builder helper class. */ + public interface Builder { + /** + * Set the title of this {@link Citation} instance. + * + * @param title Title of the citation + * @return The Citation builder. + */ + Builder1 title(@Nonnull final String title); + } + + /** Builder helper class. */ + public interface Builder1 { + /** + * Set the url of this {@link Citation} instance. + * + * @param url URL of the citation + * @return The Citation instance. + */ + Citation url(@Nonnull final String url); + } +} diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMModuleResult.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMModuleResult.java index 957aae9ad..03bd2e213 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMModuleResult.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMModuleResult.java @@ -52,6 +52,9 @@ public class LLMModuleResult @JsonProperty("usage") private TokenUsage usage; + @JsonProperty("citations") + private List citations = new ArrayList<>(); + @JsonAnySetter @JsonAnyGetter private final Map cloudSdkCustomFields = new LinkedHashMap<>(); @@ -291,6 +294,52 @@ public void setUsage(@Nonnull final TokenUsage usage) { this.usage = usage; } + /** + * Set the citations of this {@link LLMModuleResult} instance and return the same instance. + * + * @param citations List of citations associated with the response. + * @return The same instance of this {@link LLMModuleResult} class + */ + @Nonnull + public LLMModuleResult citations(@Nullable final List citations) { + this.citations = citations; + return this; + } + + /** + * Add one citations instance to this {@link LLMModuleResult}. + * + * @param citationsItem The citations that should be added + * @return The same instance of type {@link LLMModuleResult} + */ + @Nonnull + public LLMModuleResult addCitationsItem(@Nonnull final Citation citationsItem) { + if (this.citations == null) { + this.citations = new ArrayList<>(); + } + this.citations.add(citationsItem); + return this; + } + + /** + * List of citations associated with the response. + * + * @return citations The citations of this {@link LLMModuleResult} instance. + */ + @Nonnull + public List getCitations() { + return citations; + } + + /** + * Set the citations of this {@link LLMModuleResult} instance. + * + * @param citations List of citations associated with the response. + */ + public void setCitations(@Nullable final List citations) { + this.citations = citations; + } + /** * Get the names of the unrecognizable properties of the {@link LLMModuleResult}. * @@ -336,6 +385,7 @@ public Map toMap() { if (systemFingerprint != null) declaredFields.put("systemFingerprint", systemFingerprint); if (choices != null) declaredFields.put("choices", choices); if (usage != null) declaredFields.put("usage", usage); + if (citations != null) declaredFields.put("citations", citations); return declaredFields; } @@ -367,13 +417,22 @@ public boolean equals(@Nullable final java.lang.Object o) { && Objects.equals(this.model, llMModuleResult.model) && Objects.equals(this.systemFingerprint, llMModuleResult.systemFingerprint) && Objects.equals(this.choices, llMModuleResult.choices) - && Objects.equals(this.usage, llMModuleResult.usage); + && Objects.equals(this.usage, llMModuleResult.usage) + && Objects.equals(this.citations, llMModuleResult.citations); } @Override public int hashCode() { return Objects.hash( - id, _object, created, model, systemFingerprint, choices, usage, cloudSdkCustomFields); + id, + _object, + created, + model, + systemFingerprint, + choices, + usage, + citations, + cloudSdkCustomFields); } @Override @@ -388,6 +447,7 @@ public String toString() { sb.append(" systemFingerprint: ").append(toIndentedString(systemFingerprint)).append("\n"); sb.append(" choices: ").append(toIndentedString(choices)).append("\n"); sb.append(" usage: ").append(toIndentedString(usage)).append("\n"); + sb.append(" citations: ").append(toIndentedString(citations)).append("\n"); cloudSdkCustomFields.forEach( (k, v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); diff --git a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMModuleResultStreaming.java b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMModuleResultStreaming.java index 394a8d3b1..2b429b300 100644 --- a/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMModuleResultStreaming.java +++ b/orchestration/src/main/java/com/sap/ai/sdk/orchestration/model/LLMModuleResultStreaming.java @@ -52,6 +52,9 @@ public class LLMModuleResultStreaming @JsonProperty("usage") private TokenUsage usage; + @JsonProperty("citations") + private List citations = new ArrayList<>(); + @JsonAnySetter @JsonAnyGetter private final Map cloudSdkCustomFields = new LinkedHashMap<>(); @@ -292,6 +295,53 @@ public void setUsage(@Nullable final TokenUsage usage) { this.usage = usage; } + /** + * Set the citations of this {@link LLMModuleResultStreaming} instance and return the same + * instance. + * + * @param citations List of citations associated with the response. + * @return The same instance of this {@link LLMModuleResultStreaming} class + */ + @Nonnull + public LLMModuleResultStreaming citations(@Nullable final List citations) { + this.citations = citations; + return this; + } + + /** + * Add one citations instance to this {@link LLMModuleResultStreaming}. + * + * @param citationsItem The citations that should be added + * @return The same instance of type {@link LLMModuleResultStreaming} + */ + @Nonnull + public LLMModuleResultStreaming addCitationsItem(@Nonnull final Citation citationsItem) { + if (this.citations == null) { + this.citations = new ArrayList<>(); + } + this.citations.add(citationsItem); + return this; + } + + /** + * List of citations associated with the response. + * + * @return citations The citations of this {@link LLMModuleResultStreaming} instance. + */ + @Nonnull + public List getCitations() { + return citations; + } + + /** + * Set the citations of this {@link LLMModuleResultStreaming} instance. + * + * @param citations List of citations associated with the response. + */ + public void setCitations(@Nullable final List citations) { + this.citations = citations; + } + /** * Get the names of the unrecognizable properties of the {@link LLMModuleResultStreaming}. * @@ -338,6 +388,7 @@ public Map toMap() { if (systemFingerprint != null) declaredFields.put("systemFingerprint", systemFingerprint); if (choices != null) declaredFields.put("choices", choices); if (usage != null) declaredFields.put("usage", usage); + if (citations != null) declaredFields.put("citations", citations); return declaredFields; } @@ -369,13 +420,22 @@ public boolean equals(@Nullable final java.lang.Object o) { && Objects.equals(this.model, llMModuleResultStreaming.model) && Objects.equals(this.systemFingerprint, llMModuleResultStreaming.systemFingerprint) && Objects.equals(this.choices, llMModuleResultStreaming.choices) - && Objects.equals(this.usage, llMModuleResultStreaming.usage); + && Objects.equals(this.usage, llMModuleResultStreaming.usage) + && Objects.equals(this.citations, llMModuleResultStreaming.citations); } @Override public int hashCode() { return Objects.hash( - id, _object, created, model, systemFingerprint, choices, usage, cloudSdkCustomFields); + id, + _object, + created, + model, + systemFingerprint, + choices, + usage, + citations, + cloudSdkCustomFields); } @Override @@ -390,6 +450,7 @@ public String toString() { sb.append(" systemFingerprint: ").append(toIndentedString(systemFingerprint)).append("\n"); sb.append(" choices: ").append(toIndentedString(choices)).append("\n"); sb.append(" usage: ").append(toIndentedString(usage)).append("\n"); + sb.append(" citations: ").append(toIndentedString(citations)).append("\n"); cloudSdkCustomFields.forEach( (k, v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); diff --git a/orchestration/src/main/resources/spec/orchestration.yaml b/orchestration/src/main/resources/spec/orchestration.yaml index ddbaf8000..b1263c1d5 100644 --- a/orchestration/src/main/resources/spec/orchestration.yaml +++ b/orchestration/src/main/resources/spec/orchestration.yaml @@ -750,6 +750,11 @@ components: $ref: "#/components/schemas/LLMChoice" usage: $ref: "#/components/schemas/TokenUsage" + citations: + type: array + description: List of citations associated with the response. + items: + $ref: "#/components/schemas/Citation" LLMModuleResultStreaming: type: object description: Output of LLM module. Follows the OpenAI spec. @@ -782,6 +787,32 @@ components: $ref: "#/components/schemas/LLMChoiceStreaming" usage: $ref: "#/components/schemas/TokenUsage" + citations: + type: array + description: List of citations associated with the response. + items: + $ref: "#/components/schemas/Citation" + Citation: + type: object + required: + - title + - url + properties: + ref_id: + type: integer + description: Unique identifier for inline citation + title: + type: string + description: Title of the citation + url: + type: string + description: URL of the citation + start_index: + type: integer + description: Start index of the citation in the response text + end_index: + type: integer + description: End index of the citation in the response text LLMChoice: type: object required: