diff --git a/.pipeline/checkstyle-suppressions.xml b/.pipeline/checkstyle-suppressions.xml index b30fd0568..01c0e6f64 100644 --- a/.pipeline/checkstyle-suppressions.xml +++ b/.pipeline/checkstyle-suppressions.xml @@ -8,7 +8,10 @@ + + + diff --git a/foundation-models/openai/pom.xml b/foundation-models/openai/pom.xml index db4bf0f6d..cd54dd009 100644 --- a/foundation-models/openai/pom.xml +++ b/foundation-models/openai/pom.xml @@ -33,12 +33,12 @@ ${project.basedir}/../../ - 71% - 80% - 76% - 69% - 83% - 84% + 32% + 42% + 42% + 16% + 48% + 40% diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/JacksonMixins.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/JacksonMixins.java new file mode 100644 index 000000000..8ea4da339 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/JacksonMixins.java @@ -0,0 +1,31 @@ +package com.sap.ai.sdk.foundationmodels.openai; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.sap.ai.sdk.foundationmodels.openai.model2.CreateChatCompletionResponse; +import com.sap.ai.sdk.foundationmodels.openai.model2.CreateChatCompletionStreamResponse; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; + +@NoArgsConstructor(access = AccessLevel.PRIVATE) +final class JacksonMixins { + + @JsonTypeInfo(use = JsonTypeInfo.Id.NONE) + interface CreateChatCompletionStreamResponseMixIn {} + + @JsonTypeInfo(use = JsonTypeInfo.Id.NONE) + interface CreateChatCompletionResponseMixIn {} + + @JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + property = "object", + defaultImpl = CreateChatCompletionResponse.class, + visible = true) + @JsonSubTypes({ + @JsonSubTypes.Type(value = CreateChatCompletionResponse.class, name = "chat.completion"), + @JsonSubTypes.Type( + value = CreateChatCompletionStreamResponse.class, + name = "chat.completion.chunk"), + }) + public interface ChatCompletionCreate200ResponseMixIn {} +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiChatCompletionDelta.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiChatCompletionDelta.java new file mode 100644 index 000000000..dbcbfb83e --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiChatCompletionDelta.java @@ -0,0 +1,91 @@ +package com.sap.ai.sdk.foundationmodels.openai; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.annotations.Beta; +import com.sap.ai.sdk.core.common.StreamedDelta; +import com.sap.ai.sdk.foundationmodels.openai.model2.ChatCompletionsCreate200Response; +import com.sap.ai.sdk.foundationmodels.openai.model2.CompletionUsage; +import com.sap.ai.sdk.foundationmodels.openai.model2.CreateChatCompletionResponse; +import com.sap.ai.sdk.foundationmodels.openai.model2.CreateChatCompletionStreamResponse; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import lombok.RequiredArgsConstructor; +import lombok.Value; + +/** + * OpenAI chat completion output delta for streaming. + * + * @since 1.3.0 + */ +@Beta +@Value +@RequiredArgsConstructor(onConstructor_ = @JsonCreator) +public class OpenAiChatCompletionDelta implements StreamedDelta { + ChatCompletionsCreate200Response originalResponse; + + @Nonnull + @Override + public String getDeltaContent() { + if (getOriginalResponse() instanceof CreateChatCompletionStreamResponse response) { + final var choices = response.getChoices(); + if (!choices.isEmpty() && choices.get(0).getIndex() == 0) { + final var message = choices.get(0).getDelta(); + if (message != null) { + return Objects.requireNonNullElse(message.getContent(), ""); + } + } + } + if (getOriginalResponse() instanceof CreateChatCompletionResponse response) { + final var choices = response.getChoices(); + if (!choices.isEmpty() && choices.get(0).getIndex() == 0) { + final var delta = choices.get(0).getCustomField("delta"); // .getMessage() does not work + if (delta instanceof String message) { + return message; + } + } + } + return ""; + } + + @Nullable + @Override + public String getFinishReason() { + if (getOriginalResponse() instanceof CreateChatCompletionStreamResponse response) { + final var choices = response.getChoices(); + if (!choices.isEmpty()) { + final var finishReason = choices.get(0).getFinishReason(); + return finishReason != null ? finishReason.getValue() : null; + } + } + if (getOriginalResponse() instanceof CreateChatCompletionResponse response) { + final var choices = response.getChoices(); + if (!choices.isEmpty()) { + final var finishReason = choices.get(0).getFinishReason(); + return finishReason != null ? finishReason.getValue() : null; + } + } + return null; + } + + /** + * Get the completion usage from the response, or null if it is not available. + * + * @param objectMapper The object mapper to use for conversion. + * @return The completion usage or null. + */ + @Nullable + public CompletionUsage getCompletionUsage(@Nonnull final ObjectMapper objectMapper) { + if (getOriginalResponse() instanceof CreateChatCompletionStreamResponse response + && response.getCustomFieldNames().contains("usage") + && response.getCustomField("usage") instanceof Map usage) { + return objectMapper.convertValue(usage, CompletionUsage.class); + } + if (getOriginalResponse() instanceof CreateChatCompletionResponse response) { + return response.getUsage(); + } + return null; + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiClient.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiClient.java index 8699201a7..ee4e5bcb9 100644 --- a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiClient.java +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiClient.java @@ -10,14 +10,18 @@ import com.sap.ai.sdk.core.common.ClientResponseHandler; import com.sap.ai.sdk.core.common.ClientStreamingHandler; import com.sap.ai.sdk.core.common.StreamedDelta; -import com.sap.ai.sdk.foundationmodels.openai.model.OpenAiChatCompletionDelta; -import com.sap.ai.sdk.foundationmodels.openai.model.OpenAiChatCompletionOutput; -import com.sap.ai.sdk.foundationmodels.openai.model.OpenAiChatCompletionParameters; -import com.sap.ai.sdk.foundationmodels.openai.model.OpenAiChatMessage.OpenAiChatSystemMessage; -import com.sap.ai.sdk.foundationmodels.openai.model.OpenAiChatMessage.OpenAiChatUserMessage; -import com.sap.ai.sdk.foundationmodels.openai.model.OpenAiEmbeddingOutput; -import com.sap.ai.sdk.foundationmodels.openai.model.OpenAiEmbeddingParameters; import com.sap.ai.sdk.foundationmodels.openai.model.OpenAiError; +import com.sap.ai.sdk.foundationmodels.openai.model2.ChatCompletionRequestSystemMessage; +import com.sap.ai.sdk.foundationmodels.openai.model2.ChatCompletionRequestSystemMessageContent; +import com.sap.ai.sdk.foundationmodels.openai.model2.ChatCompletionRequestUserMessage; +import com.sap.ai.sdk.foundationmodels.openai.model2.ChatCompletionRequestUserMessageContent; +import com.sap.ai.sdk.foundationmodels.openai.model2.ChatCompletionStreamOptions; +import com.sap.ai.sdk.foundationmodels.openai.model2.ChatCompletionsCreate200Response; +import com.sap.ai.sdk.foundationmodels.openai.model2.CreateChatCompletionRequest; +import com.sap.ai.sdk.foundationmodels.openai.model2.CreateChatCompletionResponse; +import com.sap.ai.sdk.foundationmodels.openai.model2.CreateChatCompletionStreamResponse; +import com.sap.ai.sdk.foundationmodels.openai.model2.EmbeddingsCreate200Response; +import com.sap.ai.sdk.foundationmodels.openai.model2.EmbeddingsCreateRequest; import com.sap.cloud.sdk.cloudplatform.connectivity.ApacheHttpClient5Accessor; import com.sap.cloud.sdk.cloudplatform.connectivity.DefaultHttpDestination; import com.sap.cloud.sdk.cloudplatform.connectivity.Destination; @@ -126,13 +130,24 @@ public OpenAiClient withSystemPrompt(@Nonnull final String systemPrompt) { * @throws OpenAiClientException if the request fails */ @Nonnull - public OpenAiChatCompletionOutput chatCompletion(@Nonnull final String prompt) + public CreateChatCompletionResponse chatCompletion(@Nonnull final String prompt) throws OpenAiClientException { - final OpenAiChatCompletionParameters parameters = new OpenAiChatCompletionParameters(); + final CreateChatCompletionRequest parameters = new CreateChatCompletionRequest(); + if (systemPrompt != null) { - parameters.addMessages(new OpenAiChatSystemMessage().setContent(systemPrompt)); + parameters.addMessagesItem( + new ChatCompletionRequestSystemMessage() + .role(ChatCompletionRequestSystemMessage.RoleEnum.SYSTEM) + .content(ChatCompletionRequestSystemMessageContent.create(systemPrompt))); } - parameters.addMessages(new OpenAiChatUserMessage().addText(prompt)); + parameters + .addMessagesItem( + new ChatCompletionRequestUserMessage() + .role(ChatCompletionRequestUserMessage.RoleEnum.USER) + .content(ChatCompletionRequestUserMessageContent.create(prompt))) + .functions(null) + .tools(null) + .parallelToolCalls(null); return chatCompletion(parameters); } @@ -144,16 +159,16 @@ public OpenAiChatCompletionOutput chatCompletion(@Nonnull final String prompt) * @throws OpenAiClientException if the request fails */ @Nonnull - public OpenAiChatCompletionOutput chatCompletion( - @Nonnull final OpenAiChatCompletionParameters parameters) throws OpenAiClientException { + public CreateChatCompletionResponse chatCompletion( + @Nonnull final CreateChatCompletionRequest parameters) throws OpenAiClientException { warnIfUnsupportedUsage(); - return execute("/chat/completions", parameters, OpenAiChatCompletionOutput.class); + return execute("/chat/completions", parameters, CreateChatCompletionResponse.class); } /** * Stream a completion for the given prompt. Returns a lazily populated stream of text * chunks. To access more details about the individual chunks, use {@link - * #streamChatCompletionDeltas(OpenAiChatCompletionParameters)}. + * #streamChatCompletionDeltas(CreateChatCompletionRequest)}. * *

The stream should be consumed using a try-with-resources block to ensure that the underlying * HTTP connection is closed. @@ -173,22 +188,33 @@ public OpenAiChatCompletionOutput chatCompletion( * @param prompt a text message. * @return A stream of message deltas * @throws OpenAiClientException if the request fails or if the finish reason is content_filter - * @see #streamChatCompletionDeltas(OpenAiChatCompletionParameters) + * @see #streamChatCompletionDeltas(CreateChatCompletionRequest) */ @Nonnull public Stream streamChatCompletion(@Nonnull final String prompt) throws OpenAiClientException { - final OpenAiChatCompletionParameters parameters = new OpenAiChatCompletionParameters(); + final CreateChatCompletionRequest parameters = new CreateChatCompletionRequest(); + if (systemPrompt != null) { - parameters.addMessages(new OpenAiChatSystemMessage().setContent(systemPrompt)); + parameters.addMessagesItem( + new ChatCompletionRequestSystemMessage() + .role(ChatCompletionRequestSystemMessage.RoleEnum.SYSTEM) + .content(ChatCompletionRequestSystemMessageContent.create(systemPrompt))); } - parameters.addMessages(new OpenAiChatUserMessage().addText(prompt)); + final var userMessage = + new ChatCompletionRequestUserMessage() + .role(ChatCompletionRequestUserMessage.RoleEnum.USER) + .content(ChatCompletionRequestUserMessageContent.create(prompt)); + parameters.addMessagesItem(userMessage).tools(null).functions(null).parallelToolCalls(null); + return streamChatCompletionDeltas(parameters) + .map(OpenAiChatCompletionDelta.class::cast) .peek(OpenAiClient::throwOnContentFilter) .map(OpenAiChatCompletionDelta::getDeltaContent); } - private static void throwOnContentFilter(@Nonnull final OpenAiChatCompletionDelta delta) { + private static void throwOnContentFilter( + @Nonnull final com.sap.ai.sdk.foundationmodels.openai.OpenAiChatCompletionDelta delta) { final String finishReason = delta.getFinishReason(); if (finishReason != null && finishReason.equals("content_filter")) { throw new OpenAiClientException("Content filter filtered the output."); @@ -224,9 +250,9 @@ private static void throwOnContentFilter(@Nonnull final OpenAiChatCompletionDelt */ @Nonnull public Stream streamChatCompletionDeltas( - @Nonnull final OpenAiChatCompletionParameters parameters) throws OpenAiClientException { + @Nonnull final CreateChatCompletionRequest parameters) throws OpenAiClientException { warnIfUnsupportedUsage(); - parameters.enableStreaming(); + parameters.stream(true).streamOptions(new ChatCompletionStreamOptions().includeUsage(true)); return executeStream("/chat/completions", parameters, OpenAiChatCompletionDelta.class); } @@ -246,9 +272,9 @@ private void warnIfUnsupportedUsage() { * @throws OpenAiClientException if the request fails */ @Nonnull - public OpenAiEmbeddingOutput embedding(@Nonnull final OpenAiEmbeddingParameters parameters) + public EmbeddingsCreate200Response embedding(@Nonnull final EmbeddingsCreateRequest parameters) throws OpenAiClientException { - return execute("/embeddings", parameters, OpenAiEmbeddingOutput.class); + return execute("/embeddings", parameters, EmbeddingsCreate200Response.class); } @Nonnull @@ -300,6 +326,17 @@ private Stream streamRequest( try { final var client = ApacheHttpClient5Accessor.getHttpClient(destination); return new ClientStreamingHandler<>(deltaType, OpenAiError.class, OpenAiClientException::new) + .objectMapper( + JACKSON + .addMixIn( + CreateChatCompletionResponse.class, + JacksonMixins.CreateChatCompletionResponseMixIn.class) + .addMixIn( + CreateChatCompletionStreamResponse.class, + JacksonMixins.CreateChatCompletionStreamResponseMixIn.class) + .addMixIn( + ChatCompletionsCreate200Response.class, + JacksonMixins.ChatCompletionCreate200ResponseMixIn.class)) .handleStreamingResponse(client.executeOpen(null, request, null)); } catch (final IOException e) { throw new OpenAiClientException("Request to OpenAI model failed", e); diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionFunctionCall.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionFunctionCall.java new file mode 100644 index 000000000..aece7d25c --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionFunctionCall.java @@ -0,0 +1,202 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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; + +/** + * Deprecated and replaced by `tool_calls`. The name and arguments of a function that + * should be called, as generated by the model. + */ +// CHECKSTYLE:OFF +public class ChatCompletionFunctionCall +// CHECKSTYLE:ON +{ + @JsonProperty("name") + private String name; + + @JsonProperty("arguments") + private String arguments; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the name of this {@link ChatCompletionFunctionCall} instance and return the same instance. + * + * @param name The name of the function to call. + * @return The same instance of this {@link ChatCompletionFunctionCall} class + */ + @Nonnull + public ChatCompletionFunctionCall name(@Nonnull final String name) { + this.name = name; + return this; + } + + /** + * The name of the function to call. + * + * @return name The name of this {@link ChatCompletionFunctionCall} instance. + */ + @Nonnull + public String getName() { + return name; + } + + /** + * Set the name of this {@link ChatCompletionFunctionCall} instance. + * + * @param name The name of the function to call. + */ + public void setName(@Nonnull final String name) { + this.name = name; + } + + /** + * Set the arguments of this {@link ChatCompletionFunctionCall} instance and return the same + * instance. + * + * @param arguments The arguments to call the function with, as generated by the model in JSON + * format. Note that the model does not always generate valid JSON, and may hallucinate + * parameters not defined by your function schema. Validate the arguments in your code before + * calling your function. + * @return The same instance of this {@link ChatCompletionFunctionCall} class + */ + @Nonnull + public ChatCompletionFunctionCall arguments(@Nonnull final String arguments) { + this.arguments = arguments; + return this; + } + + /** + * The arguments to call the function with, as generated by the model in JSON format. Note that + * the model does not always generate valid JSON, and may hallucinate parameters not defined by + * your function schema. Validate the arguments in your code before calling your function. + * + * @return arguments The arguments of this {@link ChatCompletionFunctionCall} instance. + */ + @Nonnull + public String getArguments() { + return arguments; + } + + /** + * Set the arguments of this {@link ChatCompletionFunctionCall} instance. + * + * @param arguments The arguments to call the function with, as generated by the model in JSON + * format. Note that the model does not always generate valid JSON, and may hallucinate + * parameters not defined by your function schema. Validate the arguments in your code before + * calling your function. + */ + public void setArguments(@Nonnull final String arguments) { + this.arguments = arguments; + } + + /** + * Get the names of the unrecognizable properties of the {@link ChatCompletionFunctionCall}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ChatCompletionFunctionCall} + * instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ChatCompletionFunctionCall has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ChatCompletionFunctionCall} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ChatCompletionFunctionCall chatCompletionFunctionCall = (ChatCompletionFunctionCall) o; + return Objects.equals( + this.cloudSdkCustomFields, chatCompletionFunctionCall.cloudSdkCustomFields) + && Objects.equals(this.name, chatCompletionFunctionCall.name) + && Objects.equals(this.arguments, chatCompletionFunctionCall.arguments); + } + + @Override + public int hashCode() { + return Objects.hash(name, arguments, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ChatCompletionFunctionCall {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" arguments: ").append(toIndentedString(arguments)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionFunctionCallOption.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionFunctionCallOption.java new file mode 100644 index 000000000..33ccebfad --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionFunctionCallOption.java @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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; + +/** + * Specifying a particular function via `{\"name\": \"my_function\"}` + * forces the model to call that function. + */ +// CHECKSTYLE:OFF +public class ChatCompletionFunctionCallOption +// CHECKSTYLE:ON +{ + @JsonProperty("name") + private String name; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the name of this {@link ChatCompletionFunctionCallOption} instance and return the same + * instance. + * + * @param name The name of the function to call. + * @return The same instance of this {@link ChatCompletionFunctionCallOption} class + */ + @Nonnull + public ChatCompletionFunctionCallOption name(@Nonnull final String name) { + this.name = name; + return this; + } + + /** + * The name of the function to call. + * + * @return name The name of this {@link ChatCompletionFunctionCallOption} instance. + */ + @Nonnull + public String getName() { + return name; + } + + /** + * Set the name of this {@link ChatCompletionFunctionCallOption} instance. + * + * @param name The name of the function to call. + */ + public void setName(@Nonnull final String name) { + this.name = name; + } + + /** + * Get the names of the unrecognizable properties of the {@link ChatCompletionFunctionCallOption}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ChatCompletionFunctionCallOption} + * instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ChatCompletionFunctionCallOption has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ChatCompletionFunctionCallOption} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ChatCompletionFunctionCallOption chatCompletionFunctionCallOption = + (ChatCompletionFunctionCallOption) o; + return Objects.equals( + this.cloudSdkCustomFields, chatCompletionFunctionCallOption.cloudSdkCustomFields) + && Objects.equals(this.name, chatCompletionFunctionCallOption.name); + } + + @Override + public int hashCode() { + return Objects.hash(name, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ChatCompletionFunctionCallOption {\n"); + sb.append(" name: ").append(toIndentedString(name)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionFunctions.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionFunctions.java new file mode 100644 index 000000000..bbdef32c8 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionFunctions.java @@ -0,0 +1,269 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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.HashMap; +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; + +/** + * ChatCompletionFunctions + * + * @deprecated + */ +@Deprecated +// CHECKSTYLE:OFF +public class ChatCompletionFunctions +// CHECKSTYLE:ON +{ + @JsonProperty("description") + private String description; + + @JsonProperty("name") + private String name; + + @JsonProperty("parameters") + private Map parameters = new HashMap<>(); + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the description of this {@link ChatCompletionFunctions} instance and return the same + * instance. + * + * @param description A description of what the function does, used by the model to choose when + * and how to call the function. + * @return The same instance of this {@link ChatCompletionFunctions} class + */ + @Nonnull + public ChatCompletionFunctions description(@Nullable final String description) { + this.description = description; + return this; + } + + /** + * A description of what the function does, used by the model to choose when and how to call the + * function. + * + * @return description The description of this {@link ChatCompletionFunctions} instance. + */ + @Nonnull + public String getDescription() { + return description; + } + + /** + * Set the description of this {@link ChatCompletionFunctions} instance. + * + * @param description A description of what the function does, used by the model to choose when + * and how to call the function. + */ + public void setDescription(@Nullable final String description) { + this.description = description; + } + + /** + * Set the name of this {@link ChatCompletionFunctions} instance and return the same instance. + * + * @param name The name of the function to be called. Must be a-z, A-Z, 0-9, or contain + * underscores and dashes, with a maximum length of 64. + * @return The same instance of this {@link ChatCompletionFunctions} class + */ + @Nonnull + public ChatCompletionFunctions name(@Nonnull final String name) { + this.name = name; + return this; + } + + /** + * The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and + * dashes, with a maximum length of 64. + * + * @return name The name of this {@link ChatCompletionFunctions} instance. + */ + @Nonnull + public String getName() { + return name; + } + + /** + * Set the name of this {@link ChatCompletionFunctions} instance. + * + * @param name The name of the function to be called. Must be a-z, A-Z, 0-9, or contain + * underscores and dashes, with a maximum length of 64. + */ + public void setName(@Nonnull final String name) { + this.name = name; + } + + /** + * Set the parameters of this {@link ChatCompletionFunctions} instance and return the same + * instance. + * + * @param parameters The parameters the functions accepts, described as a JSON Schema object. See + * the + * guide](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/function-calling) + * for examples, and the [JSON Schema + * reference](https://json-schema.org/understanding-json-schema/) for documentation about the + * format. Omitting `parameters` defines a function with an empty parameter list. + * @return The same instance of this {@link ChatCompletionFunctions} class + */ + @Nonnull + public ChatCompletionFunctions parameters(@Nullable final Map parameters) { + this.parameters = parameters; + return this; + } + + /** + * Put one parameters instance to this {@link ChatCompletionFunctions} instance. + * + * @param key The String key of this parameters instance + * @param parametersItem The parameters that should be added under the given key + * @return The same instance of type {@link ChatCompletionFunctions} + */ + @Nonnull + public ChatCompletionFunctions putparametersItem( + @Nonnull final String key, @Nullable final Object parametersItem) { + if (this.parameters == null) { + this.parameters = new HashMap<>(); + } + this.parameters.put(key, parametersItem); + return this; + } + + /** + * The parameters the functions accepts, described as a JSON Schema object. See the + * guide](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/function-calling) for + * examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) + * for documentation about the format. Omitting `parameters` defines a function with an + * empty parameter list. + * + * @return parameters The parameters of this {@link ChatCompletionFunctions} instance. + */ + @Nonnull + public Map getParameters() { + return parameters; + } + + /** + * Set the parameters of this {@link ChatCompletionFunctions} instance. + * + * @param parameters The parameters the functions accepts, described as a JSON Schema object. See + * the + * guide](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/function-calling) + * for examples, and the [JSON Schema + * reference](https://json-schema.org/understanding-json-schema/) for documentation about the + * format. Omitting `parameters` defines a function with an empty parameter list. + */ + public void setParameters(@Nullable final Map parameters) { + this.parameters = parameters; + } + + /** + * Get the names of the unrecognizable properties of the {@link ChatCompletionFunctions}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ChatCompletionFunctions} instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ChatCompletionFunctions has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ChatCompletionFunctions} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ChatCompletionFunctions chatCompletionFunctions = (ChatCompletionFunctions) o; + return Objects.equals(this.cloudSdkCustomFields, chatCompletionFunctions.cloudSdkCustomFields) + && Objects.equals(this.description, chatCompletionFunctions.description) + && Objects.equals(this.name, chatCompletionFunctions.name) + && Objects.equals(this.parameters, chatCompletionFunctions.parameters); + } + + @Override + public int hashCode() { + return Objects.hash(description, name, parameters, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ChatCompletionFunctions {\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" parameters: ").append(toIndentedString(parameters)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionMessageToolCall.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionMessageToolCall.java new file mode 100644 index 000000000..bb73cef44 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionMessageToolCall.java @@ -0,0 +1,231 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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; + +/** ChatCompletionMessageToolCall */ +// CHECKSTYLE:OFF +public class ChatCompletionMessageToolCall +// CHECKSTYLE:ON +{ + @JsonProperty("id") + private String id; + + @JsonProperty("type") + private ToolCallType type; + + @JsonProperty("function") + private ChatCompletionMessageToolCallFunction function; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the id of this {@link ChatCompletionMessageToolCall} instance and return the same instance. + * + * @param id The ID of the tool call. + * @return The same instance of this {@link ChatCompletionMessageToolCall} class + */ + @Nonnull + public ChatCompletionMessageToolCall id(@Nonnull final String id) { + this.id = id; + return this; + } + + /** + * The ID of the tool call. + * + * @return id The id of this {@link ChatCompletionMessageToolCall} instance. + */ + @Nonnull + public String getId() { + return id; + } + + /** + * Set the id of this {@link ChatCompletionMessageToolCall} instance. + * + * @param id The ID of the tool call. + */ + public void setId(@Nonnull final String id) { + this.id = id; + } + + /** + * Set the type of this {@link ChatCompletionMessageToolCall} instance and return the same + * instance. + * + * @param type The type of this {@link ChatCompletionMessageToolCall} + * @return The same instance of this {@link ChatCompletionMessageToolCall} class + */ + @Nonnull + public ChatCompletionMessageToolCall type(@Nonnull final ToolCallType type) { + this.type = type; + return this; + } + + /** + * Get type + * + * @return type The type of this {@link ChatCompletionMessageToolCall} instance. + */ + @Nonnull + public ToolCallType getType() { + return type; + } + + /** + * Set the type of this {@link ChatCompletionMessageToolCall} instance. + * + * @param type The type of this {@link ChatCompletionMessageToolCall} + */ + public void setType(@Nonnull final ToolCallType type) { + this.type = type; + } + + /** + * Set the function of this {@link ChatCompletionMessageToolCall} instance and return the same + * instance. + * + * @param function The function of this {@link ChatCompletionMessageToolCall} + * @return The same instance of this {@link ChatCompletionMessageToolCall} class + */ + @Nonnull + public ChatCompletionMessageToolCall function( + @Nonnull final ChatCompletionMessageToolCallFunction function) { + this.function = function; + return this; + } + + /** + * Get function + * + * @return function The function of this {@link ChatCompletionMessageToolCall} instance. + */ + @Nonnull + public ChatCompletionMessageToolCallFunction getFunction() { + return function; + } + + /** + * Set the function of this {@link ChatCompletionMessageToolCall} instance. + * + * @param function The function of this {@link ChatCompletionMessageToolCall} + */ + public void setFunction(@Nonnull final ChatCompletionMessageToolCallFunction function) { + this.function = function; + } + + /** + * Get the names of the unrecognizable properties of the {@link ChatCompletionMessageToolCall}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ChatCompletionMessageToolCall} + * instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ChatCompletionMessageToolCall has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ChatCompletionMessageToolCall} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ChatCompletionMessageToolCall chatCompletionMessageToolCall = + (ChatCompletionMessageToolCall) o; + return Objects.equals( + this.cloudSdkCustomFields, chatCompletionMessageToolCall.cloudSdkCustomFields) + && Objects.equals(this.id, chatCompletionMessageToolCall.id) + && Objects.equals(this.type, chatCompletionMessageToolCall.type) + && Objects.equals(this.function, chatCompletionMessageToolCall.function); + } + + @Override + public int hashCode() { + return Objects.hash(id, type, function, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ChatCompletionMessageToolCall {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" function: ").append(toIndentedString(function)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionMessageToolCallChunk.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionMessageToolCallChunk.java new file mode 100644 index 000000000..b69611cd1 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionMessageToolCallChunk.java @@ -0,0 +1,323 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +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; + +/** ChatCompletionMessageToolCallChunk */ +// CHECKSTYLE:OFF +public class ChatCompletionMessageToolCallChunk +// CHECKSTYLE:ON +{ + @JsonProperty("index") + private Integer index; + + @JsonProperty("id") + private String id; + + /** The type of the tool. Currently, only `function` is supported. */ + public enum TypeEnum { + /** The FUNCTION option of this ChatCompletionMessageToolCallChunk */ + FUNCTION("function"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value The String value + * @return The enum value of type ChatCompletionMessageToolCallChunk + */ + @JsonCreator + @Nonnull + public static TypeEnum fromValue(@Nonnull final String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("type") + private TypeEnum type; + + @JsonProperty("function") + private ChatCompletionMessageToolCallChunkFunction function; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the index of this {@link ChatCompletionMessageToolCallChunk} instance and return the same + * instance. + * + * @param index The index of this {@link ChatCompletionMessageToolCallChunk} + * @return The same instance of this {@link ChatCompletionMessageToolCallChunk} class + */ + @Nonnull + public ChatCompletionMessageToolCallChunk index(@Nonnull final Integer index) { + this.index = index; + return this; + } + + /** + * Get index + * + * @return index The index of this {@link ChatCompletionMessageToolCallChunk} instance. + */ + @Nonnull + public Integer getIndex() { + return index; + } + + /** + * Set the index of this {@link ChatCompletionMessageToolCallChunk} instance. + * + * @param index The index of this {@link ChatCompletionMessageToolCallChunk} + */ + public void setIndex(@Nonnull final Integer index) { + this.index = index; + } + + /** + * Set the id of this {@link ChatCompletionMessageToolCallChunk} instance and return the same + * instance. + * + * @param id The ID of the tool call. + * @return The same instance of this {@link ChatCompletionMessageToolCallChunk} class + */ + @Nonnull + public ChatCompletionMessageToolCallChunk id(@Nullable final String id) { + this.id = id; + return this; + } + + /** + * The ID of the tool call. + * + * @return id The id of this {@link ChatCompletionMessageToolCallChunk} instance. + */ + @Nonnull + public String getId() { + return id; + } + + /** + * Set the id of this {@link ChatCompletionMessageToolCallChunk} instance. + * + * @param id The ID of the tool call. + */ + public void setId(@Nullable final String id) { + this.id = id; + } + + /** + * Set the type of this {@link ChatCompletionMessageToolCallChunk} instance and return the same + * instance. + * + * @param type The type of the tool. Currently, only `function` is supported. + * @return The same instance of this {@link ChatCompletionMessageToolCallChunk} class + */ + @Nonnull + public ChatCompletionMessageToolCallChunk type(@Nullable final TypeEnum type) { + this.type = type; + return this; + } + + /** + * The type of the tool. Currently, only `function` is supported. + * + * @return type The type of this {@link ChatCompletionMessageToolCallChunk} instance. + */ + @Nonnull + public TypeEnum getType() { + return type; + } + + /** + * Set the type of this {@link ChatCompletionMessageToolCallChunk} instance. + * + * @param type The type of the tool. Currently, only `function` is supported. + */ + public void setType(@Nullable final TypeEnum type) { + this.type = type; + } + + /** + * Set the function of this {@link ChatCompletionMessageToolCallChunk} instance and return the + * same instance. + * + * @param function The function of this {@link ChatCompletionMessageToolCallChunk} + * @return The same instance of this {@link ChatCompletionMessageToolCallChunk} class + */ + @Nonnull + public ChatCompletionMessageToolCallChunk function( + @Nullable final ChatCompletionMessageToolCallChunkFunction function) { + this.function = function; + return this; + } + + /** + * Get function + * + * @return function The function of this {@link ChatCompletionMessageToolCallChunk} instance. + */ + @Nonnull + public ChatCompletionMessageToolCallChunkFunction getFunction() { + return function; + } + + /** + * Set the function of this {@link ChatCompletionMessageToolCallChunk} instance. + * + * @param function The function of this {@link ChatCompletionMessageToolCallChunk} + */ + public void setFunction(@Nullable final ChatCompletionMessageToolCallChunkFunction function) { + this.function = function; + } + + /** + * Get the names of the unrecognizable properties of the {@link + * ChatCompletionMessageToolCallChunk}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ChatCompletionMessageToolCallChunk} + * instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ChatCompletionMessageToolCallChunk has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ChatCompletionMessageToolCallChunk} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ChatCompletionMessageToolCallChunk chatCompletionMessageToolCallChunk = + (ChatCompletionMessageToolCallChunk) o; + return Objects.equals( + this.cloudSdkCustomFields, chatCompletionMessageToolCallChunk.cloudSdkCustomFields) + && Objects.equals(this.index, chatCompletionMessageToolCallChunk.index) + && Objects.equals(this.id, chatCompletionMessageToolCallChunk.id) + && Objects.equals(this.type, chatCompletionMessageToolCallChunk.type) + && Objects.equals(this.function, chatCompletionMessageToolCallChunk.function); + } + + @Override + public int hashCode() { + return Objects.hash(index, id, type, function, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ChatCompletionMessageToolCallChunk {\n"); + sb.append(" index: ").append(toIndentedString(index)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" function: ").append(toIndentedString(function)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionMessageToolCallChunkFunction.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionMessageToolCallChunkFunction.java new file mode 100644 index 000000000..328b5223a --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionMessageToolCallChunkFunction.java @@ -0,0 +1,205 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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; + +/** ChatCompletionMessageToolCallChunkFunction */ +// CHECKSTYLE:OFF +public class ChatCompletionMessageToolCallChunkFunction +// CHECKSTYLE:ON +{ + @JsonProperty("name") + private String name; + + @JsonProperty("arguments") + private String arguments; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the name of this {@link ChatCompletionMessageToolCallChunkFunction} instance and return the + * same instance. + * + * @param name The name of the function to call. + * @return The same instance of this {@link ChatCompletionMessageToolCallChunkFunction} class + */ + @Nonnull + public ChatCompletionMessageToolCallChunkFunction name(@Nullable final String name) { + this.name = name; + return this; + } + + /** + * The name of the function to call. + * + * @return name The name of this {@link ChatCompletionMessageToolCallChunkFunction} instance. + */ + @Nonnull + public String getName() { + return name; + } + + /** + * Set the name of this {@link ChatCompletionMessageToolCallChunkFunction} instance. + * + * @param name The name of the function to call. + */ + public void setName(@Nullable final String name) { + this.name = name; + } + + /** + * Set the arguments of this {@link ChatCompletionMessageToolCallChunkFunction} instance and + * return the same instance. + * + * @param arguments The arguments to call the function with, as generated by the model in JSON + * format. Note that the model does not always generate valid JSON, and may hallucinate + * parameters not defined by your function schema. Validate the arguments in your code before + * calling your function. + * @return The same instance of this {@link ChatCompletionMessageToolCallChunkFunction} class + */ + @Nonnull + public ChatCompletionMessageToolCallChunkFunction arguments(@Nullable final String arguments) { + this.arguments = arguments; + return this; + } + + /** + * The arguments to call the function with, as generated by the model in JSON format. Note that + * the model does not always generate valid JSON, and may hallucinate parameters not defined by + * your function schema. Validate the arguments in your code before calling your function. + * + * @return arguments The arguments of this {@link ChatCompletionMessageToolCallChunkFunction} + * instance. + */ + @Nonnull + public String getArguments() { + return arguments; + } + + /** + * Set the arguments of this {@link ChatCompletionMessageToolCallChunkFunction} instance. + * + * @param arguments The arguments to call the function with, as generated by the model in JSON + * format. Note that the model does not always generate valid JSON, and may hallucinate + * parameters not defined by your function schema. Validate the arguments in your code before + * calling your function. + */ + public void setArguments(@Nullable final String arguments) { + this.arguments = arguments; + } + + /** + * Get the names of the unrecognizable properties of the {@link + * ChatCompletionMessageToolCallChunkFunction}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link + * ChatCompletionMessageToolCallChunkFunction} instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ChatCompletionMessageToolCallChunkFunction has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ChatCompletionMessageToolCallChunkFunction} + * 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ChatCompletionMessageToolCallChunkFunction chatCompletionMessageToolCallChunkFunction = + (ChatCompletionMessageToolCallChunkFunction) o; + return Objects.equals( + this.cloudSdkCustomFields, + chatCompletionMessageToolCallChunkFunction.cloudSdkCustomFields) + && Objects.equals(this.name, chatCompletionMessageToolCallChunkFunction.name) + && Objects.equals(this.arguments, chatCompletionMessageToolCallChunkFunction.arguments); + } + + @Override + public int hashCode() { + return Objects.hash(name, arguments, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ChatCompletionMessageToolCallChunkFunction {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" arguments: ").append(toIndentedString(arguments)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionMessageToolCallFunction.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionMessageToolCallFunction.java new file mode 100644 index 000000000..27e5b5097 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionMessageToolCallFunction.java @@ -0,0 +1,203 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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; + +/** The function that the model called. */ +// CHECKSTYLE:OFF +public class ChatCompletionMessageToolCallFunction +// CHECKSTYLE:ON +{ + @JsonProperty("name") + private String name; + + @JsonProperty("arguments") + private String arguments; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the name of this {@link ChatCompletionMessageToolCallFunction} instance and return the same + * instance. + * + * @param name The name of the function to call. + * @return The same instance of this {@link ChatCompletionMessageToolCallFunction} class + */ + @Nonnull + public ChatCompletionMessageToolCallFunction name(@Nonnull final String name) { + this.name = name; + return this; + } + + /** + * The name of the function to call. + * + * @return name The name of this {@link ChatCompletionMessageToolCallFunction} instance. + */ + @Nonnull + public String getName() { + return name; + } + + /** + * Set the name of this {@link ChatCompletionMessageToolCallFunction} instance. + * + * @param name The name of the function to call. + */ + public void setName(@Nonnull final String name) { + this.name = name; + } + + /** + * Set the arguments of this {@link ChatCompletionMessageToolCallFunction} instance and return the + * same instance. + * + * @param arguments The arguments to call the function with, as generated by the model in JSON + * format. Note that the model does not always generate valid JSON, and may hallucinate + * parameters not defined by your function schema. Validate the arguments in your code before + * calling your function. + * @return The same instance of this {@link ChatCompletionMessageToolCallFunction} class + */ + @Nonnull + public ChatCompletionMessageToolCallFunction arguments(@Nonnull final String arguments) { + this.arguments = arguments; + return this; + } + + /** + * The arguments to call the function with, as generated by the model in JSON format. Note that + * the model does not always generate valid JSON, and may hallucinate parameters not defined by + * your function schema. Validate the arguments in your code before calling your function. + * + * @return arguments The arguments of this {@link ChatCompletionMessageToolCallFunction} instance. + */ + @Nonnull + public String getArguments() { + return arguments; + } + + /** + * Set the arguments of this {@link ChatCompletionMessageToolCallFunction} instance. + * + * @param arguments The arguments to call the function with, as generated by the model in JSON + * format. Note that the model does not always generate valid JSON, and may hallucinate + * parameters not defined by your function schema. Validate the arguments in your code before + * calling your function. + */ + public void setArguments(@Nonnull final String arguments) { + this.arguments = arguments; + } + + /** + * Get the names of the unrecognizable properties of the {@link + * ChatCompletionMessageToolCallFunction}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link + * ChatCompletionMessageToolCallFunction} instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ChatCompletionMessageToolCallFunction has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ChatCompletionMessageToolCallFunction} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ChatCompletionMessageToolCallFunction chatCompletionMessageToolCallFunction = + (ChatCompletionMessageToolCallFunction) o; + return Objects.equals( + this.cloudSdkCustomFields, chatCompletionMessageToolCallFunction.cloudSdkCustomFields) + && Objects.equals(this.name, chatCompletionMessageToolCallFunction.name) + && Objects.equals(this.arguments, chatCompletionMessageToolCallFunction.arguments); + } + + @Override + public int hashCode() { + return Objects.hash(name, arguments, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ChatCompletionMessageToolCallFunction {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" arguments: ").append(toIndentedString(arguments)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionNamedToolChoice.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionNamedToolChoice.java new file mode 100644 index 000000000..865301c7e --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionNamedToolChoice.java @@ -0,0 +1,248 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +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; + +/** Specifies a tool the model should use. Use to force the model to call a specific function. */ +// CHECKSTYLE:OFF +public class ChatCompletionNamedToolChoice +// CHECKSTYLE:ON +{ + /** The type of the tool. Currently, only `function` is supported. */ + public enum TypeEnum { + /** The FUNCTION option of this ChatCompletionNamedToolChoice */ + FUNCTION("function"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value The String value + * @return The enum value of type ChatCompletionNamedToolChoice + */ + @JsonCreator + @Nonnull + public static TypeEnum fromValue(@Nonnull final String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("type") + private TypeEnum type; + + @JsonProperty("function") + private ChatCompletionNamedToolChoiceFunction function; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the type of this {@link ChatCompletionNamedToolChoice} instance and return the same + * instance. + * + * @param type The type of the tool. Currently, only `function` is supported. + * @return The same instance of this {@link ChatCompletionNamedToolChoice} class + */ + @Nonnull + public ChatCompletionNamedToolChoice type(@Nonnull final TypeEnum type) { + this.type = type; + return this; + } + + /** + * The type of the tool. Currently, only `function` is supported. + * + * @return type The type of this {@link ChatCompletionNamedToolChoice} instance. + */ + @Nonnull + public TypeEnum getType() { + return type; + } + + /** + * Set the type of this {@link ChatCompletionNamedToolChoice} instance. + * + * @param type The type of the tool. Currently, only `function` is supported. + */ + public void setType(@Nonnull final TypeEnum type) { + this.type = type; + } + + /** + * Set the function of this {@link ChatCompletionNamedToolChoice} instance and return the same + * instance. + * + * @param function The function of this {@link ChatCompletionNamedToolChoice} + * @return The same instance of this {@link ChatCompletionNamedToolChoice} class + */ + @Nonnull + public ChatCompletionNamedToolChoice function( + @Nonnull final ChatCompletionNamedToolChoiceFunction function) { + this.function = function; + return this; + } + + /** + * Get function + * + * @return function The function of this {@link ChatCompletionNamedToolChoice} instance. + */ + @Nonnull + public ChatCompletionNamedToolChoiceFunction getFunction() { + return function; + } + + /** + * Set the function of this {@link ChatCompletionNamedToolChoice} instance. + * + * @param function The function of this {@link ChatCompletionNamedToolChoice} + */ + public void setFunction(@Nonnull final ChatCompletionNamedToolChoiceFunction function) { + this.function = function; + } + + /** + * Get the names of the unrecognizable properties of the {@link ChatCompletionNamedToolChoice}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ChatCompletionNamedToolChoice} + * instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ChatCompletionNamedToolChoice has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ChatCompletionNamedToolChoice} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ChatCompletionNamedToolChoice chatCompletionNamedToolChoice = + (ChatCompletionNamedToolChoice) o; + return Objects.equals( + this.cloudSdkCustomFields, chatCompletionNamedToolChoice.cloudSdkCustomFields) + && Objects.equals(this.type, chatCompletionNamedToolChoice.type) + && Objects.equals(this.function, chatCompletionNamedToolChoice.function); + } + + @Override + public int hashCode() { + return Objects.hash(type, function, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ChatCompletionNamedToolChoice {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" function: ").append(toIndentedString(function)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionNamedToolChoiceFunction.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionNamedToolChoiceFunction.java new file mode 100644 index 000000000..16814858a --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionNamedToolChoiceFunction.java @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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; + +/** ChatCompletionNamedToolChoiceFunction */ +// CHECKSTYLE:OFF +public class ChatCompletionNamedToolChoiceFunction +// CHECKSTYLE:ON +{ + @JsonProperty("name") + private String name; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the name of this {@link ChatCompletionNamedToolChoiceFunction} instance and return the same + * instance. + * + * @param name The name of the function to call. + * @return The same instance of this {@link ChatCompletionNamedToolChoiceFunction} class + */ + @Nonnull + public ChatCompletionNamedToolChoiceFunction name(@Nonnull final String name) { + this.name = name; + return this; + } + + /** + * The name of the function to call. + * + * @return name The name of this {@link ChatCompletionNamedToolChoiceFunction} instance. + */ + @Nonnull + public String getName() { + return name; + } + + /** + * Set the name of this {@link ChatCompletionNamedToolChoiceFunction} instance. + * + * @param name The name of the function to call. + */ + public void setName(@Nonnull final String name) { + this.name = name; + } + + /** + * Get the names of the unrecognizable properties of the {@link + * ChatCompletionNamedToolChoiceFunction}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link + * ChatCompletionNamedToolChoiceFunction} instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ChatCompletionNamedToolChoiceFunction has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ChatCompletionNamedToolChoiceFunction} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ChatCompletionNamedToolChoiceFunction chatCompletionNamedToolChoiceFunction = + (ChatCompletionNamedToolChoiceFunction) o; + return Objects.equals( + this.cloudSdkCustomFields, chatCompletionNamedToolChoiceFunction.cloudSdkCustomFields) + && Objects.equals(this.name, chatCompletionNamedToolChoiceFunction.name); + } + + @Override + public int hashCode() { + return Objects.hash(name, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ChatCompletionNamedToolChoiceFunction {\n"); + sb.append(" name: ").append(toIndentedString(name)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestAssistantMessage.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestAssistantMessage.java new file mode 100644 index 000000000..135d3d3e1 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestAssistantMessage.java @@ -0,0 +1,425 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** ChatCompletionRequestAssistantMessage */ +// CHECKSTYLE:OFF +public class ChatCompletionRequestAssistantMessage implements ChatCompletionRequestMessage +// CHECKSTYLE:ON +{ + @JsonProperty("content") + private ChatCompletionRequestAssistantMessageContent content; + + @JsonProperty("refusal") + private String refusal; + + /** The role of the messages author, in this case `assistant`. */ + public enum RoleEnum { + /** The ASSISTANT option of this ChatCompletionRequestAssistantMessage */ + ASSISTANT("assistant"); + + private String value; + + RoleEnum(String value) { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value The String value + * @return The enum value of type ChatCompletionRequestAssistantMessage + */ + @JsonCreator + @Nonnull + public static RoleEnum fromValue(@Nonnull final String value) { + for (RoleEnum b : RoleEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("role") + private RoleEnum role; + + @JsonProperty("name") + private String name; + + @JsonProperty("tool_calls") + private List toolCalls = new ArrayList<>(); + + @JsonProperty("function_call") + private ChatCompletionRequestAssistantMessageFunctionCall functionCall; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the content of this {@link ChatCompletionRequestAssistantMessage} instance and return the + * same instance. + * + * @param content The content of this {@link ChatCompletionRequestAssistantMessage} + * @return The same instance of this {@link ChatCompletionRequestAssistantMessage} class + */ + @Nonnull + public ChatCompletionRequestAssistantMessage content( + @Nullable final ChatCompletionRequestAssistantMessageContent content) { + this.content = content; + return this; + } + + /** + * Get content + * + * @return content The content of this {@link ChatCompletionRequestAssistantMessage} instance. + */ + @Nullable + public ChatCompletionRequestAssistantMessageContent getContent() { + return content; + } + + /** + * Set the content of this {@link ChatCompletionRequestAssistantMessage} instance. + * + * @param content The content of this {@link ChatCompletionRequestAssistantMessage} + */ + public void setContent(@Nullable final ChatCompletionRequestAssistantMessageContent content) { + this.content = content; + } + + /** + * Set the refusal of this {@link ChatCompletionRequestAssistantMessage} instance and return the + * same instance. + * + * @param refusal The refusal message by the assistant. + * @return The same instance of this {@link ChatCompletionRequestAssistantMessage} class + */ + @Nonnull + public ChatCompletionRequestAssistantMessage refusal(@Nullable final String refusal) { + this.refusal = refusal; + return this; + } + + /** + * The refusal message by the assistant. + * + * @return refusal The refusal of this {@link ChatCompletionRequestAssistantMessage} instance. + */ + @Nullable + public String getRefusal() { + return refusal; + } + + /** + * Set the refusal of this {@link ChatCompletionRequestAssistantMessage} instance. + * + * @param refusal The refusal message by the assistant. + */ + public void setRefusal(@Nullable final String refusal) { + this.refusal = refusal; + } + + /** + * Set the role of this {@link ChatCompletionRequestAssistantMessage} instance and return the same + * instance. + * + * @param role The role of the messages author, in this case `assistant`. + * @return The same instance of this {@link ChatCompletionRequestAssistantMessage} class + */ + @Nonnull + public ChatCompletionRequestAssistantMessage role(@Nonnull final RoleEnum role) { + this.role = role; + return this; + } + + /** + * The role of the messages author, in this case `assistant`. + * + * @return role The role of this {@link ChatCompletionRequestAssistantMessage} instance. + */ + @Nonnull + public RoleEnum getRole() { + return role; + } + + /** + * Set the role of this {@link ChatCompletionRequestAssistantMessage} instance. + * + * @param role The role of the messages author, in this case `assistant`. + */ + public void setRole(@Nonnull final RoleEnum role) { + this.role = role; + } + + /** + * Set the name of this {@link ChatCompletionRequestAssistantMessage} instance and return the same + * instance. + * + * @param name An optional name for the participant. Provides the model information to + * differentiate between participants of the same role. + * @return The same instance of this {@link ChatCompletionRequestAssistantMessage} class + */ + @Nonnull + public ChatCompletionRequestAssistantMessage name(@Nullable final String name) { + this.name = name; + return this; + } + + /** + * An optional name for the participant. Provides the model information to differentiate between + * participants of the same role. + * + * @return name The name of this {@link ChatCompletionRequestAssistantMessage} instance. + */ + @Nonnull + public String getName() { + return name; + } + + /** + * Set the name of this {@link ChatCompletionRequestAssistantMessage} instance. + * + * @param name An optional name for the participant. Provides the model information to + * differentiate between participants of the same role. + */ + public void setName(@Nullable final String name) { + this.name = name; + } + + /** + * Set the toolCalls of this {@link ChatCompletionRequestAssistantMessage} instance and return the + * same instance. + * + * @param toolCalls The tool calls generated by the model, such as function calls. + * @return The same instance of this {@link ChatCompletionRequestAssistantMessage} class + */ + @Nonnull + public ChatCompletionRequestAssistantMessage toolCalls( + @Nullable final List toolCalls) { + this.toolCalls = toolCalls; + return this; + } + + /** + * Add one toolCalls instance to this {@link ChatCompletionRequestAssistantMessage}. + * + * @param toolCallsItem The toolCalls that should be added + * @return The same instance of type {@link ChatCompletionRequestAssistantMessage} + */ + @Nonnull + public ChatCompletionRequestAssistantMessage addToolCallsItem( + @Nonnull final ChatCompletionMessageToolCall toolCallsItem) { + if (this.toolCalls == null) { + this.toolCalls = new ArrayList<>(); + } + this.toolCalls.add(toolCallsItem); + return this; + } + + /** + * The tool calls generated by the model, such as function calls. + * + * @return toolCalls The toolCalls of this {@link ChatCompletionRequestAssistantMessage} instance. + */ + @Nonnull + public List getToolCalls() { + return toolCalls; + } + + /** + * Set the toolCalls of this {@link ChatCompletionRequestAssistantMessage} instance. + * + * @param toolCalls The tool calls generated by the model, such as function calls. + */ + public void setToolCalls(@Nullable final List toolCalls) { + this.toolCalls = toolCalls; + } + + /** + * Set the functionCall of this {@link ChatCompletionRequestAssistantMessage} instance and return + * the same instance. + * + * @param functionCall The functionCall of this {@link ChatCompletionRequestAssistantMessage} + * @return The same instance of this {@link ChatCompletionRequestAssistantMessage} class + */ + @Nonnull + public ChatCompletionRequestAssistantMessage functionCall( + @Nullable final ChatCompletionRequestAssistantMessageFunctionCall functionCall) { + this.functionCall = functionCall; + return this; + } + + /** + * Get functionCall + * + * @return functionCall The functionCall of this {@link ChatCompletionRequestAssistantMessage} + * instance. + * @deprecated + */ + @Deprecated + @Nullable + public ChatCompletionRequestAssistantMessageFunctionCall getFunctionCall() { + return functionCall; + } + + /** + * Set the functionCall of this {@link ChatCompletionRequestAssistantMessage} instance. + * + * @param functionCall The functionCall of this {@link ChatCompletionRequestAssistantMessage} + */ + public void setFunctionCall( + @Nullable final ChatCompletionRequestAssistantMessageFunctionCall functionCall) { + this.functionCall = functionCall; + } + + /** + * Get the names of the unrecognizable properties of the {@link + * ChatCompletionRequestAssistantMessage}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link + * ChatCompletionRequestAssistantMessage} instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ChatCompletionRequestAssistantMessage has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ChatCompletionRequestAssistantMessage} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ChatCompletionRequestAssistantMessage chatCompletionRequestAssistantMessage = + (ChatCompletionRequestAssistantMessage) o; + return Objects.equals( + this.cloudSdkCustomFields, chatCompletionRequestAssistantMessage.cloudSdkCustomFields) + && Objects.equals(this.content, chatCompletionRequestAssistantMessage.content) + && Objects.equals(this.refusal, chatCompletionRequestAssistantMessage.refusal) + && Objects.equals(this.role, chatCompletionRequestAssistantMessage.role) + && Objects.equals(this.name, chatCompletionRequestAssistantMessage.name) + && Objects.equals(this.toolCalls, chatCompletionRequestAssistantMessage.toolCalls) + && Objects.equals(this.functionCall, chatCompletionRequestAssistantMessage.functionCall); + } + + @Override + public int hashCode() { + return Objects.hash( + content, refusal, role, name, toolCalls, functionCall, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ChatCompletionRequestAssistantMessage {\n"); + sb.append(" content: ").append(toIndentedString(content)).append("\n"); + sb.append(" refusal: ").append(toIndentedString(refusal)).append("\n"); + sb.append(" role: ").append(toIndentedString(role)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" toolCalls: ").append(toIndentedString(toolCalls)).append("\n"); + sb.append(" functionCall: ").append(toIndentedString(functionCall)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestAssistantMessageContent.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestAssistantMessageContent.java new file mode 100644 index 000000000..bfb5c3bd7 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestAssistantMessageContent.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import java.util.List; + +/** + * The contents of the assistant message. Required unless `tool_calls` or + * `function_call` is specified. + */ +public interface ChatCompletionRequestAssistantMessageContent { + /** + * Helper class to create a String that implements {@link + * ChatCompletionRequestAssistantMessageContent}. + */ + record InnerString(@com.fasterxml.jackson.annotation.JsonValue String value) + implements ChatCompletionRequestAssistantMessageContent {} + + /** + * Creator to enable deserialization of a String. + * + * @param val the value to use + * @return a new instance of {@link InnerString}. + */ + @com.fasterxml.jackson.annotation.JsonCreator + static InnerString create(String val) { + return new InnerString(val); + } + + /** + * Helper class to create a list of ChatCompletionRequestAssistantMessageContentPart that + * implements {@link ChatCompletionRequestAssistantMessageContent}. + */ + record InnerChatCompletionRequestAssistantMessageContentParts( + @com.fasterxml.jackson.annotation.JsonValue + List values) + implements ChatCompletionRequestAssistantMessageContent {} + + /** + * Creator to enable deserialization of a list of + * ChatCompletionRequestAssistantMessageContentPart. + * + * @param val the value to use + * @return a new instance of {@link InnerChatCompletionRequestAssistantMessageContentParts}. + */ + @com.fasterxml.jackson.annotation.JsonCreator + static InnerChatCompletionRequestAssistantMessageContentParts create( + List val) { + return new InnerChatCompletionRequestAssistantMessageContentParts(val); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestAssistantMessageContentPart.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestAssistantMessageContentPart.java new file mode 100644 index 000000000..a0f14ee4d --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestAssistantMessageContentPart.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +/** ChatCompletionRequestAssistantMessageContentPart */ +@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChatCompletionRequestMessageContentPartRefusal.class), + @JsonSubTypes.Type(value = ChatCompletionRequestMessageContentPartText.class), +}) +public interface ChatCompletionRequestAssistantMessageContentPart {} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestAssistantMessageFunctionCall.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestAssistantMessageFunctionCall.java new file mode 100644 index 000000000..9d9222555 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestAssistantMessageFunctionCall.java @@ -0,0 +1,219 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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; + +/** + * Deprecated and replaced by `tool_calls`. The name and arguments of a function that + * should be called, as generated by the model. + * + * @deprecated + */ +@Deprecated +// CHECKSTYLE:OFF +public class ChatCompletionRequestAssistantMessageFunctionCall +// CHECKSTYLE:ON +{ + @JsonProperty("arguments") + private String arguments; + + @JsonProperty("name") + private String name; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the arguments of this {@link ChatCompletionRequestAssistantMessageFunctionCall} instance + * and return the same instance. + * + * @param arguments The arguments to call the function with, as generated by the model in JSON + * format. Note that the model does not always generate valid JSON, and may hallucinate + * parameters not defined by your function schema. Validate the arguments in your code before + * calling your function. + * @return The same instance of this {@link ChatCompletionRequestAssistantMessageFunctionCall} + * class + */ + @Nonnull + public ChatCompletionRequestAssistantMessageFunctionCall arguments( + @Nonnull final String arguments) { + this.arguments = arguments; + return this; + } + + /** + * The arguments to call the function with, as generated by the model in JSON format. Note that + * the model does not always generate valid JSON, and may hallucinate parameters not defined by + * your function schema. Validate the arguments in your code before calling your function. + * + * @return arguments The arguments of this {@link + * ChatCompletionRequestAssistantMessageFunctionCall} instance. + */ + @Nonnull + public String getArguments() { + return arguments; + } + + /** + * Set the arguments of this {@link ChatCompletionRequestAssistantMessageFunctionCall} instance. + * + * @param arguments The arguments to call the function with, as generated by the model in JSON + * format. Note that the model does not always generate valid JSON, and may hallucinate + * parameters not defined by your function schema. Validate the arguments in your code before + * calling your function. + */ + public void setArguments(@Nonnull final String arguments) { + this.arguments = arguments; + } + + /** + * Set the name of this {@link ChatCompletionRequestAssistantMessageFunctionCall} instance and + * return the same instance. + * + * @param name The name of the function to call. + * @return The same instance of this {@link ChatCompletionRequestAssistantMessageFunctionCall} + * class + */ + @Nonnull + public ChatCompletionRequestAssistantMessageFunctionCall name(@Nonnull final String name) { + this.name = name; + return this; + } + + /** + * The name of the function to call. + * + * @return name The name of this {@link ChatCompletionRequestAssistantMessageFunctionCall} + * instance. + */ + @Nonnull + public String getName() { + return name; + } + + /** + * Set the name of this {@link ChatCompletionRequestAssistantMessageFunctionCall} instance. + * + * @param name The name of the function to call. + */ + public void setName(@Nonnull final String name) { + this.name = name; + } + + /** + * Get the names of the unrecognizable properties of the {@link + * ChatCompletionRequestAssistantMessageFunctionCall}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link + * ChatCompletionRequestAssistantMessageFunctionCall} instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ChatCompletionRequestAssistantMessageFunctionCall has no field with name '" + + name + + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link + * ChatCompletionRequestAssistantMessageFunctionCall} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ChatCompletionRequestAssistantMessageFunctionCall + chatCompletionRequestAssistantMessageFunctionCall = + (ChatCompletionRequestAssistantMessageFunctionCall) o; + return Objects.equals( + this.cloudSdkCustomFields, + chatCompletionRequestAssistantMessageFunctionCall.cloudSdkCustomFields) + && Objects.equals( + this.arguments, chatCompletionRequestAssistantMessageFunctionCall.arguments) + && Objects.equals(this.name, chatCompletionRequestAssistantMessageFunctionCall.name); + } + + @Override + public int hashCode() { + return Objects.hash(arguments, name, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ChatCompletionRequestAssistantMessageFunctionCall {\n"); + sb.append(" arguments: ").append(toIndentedString(arguments)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestFunctionMessage.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestFunctionMessage.java new file mode 100644 index 000000000..5ac955a4b --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestFunctionMessage.java @@ -0,0 +1,290 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +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; + +/** + * ChatCompletionRequestFunctionMessage + * + * @deprecated + */ +@Deprecated +// CHECKSTYLE:OFF +public class ChatCompletionRequestFunctionMessage implements ChatCompletionRequestMessage +// CHECKSTYLE:ON +{ + /** The role of the messages author, in this case `function`. */ + public enum RoleEnum { + /** The FUNCTION option of this ChatCompletionRequestFunctionMessage */ + FUNCTION("function"); + + private String value; + + RoleEnum(String value) { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value The String value + * @return The enum value of type ChatCompletionRequestFunctionMessage + */ + @JsonCreator + @Nonnull + public static RoleEnum fromValue(@Nonnull final String value) { + for (RoleEnum b : RoleEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("role") + private RoleEnum role; + + @JsonProperty("content") + private String content; + + @JsonProperty("name") + private String name; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the role of this {@link ChatCompletionRequestFunctionMessage} instance and return the same + * instance. + * + * @param role The role of the messages author, in this case `function`. + * @return The same instance of this {@link ChatCompletionRequestFunctionMessage} class + */ + @Nonnull + public ChatCompletionRequestFunctionMessage role(@Nonnull final RoleEnum role) { + this.role = role; + return this; + } + + /** + * The role of the messages author, in this case `function`. + * + * @return role The role of this {@link ChatCompletionRequestFunctionMessage} instance. + */ + @Nonnull + public RoleEnum getRole() { + return role; + } + + /** + * Set the role of this {@link ChatCompletionRequestFunctionMessage} instance. + * + * @param role The role of the messages author, in this case `function`. + */ + public void setRole(@Nonnull final RoleEnum role) { + this.role = role; + } + + /** + * Set the content of this {@link ChatCompletionRequestFunctionMessage} instance and return the + * same instance. + * + * @param content The contents of the function message. + * @return The same instance of this {@link ChatCompletionRequestFunctionMessage} class + */ + @Nonnull + public ChatCompletionRequestFunctionMessage content(@Nullable final String content) { + this.content = content; + return this; + } + + /** + * The contents of the function message. + * + * @return content The content of this {@link ChatCompletionRequestFunctionMessage} instance. + */ + @Nullable + public String getContent() { + return content; + } + + /** + * Set the content of this {@link ChatCompletionRequestFunctionMessage} instance. + * + * @param content The contents of the function message. + */ + public void setContent(@Nullable final String content) { + this.content = content; + } + + /** + * Set the name of this {@link ChatCompletionRequestFunctionMessage} instance and return the same + * instance. + * + * @param name The name of the function to call. + * @return The same instance of this {@link ChatCompletionRequestFunctionMessage} class + */ + @Nonnull + public ChatCompletionRequestFunctionMessage name(@Nonnull final String name) { + this.name = name; + return this; + } + + /** + * The name of the function to call. + * + * @return name The name of this {@link ChatCompletionRequestFunctionMessage} instance. + */ + @Nonnull + public String getName() { + return name; + } + + /** + * Set the name of this {@link ChatCompletionRequestFunctionMessage} instance. + * + * @param name The name of the function to call. + */ + public void setName(@Nonnull final String name) { + this.name = name; + } + + /** + * Get the names of the unrecognizable properties of the {@link + * ChatCompletionRequestFunctionMessage}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link + * ChatCompletionRequestFunctionMessage} instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ChatCompletionRequestFunctionMessage has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ChatCompletionRequestFunctionMessage} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ChatCompletionRequestFunctionMessage chatCompletionRequestFunctionMessage = + (ChatCompletionRequestFunctionMessage) o; + return Objects.equals( + this.cloudSdkCustomFields, chatCompletionRequestFunctionMessage.cloudSdkCustomFields) + && Objects.equals(this.role, chatCompletionRequestFunctionMessage.role) + && Objects.equals(this.content, chatCompletionRequestFunctionMessage.content) + && Objects.equals(this.name, chatCompletionRequestFunctionMessage.name); + } + + @Override + public int hashCode() { + return Objects.hash(role, content, name, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ChatCompletionRequestFunctionMessage {\n"); + sb.append(" role: ").append(toIndentedString(role)).append("\n"); + sb.append(" content: ").append(toIndentedString(content)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestMessage.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestMessage.java new file mode 100644 index 000000000..4c67126f6 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestMessage.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +/** ChatCompletionRequestMessage */ +@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChatCompletionRequestAssistantMessage.class), + @JsonSubTypes.Type(value = ChatCompletionRequestFunctionMessage.class), + @JsonSubTypes.Type(value = ChatCompletionRequestSystemMessage.class), + @JsonSubTypes.Type(value = ChatCompletionRequestToolMessage.class), + @JsonSubTypes.Type(value = ChatCompletionRequestUserMessage.class), +}) +public interface ChatCompletionRequestMessage {} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestMessageContentPartImage.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestMessageContentPartImage.java new file mode 100644 index 000000000..e28989a1e --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestMessageContentPartImage.java @@ -0,0 +1,254 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +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; + +/** ChatCompletionRequestMessageContentPartImage */ +// CHECKSTYLE:OFF +public class ChatCompletionRequestMessageContentPartImage + implements ChatCompletionRequestUserMessageContentPart +// CHECKSTYLE:ON +{ + /** The type of the content part. */ + public enum TypeEnum { + /** The IMAGE_URL option of this ChatCompletionRequestMessageContentPartImage */ + IMAGE_URL("image_url"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value The String value + * @return The enum value of type ChatCompletionRequestMessageContentPartImage + */ + @JsonCreator + @Nonnull + public static TypeEnum fromValue(@Nonnull final String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("type") + private TypeEnum type; + + @JsonProperty("image_url") + private ChatCompletionRequestMessageContentPartImageImageUrl imageUrl; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the type of this {@link ChatCompletionRequestMessageContentPartImage} instance and return + * the same instance. + * + * @param type The type of the content part. + * @return The same instance of this {@link ChatCompletionRequestMessageContentPartImage} class + */ + @Nonnull + public ChatCompletionRequestMessageContentPartImage type(@Nonnull final TypeEnum type) { + this.type = type; + return this; + } + + /** + * The type of the content part. + * + * @return type The type of this {@link ChatCompletionRequestMessageContentPartImage} instance. + */ + @Nonnull + public TypeEnum getType() { + return type; + } + + /** + * Set the type of this {@link ChatCompletionRequestMessageContentPartImage} instance. + * + * @param type The type of the content part. + */ + public void setType(@Nonnull final TypeEnum type) { + this.type = type; + } + + /** + * Set the imageUrl of this {@link ChatCompletionRequestMessageContentPartImage} instance and + * return the same instance. + * + * @param imageUrl The imageUrl of this {@link ChatCompletionRequestMessageContentPartImage} + * @return The same instance of this {@link ChatCompletionRequestMessageContentPartImage} class + */ + @Nonnull + public ChatCompletionRequestMessageContentPartImage imageUrl( + @Nonnull final ChatCompletionRequestMessageContentPartImageImageUrl imageUrl) { + this.imageUrl = imageUrl; + return this; + } + + /** + * Get imageUrl + * + * @return imageUrl The imageUrl of this {@link ChatCompletionRequestMessageContentPartImage} + * instance. + */ + @Nonnull + public ChatCompletionRequestMessageContentPartImageImageUrl getImageUrl() { + return imageUrl; + } + + /** + * Set the imageUrl of this {@link ChatCompletionRequestMessageContentPartImage} instance. + * + * @param imageUrl The imageUrl of this {@link ChatCompletionRequestMessageContentPartImage} + */ + public void setImageUrl( + @Nonnull final ChatCompletionRequestMessageContentPartImageImageUrl imageUrl) { + this.imageUrl = imageUrl; + } + + /** + * Get the names of the unrecognizable properties of the {@link + * ChatCompletionRequestMessageContentPartImage}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link + * ChatCompletionRequestMessageContentPartImage} instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ChatCompletionRequestMessageContentPartImage has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ChatCompletionRequestMessageContentPartImage} + * 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ChatCompletionRequestMessageContentPartImage + chatCompletionRequestMessageContentPartImage = + (ChatCompletionRequestMessageContentPartImage) o; + return Objects.equals( + this.cloudSdkCustomFields, + chatCompletionRequestMessageContentPartImage.cloudSdkCustomFields) + && Objects.equals(this.type, chatCompletionRequestMessageContentPartImage.type) + && Objects.equals(this.imageUrl, chatCompletionRequestMessageContentPartImage.imageUrl); + } + + @Override + public int hashCode() { + return Objects.hash(type, imageUrl, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ChatCompletionRequestMessageContentPartImage {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" imageUrl: ").append(toIndentedString(imageUrl)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestMessageContentPartImageImageUrl.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestMessageContentPartImageImageUrl.java new file mode 100644 index 000000000..be24ccdfa --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestMessageContentPartImageImageUrl.java @@ -0,0 +1,270 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import java.net.URI; +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; + +/** ChatCompletionRequestMessageContentPartImageImageUrl */ +// CHECKSTYLE:OFF +public class ChatCompletionRequestMessageContentPartImageImageUrl +// CHECKSTYLE:ON +{ + @JsonProperty("url") + private URI url; + + /** + * Specifies the detail level of the image. Learn more in the [Vision + * guide](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/gpt-with-vision?tabs=rest%2Csystem-assigned%2Cresource#detail-parameter-settings-in-image-processing-low-high-auto). + */ + public enum DetailEnum { + /** The AUTO option of this ChatCompletionRequestMessageContentPartImageImageUrl */ + AUTO("auto"), + + /** The LOW option of this ChatCompletionRequestMessageContentPartImageImageUrl */ + LOW("low"), + + /** The HIGH option of this ChatCompletionRequestMessageContentPartImageImageUrl */ + HIGH("high"); + + private String value; + + DetailEnum(String value) { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value The String value + * @return The enum value of type ChatCompletionRequestMessageContentPartImageImageUrl + */ + @JsonCreator + @Nonnull + public static DetailEnum fromValue(@Nonnull final String value) { + for (DetailEnum b : DetailEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("detail") + private DetailEnum detail = DetailEnum.AUTO; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the url of this {@link ChatCompletionRequestMessageContentPartImageImageUrl} instance and + * return the same instance. + * + * @param url Either a URL of the image or the base64 encoded image data. + * @return The same instance of this {@link ChatCompletionRequestMessageContentPartImageImageUrl} + * class + */ + @Nonnull + public ChatCompletionRequestMessageContentPartImageImageUrl url(@Nonnull final URI url) { + this.url = url; + return this; + } + + /** + * Either a URL of the image or the base64 encoded image data. + * + * @return url The url of this {@link ChatCompletionRequestMessageContentPartImageImageUrl} + * instance. + */ + @Nonnull + public URI getUrl() { + return url; + } + + /** + * Set the url of this {@link ChatCompletionRequestMessageContentPartImageImageUrl} instance. + * + * @param url Either a URL of the image or the base64 encoded image data. + */ + public void setUrl(@Nonnull final URI url) { + this.url = url; + } + + /** + * Set the detail of this {@link ChatCompletionRequestMessageContentPartImageImageUrl} instance + * and return the same instance. + * + * @param detail Specifies the detail level of the image. Learn more in the [Vision + * guide](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/gpt-with-vision?tabs=rest%2Csystem-assigned%2Cresource#detail-parameter-settings-in-image-processing-low-high-auto). + * @return The same instance of this {@link ChatCompletionRequestMessageContentPartImageImageUrl} + * class + */ + @Nonnull + public ChatCompletionRequestMessageContentPartImageImageUrl detail( + @Nullable final DetailEnum detail) { + this.detail = detail; + return this; + } + + /** + * Specifies the detail level of the image. Learn more in the [Vision + * guide](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/gpt-with-vision?tabs=rest%2Csystem-assigned%2Cresource#detail-parameter-settings-in-image-processing-low-high-auto). + * + * @return detail The detail of this {@link ChatCompletionRequestMessageContentPartImageImageUrl} + * instance. + */ + @Nonnull + public DetailEnum getDetail() { + return detail; + } + + /** + * Set the detail of this {@link ChatCompletionRequestMessageContentPartImageImageUrl} instance. + * + * @param detail Specifies the detail level of the image. Learn more in the [Vision + * guide](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/gpt-with-vision?tabs=rest%2Csystem-assigned%2Cresource#detail-parameter-settings-in-image-processing-low-high-auto). + */ + public void setDetail(@Nullable final DetailEnum detail) { + this.detail = detail; + } + + /** + * Get the names of the unrecognizable properties of the {@link + * ChatCompletionRequestMessageContentPartImageImageUrl}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link + * ChatCompletionRequestMessageContentPartImageImageUrl} instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ChatCompletionRequestMessageContentPartImageImageUrl has no field with name '" + + name + + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link + * ChatCompletionRequestMessageContentPartImageImageUrl} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ChatCompletionRequestMessageContentPartImageImageUrl + chatCompletionRequestMessageContentPartImageImageUrl = + (ChatCompletionRequestMessageContentPartImageImageUrl) o; + return Objects.equals( + this.cloudSdkCustomFields, + chatCompletionRequestMessageContentPartImageImageUrl.cloudSdkCustomFields) + && Objects.equals(this.url, chatCompletionRequestMessageContentPartImageImageUrl.url) + && Objects.equals(this.detail, chatCompletionRequestMessageContentPartImageImageUrl.detail); + } + + @Override + public int hashCode() { + return Objects.hash(url, detail, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ChatCompletionRequestMessageContentPartImageImageUrl {\n"); + sb.append(" url: ").append(toIndentedString(url)).append("\n"); + sb.append(" detail: ").append(toIndentedString(detail)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestMessageContentPartRefusal.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestMessageContentPartRefusal.java new file mode 100644 index 000000000..c66b887ca --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestMessageContentPartRefusal.java @@ -0,0 +1,252 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +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; + +/** ChatCompletionRequestMessageContentPartRefusal */ +// CHECKSTYLE:OFF +public class ChatCompletionRequestMessageContentPartRefusal + implements ChatCompletionRequestAssistantMessageContentPart +// CHECKSTYLE:ON +{ + /** The type of the content part. */ + public enum TypeEnum { + /** The REFUSAL option of this ChatCompletionRequestMessageContentPartRefusal */ + REFUSAL("refusal"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value The String value + * @return The enum value of type ChatCompletionRequestMessageContentPartRefusal + */ + @JsonCreator + @Nonnull + public static TypeEnum fromValue(@Nonnull final String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("type") + private TypeEnum type; + + @JsonProperty("refusal") + private String refusal; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the type of this {@link ChatCompletionRequestMessageContentPartRefusal} instance and return + * the same instance. + * + * @param type The type of the content part. + * @return The same instance of this {@link ChatCompletionRequestMessageContentPartRefusal} class + */ + @Nonnull + public ChatCompletionRequestMessageContentPartRefusal type(@Nonnull final TypeEnum type) { + this.type = type; + return this; + } + + /** + * The type of the content part. + * + * @return type The type of this {@link ChatCompletionRequestMessageContentPartRefusal} instance. + */ + @Nonnull + public TypeEnum getType() { + return type; + } + + /** + * Set the type of this {@link ChatCompletionRequestMessageContentPartRefusal} instance. + * + * @param type The type of the content part. + */ + public void setType(@Nonnull final TypeEnum type) { + this.type = type; + } + + /** + * Set the refusal of this {@link ChatCompletionRequestMessageContentPartRefusal} instance and + * return the same instance. + * + * @param refusal The refusal message generated by the model. + * @return The same instance of this {@link ChatCompletionRequestMessageContentPartRefusal} class + */ + @Nonnull + public ChatCompletionRequestMessageContentPartRefusal refusal(@Nonnull final String refusal) { + this.refusal = refusal; + return this; + } + + /** + * The refusal message generated by the model. + * + * @return refusal The refusal of this {@link ChatCompletionRequestMessageContentPartRefusal} + * instance. + */ + @Nonnull + public String getRefusal() { + return refusal; + } + + /** + * Set the refusal of this {@link ChatCompletionRequestMessageContentPartRefusal} instance. + * + * @param refusal The refusal message generated by the model. + */ + public void setRefusal(@Nonnull final String refusal) { + this.refusal = refusal; + } + + /** + * Get the names of the unrecognizable properties of the {@link + * ChatCompletionRequestMessageContentPartRefusal}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link + * ChatCompletionRequestMessageContentPartRefusal} instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ChatCompletionRequestMessageContentPartRefusal has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ChatCompletionRequestMessageContentPartRefusal} + * 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ChatCompletionRequestMessageContentPartRefusal + chatCompletionRequestMessageContentPartRefusal = + (ChatCompletionRequestMessageContentPartRefusal) o; + return Objects.equals( + this.cloudSdkCustomFields, + chatCompletionRequestMessageContentPartRefusal.cloudSdkCustomFields) + && Objects.equals(this.type, chatCompletionRequestMessageContentPartRefusal.type) + && Objects.equals(this.refusal, chatCompletionRequestMessageContentPartRefusal.refusal); + } + + @Override + public int hashCode() { + return Objects.hash(type, refusal, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ChatCompletionRequestMessageContentPartRefusal {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" refusal: ").append(toIndentedString(refusal)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestMessageContentPartText.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestMessageContentPartText.java new file mode 100644 index 000000000..1733833c6 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestMessageContentPartText.java @@ -0,0 +1,253 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +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; + +/** ChatCompletionRequestMessageContentPartText */ +// CHECKSTYLE:OFF +public class ChatCompletionRequestMessageContentPartText + implements ChatCompletionRequestAssistantMessageContentPart, + ChatCompletionRequestSystemMessageContentPart, + ChatCompletionRequestToolMessageContentPart, + ChatCompletionRequestUserMessageContentPart +// CHECKSTYLE:ON +{ + /** The type of the content part. */ + public enum TypeEnum { + /** The TEXT option of this ChatCompletionRequestMessageContentPartText */ + TEXT("text"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value The String value + * @return The enum value of type ChatCompletionRequestMessageContentPartText + */ + @JsonCreator + @Nonnull + public static TypeEnum fromValue(@Nonnull final String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("type") + private TypeEnum type; + + @JsonProperty("text") + private String text; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the type of this {@link ChatCompletionRequestMessageContentPartText} instance and return + * the same instance. + * + * @param type The type of the content part. + * @return The same instance of this {@link ChatCompletionRequestMessageContentPartText} class + */ + @Nonnull + public ChatCompletionRequestMessageContentPartText type(@Nonnull final TypeEnum type) { + this.type = type; + return this; + } + + /** + * The type of the content part. + * + * @return type The type of this {@link ChatCompletionRequestMessageContentPartText} instance. + */ + @Nonnull + public TypeEnum getType() { + return type; + } + + /** + * Set the type of this {@link ChatCompletionRequestMessageContentPartText} instance. + * + * @param type The type of the content part. + */ + public void setType(@Nonnull final TypeEnum type) { + this.type = type; + } + + /** + * Set the text of this {@link ChatCompletionRequestMessageContentPartText} instance and return + * the same instance. + * + * @param text The text content. + * @return The same instance of this {@link ChatCompletionRequestMessageContentPartText} class + */ + @Nonnull + public ChatCompletionRequestMessageContentPartText text(@Nonnull final String text) { + this.text = text; + return this; + } + + /** + * The text content. + * + * @return text The text of this {@link ChatCompletionRequestMessageContentPartText} instance. + */ + @Nonnull + public String getText() { + return text; + } + + /** + * Set the text of this {@link ChatCompletionRequestMessageContentPartText} instance. + * + * @param text The text content. + */ + public void setText(@Nonnull final String text) { + this.text = text; + } + + /** + * Get the names of the unrecognizable properties of the {@link + * ChatCompletionRequestMessageContentPartText}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link + * ChatCompletionRequestMessageContentPartText} instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ChatCompletionRequestMessageContentPartText has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ChatCompletionRequestMessageContentPartText} + * 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ChatCompletionRequestMessageContentPartText chatCompletionRequestMessageContentPartText = + (ChatCompletionRequestMessageContentPartText) o; + return Objects.equals( + this.cloudSdkCustomFields, + chatCompletionRequestMessageContentPartText.cloudSdkCustomFields) + && Objects.equals(this.type, chatCompletionRequestMessageContentPartText.type) + && Objects.equals(this.text, chatCompletionRequestMessageContentPartText.text); + } + + @Override + public int hashCode() { + return Objects.hash(type, text, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ChatCompletionRequestMessageContentPartText {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" text: ").append(toIndentedString(text)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestMessageFunction.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestMessageFunction.java new file mode 100644 index 000000000..0cd651e13 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestMessageFunction.java @@ -0,0 +1,459 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** ChatCompletionRequestMessageFunction */ +// CHECKSTYLE:OFF +public class ChatCompletionRequestMessageFunction +// CHECKSTYLE:ON +{ + @JsonProperty("content") + private String content; + + /** The role of the messages author, in this case `function`. */ + public enum RoleEnum { + /** The FUNCTION option of this ChatCompletionRequestMessageFunction */ + FUNCTION("function"); + + private String value; + + RoleEnum(String value) { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value The String value + * @return The enum value of type ChatCompletionRequestMessageFunction + */ + @JsonCreator + @Nonnull + public static RoleEnum fromValue(@Nonnull final String value) { + for (RoleEnum b : RoleEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("role") + private RoleEnum role; + + @JsonProperty("name") + private String name; + + @JsonProperty("refusal") + private String refusal; + + @JsonProperty("tool_calls") + private List toolCalls = new ArrayList<>(); + + @JsonProperty("function_call") + private ChatCompletionRequestAssistantMessageFunctionCall functionCall; + + @JsonProperty("tool_call_id") + private String toolCallId; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the content of this {@link ChatCompletionRequestMessageFunction} instance and return the + * same instance. + * + * @param content The contents of the message. + * @return The same instance of this {@link ChatCompletionRequestMessageFunction} class + */ + @Nonnull + public ChatCompletionRequestMessageFunction content(@Nullable final String content) { + this.content = content; + return this; + } + + /** + * The contents of the message. + * + * @return content The content of this {@link ChatCompletionRequestMessageFunction} instance. + */ + @Nullable + public String getContent() { + return content; + } + + /** + * Set the content of this {@link ChatCompletionRequestMessageFunction} instance. + * + * @param content The contents of the message. + */ + public void setContent(@Nullable final String content) { + this.content = content; + } + + /** + * Set the role of this {@link ChatCompletionRequestMessageFunction} instance and return the same + * instance. + * + * @param role The role of the messages author, in this case `function`. + * @return The same instance of this {@link ChatCompletionRequestMessageFunction} class + */ + @Nonnull + public ChatCompletionRequestMessageFunction role(@Nonnull final RoleEnum role) { + this.role = role; + return this; + } + + /** + * The role of the messages author, in this case `function`. + * + * @return role The role of this {@link ChatCompletionRequestMessageFunction} instance. + */ + @Nonnull + public RoleEnum getRole() { + return role; + } + + /** + * Set the role of this {@link ChatCompletionRequestMessageFunction} instance. + * + * @param role The role of the messages author, in this case `function`. + */ + public void setRole(@Nonnull final RoleEnum role) { + this.role = role; + } + + /** + * Set the name of this {@link ChatCompletionRequestMessageFunction} instance and return the same + * instance. + * + * @param name The contents of the message. + * @return The same instance of this {@link ChatCompletionRequestMessageFunction} class + */ + @Nonnull + public ChatCompletionRequestMessageFunction name(@Nonnull final String name) { + this.name = name; + return this; + } + + /** + * The contents of the message. + * + * @return name The name of this {@link ChatCompletionRequestMessageFunction} instance. + */ + @Nonnull + public String getName() { + return name; + } + + /** + * Set the name of this {@link ChatCompletionRequestMessageFunction} instance. + * + * @param name The contents of the message. + */ + public void setName(@Nonnull final String name) { + this.name = name; + } + + /** + * Set the refusal of this {@link ChatCompletionRequestMessageFunction} instance and return the + * same instance. + * + * @param refusal The refusal message by the assistant. + * @return The same instance of this {@link ChatCompletionRequestMessageFunction} class + */ + @Nonnull + public ChatCompletionRequestMessageFunction refusal(@Nullable final String refusal) { + this.refusal = refusal; + return this; + } + + /** + * The refusal message by the assistant. + * + * @return refusal The refusal of this {@link ChatCompletionRequestMessageFunction} instance. + */ + @Nullable + public String getRefusal() { + return refusal; + } + + /** + * Set the refusal of this {@link ChatCompletionRequestMessageFunction} instance. + * + * @param refusal The refusal message by the assistant. + */ + public void setRefusal(@Nullable final String refusal) { + this.refusal = refusal; + } + + /** + * Set the toolCalls of this {@link ChatCompletionRequestMessageFunction} instance and return the + * same instance. + * + * @param toolCalls The tool calls generated by the model, such as function calls. + * @return The same instance of this {@link ChatCompletionRequestMessageFunction} class + */ + @Nonnull + public ChatCompletionRequestMessageFunction toolCalls( + @Nullable final List toolCalls) { + this.toolCalls = toolCalls; + return this; + } + + /** + * Add one toolCalls instance to this {@link ChatCompletionRequestMessageFunction}. + * + * @param toolCallsItem The toolCalls that should be added + * @return The same instance of type {@link ChatCompletionRequestMessageFunction} + */ + @Nonnull + public ChatCompletionRequestMessageFunction addToolCallsItem( + @Nonnull final ChatCompletionMessageToolCall toolCallsItem) { + if (this.toolCalls == null) { + this.toolCalls = new ArrayList<>(); + } + this.toolCalls.add(toolCallsItem); + return this; + } + + /** + * The tool calls generated by the model, such as function calls. + * + * @return toolCalls The toolCalls of this {@link ChatCompletionRequestMessageFunction} instance. + */ + @Nonnull + public List getToolCalls() { + return toolCalls; + } + + /** + * Set the toolCalls of this {@link ChatCompletionRequestMessageFunction} instance. + * + * @param toolCalls The tool calls generated by the model, such as function calls. + */ + public void setToolCalls(@Nullable final List toolCalls) { + this.toolCalls = toolCalls; + } + + /** + * Set the functionCall of this {@link ChatCompletionRequestMessageFunction} instance and return + * the same instance. + * + * @param functionCall The functionCall of this {@link ChatCompletionRequestMessageFunction} + * @return The same instance of this {@link ChatCompletionRequestMessageFunction} class + */ + @Nonnull + public ChatCompletionRequestMessageFunction functionCall( + @Nullable final ChatCompletionRequestAssistantMessageFunctionCall functionCall) { + this.functionCall = functionCall; + return this; + } + + /** + * Get functionCall + * + * @return functionCall The functionCall of this {@link ChatCompletionRequestMessageFunction} + * instance. + * @deprecated + */ + @Deprecated + @Nullable + public ChatCompletionRequestAssistantMessageFunctionCall getFunctionCall() { + return functionCall; + } + + /** + * Set the functionCall of this {@link ChatCompletionRequestMessageFunction} instance. + * + * @param functionCall The functionCall of this {@link ChatCompletionRequestMessageFunction} + */ + public void setFunctionCall( + @Nullable final ChatCompletionRequestAssistantMessageFunctionCall functionCall) { + this.functionCall = functionCall; + } + + /** + * Set the toolCallId of this {@link ChatCompletionRequestMessageFunction} instance and return the + * same instance. + * + * @param toolCallId Tool call that this message is responding to. + * @return The same instance of this {@link ChatCompletionRequestMessageFunction} class + */ + @Nonnull + public ChatCompletionRequestMessageFunction toolCallId(@Nonnull final String toolCallId) { + this.toolCallId = toolCallId; + return this; + } + + /** + * Tool call that this message is responding to. + * + * @return toolCallId The toolCallId of this {@link ChatCompletionRequestMessageFunction} + * instance. + */ + @Nonnull + public String getToolCallId() { + return toolCallId; + } + + /** + * Set the toolCallId of this {@link ChatCompletionRequestMessageFunction} instance. + * + * @param toolCallId Tool call that this message is responding to. + */ + public void setToolCallId(@Nonnull final String toolCallId) { + this.toolCallId = toolCallId; + } + + /** + * Get the names of the unrecognizable properties of the {@link + * ChatCompletionRequestMessageFunction}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link + * ChatCompletionRequestMessageFunction} instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ChatCompletionRequestMessageFunction has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ChatCompletionRequestMessageFunction} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ChatCompletionRequestMessageFunction chatCompletionRequestMessageFunction = + (ChatCompletionRequestMessageFunction) o; + return Objects.equals( + this.cloudSdkCustomFields, chatCompletionRequestMessageFunction.cloudSdkCustomFields) + && Objects.equals(this.content, chatCompletionRequestMessageFunction.content) + && Objects.equals(this.role, chatCompletionRequestMessageFunction.role) + && Objects.equals(this.name, chatCompletionRequestMessageFunction.name) + && Objects.equals(this.refusal, chatCompletionRequestMessageFunction.refusal) + && Objects.equals(this.toolCalls, chatCompletionRequestMessageFunction.toolCalls) + && Objects.equals(this.functionCall, chatCompletionRequestMessageFunction.functionCall) + && Objects.equals(this.toolCallId, chatCompletionRequestMessageFunction.toolCallId); + } + + @Override + public int hashCode() { + return Objects.hash( + content, role, name, refusal, toolCalls, functionCall, toolCallId, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ChatCompletionRequestMessageFunction {\n"); + sb.append(" content: ").append(toIndentedString(content)).append("\n"); + sb.append(" role: ").append(toIndentedString(role)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" refusal: ").append(toIndentedString(refusal)).append("\n"); + sb.append(" toolCalls: ").append(toIndentedString(toolCalls)).append("\n"); + sb.append(" functionCall: ").append(toIndentedString(functionCall)).append("\n"); + sb.append(" toolCallId: ").append(toIndentedString(toolCallId)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestMessageTool.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestMessageTool.java new file mode 100644 index 000000000..c28bd03ab --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestMessageTool.java @@ -0,0 +1,457 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** ChatCompletionRequestMessageTool */ +// CHECKSTYLE:OFF +public class ChatCompletionRequestMessageTool +// CHECKSTYLE:ON +{ + @JsonProperty("content") + private String content; + + /** The role of the messages author, in this case `function`. */ + public enum RoleEnum { + /** The FUNCTION option of this ChatCompletionRequestMessageTool */ + FUNCTION("function"); + + private String value; + + RoleEnum(String value) { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value The String value + * @return The enum value of type ChatCompletionRequestMessageTool + */ + @JsonCreator + @Nonnull + public static RoleEnum fromValue(@Nonnull final String value) { + for (RoleEnum b : RoleEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("role") + private RoleEnum role; + + @JsonProperty("name") + private String name; + + @JsonProperty("refusal") + private String refusal; + + @JsonProperty("tool_calls") + private List toolCalls = new ArrayList<>(); + + @JsonProperty("function_call") + private ChatCompletionRequestAssistantMessageFunctionCall functionCall; + + @JsonProperty("tool_call_id") + private String toolCallId; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the content of this {@link ChatCompletionRequestMessageTool} instance and return the same + * instance. + * + * @param content The contents of the message. + * @return The same instance of this {@link ChatCompletionRequestMessageTool} class + */ + @Nonnull + public ChatCompletionRequestMessageTool content(@Nullable final String content) { + this.content = content; + return this; + } + + /** + * The contents of the message. + * + * @return content The content of this {@link ChatCompletionRequestMessageTool} instance. + */ + @Nullable + public String getContent() { + return content; + } + + /** + * Set the content of this {@link ChatCompletionRequestMessageTool} instance. + * + * @param content The contents of the message. + */ + public void setContent(@Nullable final String content) { + this.content = content; + } + + /** + * Set the role of this {@link ChatCompletionRequestMessageTool} instance and return the same + * instance. + * + * @param role The role of the messages author, in this case `function`. + * @return The same instance of this {@link ChatCompletionRequestMessageTool} class + */ + @Nonnull + public ChatCompletionRequestMessageTool role(@Nonnull final RoleEnum role) { + this.role = role; + return this; + } + + /** + * The role of the messages author, in this case `function`. + * + * @return role The role of this {@link ChatCompletionRequestMessageTool} instance. + */ + @Nonnull + public RoleEnum getRole() { + return role; + } + + /** + * Set the role of this {@link ChatCompletionRequestMessageTool} instance. + * + * @param role The role of the messages author, in this case `function`. + */ + public void setRole(@Nonnull final RoleEnum role) { + this.role = role; + } + + /** + * Set the name of this {@link ChatCompletionRequestMessageTool} instance and return the same + * instance. + * + * @param name The name of the function to call. + * @return The same instance of this {@link ChatCompletionRequestMessageTool} class + */ + @Nonnull + public ChatCompletionRequestMessageTool name(@Nonnull final String name) { + this.name = name; + return this; + } + + /** + * The name of the function to call. + * + * @return name The name of this {@link ChatCompletionRequestMessageTool} instance. + */ + @Nonnull + public String getName() { + return name; + } + + /** + * Set the name of this {@link ChatCompletionRequestMessageTool} instance. + * + * @param name The name of the function to call. + */ + public void setName(@Nonnull final String name) { + this.name = name; + } + + /** + * Set the refusal of this {@link ChatCompletionRequestMessageTool} instance and return the same + * instance. + * + * @param refusal The refusal message by the assistant. + * @return The same instance of this {@link ChatCompletionRequestMessageTool} class + */ + @Nonnull + public ChatCompletionRequestMessageTool refusal(@Nullable final String refusal) { + this.refusal = refusal; + return this; + } + + /** + * The refusal message by the assistant. + * + * @return refusal The refusal of this {@link ChatCompletionRequestMessageTool} instance. + */ + @Nullable + public String getRefusal() { + return refusal; + } + + /** + * Set the refusal of this {@link ChatCompletionRequestMessageTool} instance. + * + * @param refusal The refusal message by the assistant. + */ + public void setRefusal(@Nullable final String refusal) { + this.refusal = refusal; + } + + /** + * Set the toolCalls of this {@link ChatCompletionRequestMessageTool} instance and return the same + * instance. + * + * @param toolCalls The tool calls generated by the model, such as function calls. + * @return The same instance of this {@link ChatCompletionRequestMessageTool} class + */ + @Nonnull + public ChatCompletionRequestMessageTool toolCalls( + @Nullable final List toolCalls) { + this.toolCalls = toolCalls; + return this; + } + + /** + * Add one toolCalls instance to this {@link ChatCompletionRequestMessageTool}. + * + * @param toolCallsItem The toolCalls that should be added + * @return The same instance of type {@link ChatCompletionRequestMessageTool} + */ + @Nonnull + public ChatCompletionRequestMessageTool addToolCallsItem( + @Nonnull final ChatCompletionMessageToolCall toolCallsItem) { + if (this.toolCalls == null) { + this.toolCalls = new ArrayList<>(); + } + this.toolCalls.add(toolCallsItem); + return this; + } + + /** + * The tool calls generated by the model, such as function calls. + * + * @return toolCalls The toolCalls of this {@link ChatCompletionRequestMessageTool} instance. + */ + @Nonnull + public List getToolCalls() { + return toolCalls; + } + + /** + * Set the toolCalls of this {@link ChatCompletionRequestMessageTool} instance. + * + * @param toolCalls The tool calls generated by the model, such as function calls. + */ + public void setToolCalls(@Nullable final List toolCalls) { + this.toolCalls = toolCalls; + } + + /** + * Set the functionCall of this {@link ChatCompletionRequestMessageTool} instance and return the + * same instance. + * + * @param functionCall The functionCall of this {@link ChatCompletionRequestMessageTool} + * @return The same instance of this {@link ChatCompletionRequestMessageTool} class + */ + @Nonnull + public ChatCompletionRequestMessageTool functionCall( + @Nullable final ChatCompletionRequestAssistantMessageFunctionCall functionCall) { + this.functionCall = functionCall; + return this; + } + + /** + * Get functionCall + * + * @return functionCall The functionCall of this {@link ChatCompletionRequestMessageTool} + * instance. + * @deprecated + */ + @Deprecated + @Nullable + public ChatCompletionRequestAssistantMessageFunctionCall getFunctionCall() { + return functionCall; + } + + /** + * Set the functionCall of this {@link ChatCompletionRequestMessageTool} instance. + * + * @param functionCall The functionCall of this {@link ChatCompletionRequestMessageTool} + */ + public void setFunctionCall( + @Nullable final ChatCompletionRequestAssistantMessageFunctionCall functionCall) { + this.functionCall = functionCall; + } + + /** + * Set the toolCallId of this {@link ChatCompletionRequestMessageTool} instance and return the + * same instance. + * + * @param toolCallId Tool call that this message is responding to. + * @return The same instance of this {@link ChatCompletionRequestMessageTool} class + */ + @Nonnull + public ChatCompletionRequestMessageTool toolCallId(@Nonnull final String toolCallId) { + this.toolCallId = toolCallId; + return this; + } + + /** + * Tool call that this message is responding to. + * + * @return toolCallId The toolCallId of this {@link ChatCompletionRequestMessageTool} instance. + */ + @Nonnull + public String getToolCallId() { + return toolCallId; + } + + /** + * Set the toolCallId of this {@link ChatCompletionRequestMessageTool} instance. + * + * @param toolCallId Tool call that this message is responding to. + */ + public void setToolCallId(@Nonnull final String toolCallId) { + this.toolCallId = toolCallId; + } + + /** + * Get the names of the unrecognizable properties of the {@link ChatCompletionRequestMessageTool}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ChatCompletionRequestMessageTool} + * instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ChatCompletionRequestMessageTool has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ChatCompletionRequestMessageTool} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ChatCompletionRequestMessageTool chatCompletionRequestMessageTool = + (ChatCompletionRequestMessageTool) o; + return Objects.equals( + this.cloudSdkCustomFields, chatCompletionRequestMessageTool.cloudSdkCustomFields) + && Objects.equals(this.content, chatCompletionRequestMessageTool.content) + && Objects.equals(this.role, chatCompletionRequestMessageTool.role) + && Objects.equals(this.name, chatCompletionRequestMessageTool.name) + && Objects.equals(this.refusal, chatCompletionRequestMessageTool.refusal) + && Objects.equals(this.toolCalls, chatCompletionRequestMessageTool.toolCalls) + && Objects.equals(this.functionCall, chatCompletionRequestMessageTool.functionCall) + && Objects.equals(this.toolCallId, chatCompletionRequestMessageTool.toolCallId); + } + + @Override + public int hashCode() { + return Objects.hash( + content, role, name, refusal, toolCalls, functionCall, toolCallId, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ChatCompletionRequestMessageTool {\n"); + sb.append(" content: ").append(toIndentedString(content)).append("\n"); + sb.append(" role: ").append(toIndentedString(role)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" refusal: ").append(toIndentedString(refusal)).append("\n"); + sb.append(" toolCalls: ").append(toIndentedString(toolCalls)).append("\n"); + sb.append(" functionCall: ").append(toIndentedString(functionCall)).append("\n"); + sb.append(" toolCallId: ").append(toIndentedString(toolCallId)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestSystemMessage.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestSystemMessage.java new file mode 100644 index 000000000..9bf745c07 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestSystemMessage.java @@ -0,0 +1,289 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +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; + +/** ChatCompletionRequestSystemMessage */ +// CHECKSTYLE:OFF +public class ChatCompletionRequestSystemMessage implements ChatCompletionRequestMessage +// CHECKSTYLE:ON +{ + @JsonProperty("content") + private ChatCompletionRequestSystemMessageContent content; + + /** The role of the messages author, in this case `system`. */ + public enum RoleEnum { + /** The SYSTEM option of this ChatCompletionRequestSystemMessage */ + SYSTEM("system"); + + private String value; + + RoleEnum(String value) { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value The String value + * @return The enum value of type ChatCompletionRequestSystemMessage + */ + @JsonCreator + @Nonnull + public static RoleEnum fromValue(@Nonnull final String value) { + for (RoleEnum b : RoleEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("role") + private RoleEnum role; + + @JsonProperty("name") + private String name; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the content of this {@link ChatCompletionRequestSystemMessage} instance and return the same + * instance. + * + * @param content The content of this {@link ChatCompletionRequestSystemMessage} + * @return The same instance of this {@link ChatCompletionRequestSystemMessage} class + */ + @Nonnull + public ChatCompletionRequestSystemMessage content( + @Nonnull final ChatCompletionRequestSystemMessageContent content) { + this.content = content; + return this; + } + + /** + * Get content + * + * @return content The content of this {@link ChatCompletionRequestSystemMessage} instance. + */ + @Nonnull + public ChatCompletionRequestSystemMessageContent getContent() { + return content; + } + + /** + * Set the content of this {@link ChatCompletionRequestSystemMessage} instance. + * + * @param content The content of this {@link ChatCompletionRequestSystemMessage} + */ + public void setContent(@Nonnull final ChatCompletionRequestSystemMessageContent content) { + this.content = content; + } + + /** + * Set the role of this {@link ChatCompletionRequestSystemMessage} instance and return the same + * instance. + * + * @param role The role of the messages author, in this case `system`. + * @return The same instance of this {@link ChatCompletionRequestSystemMessage} class + */ + @Nonnull + public ChatCompletionRequestSystemMessage role(@Nonnull final RoleEnum role) { + this.role = role; + return this; + } + + /** + * The role of the messages author, in this case `system`. + * + * @return role The role of this {@link ChatCompletionRequestSystemMessage} instance. + */ + @Nonnull + public RoleEnum getRole() { + return role; + } + + /** + * Set the role of this {@link ChatCompletionRequestSystemMessage} instance. + * + * @param role The role of the messages author, in this case `system`. + */ + public void setRole(@Nonnull final RoleEnum role) { + this.role = role; + } + + /** + * Set the name of this {@link ChatCompletionRequestSystemMessage} instance and return the same + * instance. + * + * @param name An optional name for the participant. Provides the model information to + * differentiate between participants of the same role. + * @return The same instance of this {@link ChatCompletionRequestSystemMessage} class + */ + @Nonnull + public ChatCompletionRequestSystemMessage name(@Nullable final String name) { + this.name = name; + return this; + } + + /** + * An optional name for the participant. Provides the model information to differentiate between + * participants of the same role. + * + * @return name The name of this {@link ChatCompletionRequestSystemMessage} instance. + */ + @Nonnull + public String getName() { + return name; + } + + /** + * Set the name of this {@link ChatCompletionRequestSystemMessage} instance. + * + * @param name An optional name for the participant. Provides the model information to + * differentiate between participants of the same role. + */ + public void setName(@Nullable final String name) { + this.name = name; + } + + /** + * Get the names of the unrecognizable properties of the {@link + * ChatCompletionRequestSystemMessage}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ChatCompletionRequestSystemMessage} + * instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ChatCompletionRequestSystemMessage has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ChatCompletionRequestSystemMessage} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ChatCompletionRequestSystemMessage chatCompletionRequestSystemMessage = + (ChatCompletionRequestSystemMessage) o; + return Objects.equals( + this.cloudSdkCustomFields, chatCompletionRequestSystemMessage.cloudSdkCustomFields) + && Objects.equals(this.content, chatCompletionRequestSystemMessage.content) + && Objects.equals(this.role, chatCompletionRequestSystemMessage.role) + && Objects.equals(this.name, chatCompletionRequestSystemMessage.name); + } + + @Override + public int hashCode() { + return Objects.hash(content, role, name, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ChatCompletionRequestSystemMessage {\n"); + sb.append(" content: ").append(toIndentedString(content)).append("\n"); + sb.append(" role: ").append(toIndentedString(role)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestSystemMessageContent.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestSystemMessageContent.java new file mode 100644 index 000000000..ddfe0f786 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestSystemMessageContent.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import java.util.List; + +/** The contents of the system message. */ +public interface ChatCompletionRequestSystemMessageContent { + /** + * Helper class to create a String that implements {@link + * ChatCompletionRequestSystemMessageContent}. + */ + record InnerString(@com.fasterxml.jackson.annotation.JsonValue String value) + implements ChatCompletionRequestSystemMessageContent {} + + /** + * Creator to enable deserialization of a String. + * + * @param val the value to use + * @return a new instance of {@link InnerString}. + */ + @com.fasterxml.jackson.annotation.JsonCreator + static InnerString create(String val) { + return new InnerString(val); + } + + /** + * Helper class to create a list of ChatCompletionRequestSystemMessageContentPart that implements + * {@link ChatCompletionRequestSystemMessageContent}. + */ + record InnerChatCompletionRequestSystemMessageContentParts( + @com.fasterxml.jackson.annotation.JsonValue + List values) + implements ChatCompletionRequestSystemMessageContent {} + + /** + * Creator to enable deserialization of a list of ChatCompletionRequestSystemMessageContentPart. + * + * @param val the value to use + * @return a new instance of {@link InnerChatCompletionRequestSystemMessageContentParts}. + */ + @com.fasterxml.jackson.annotation.JsonCreator + static InnerChatCompletionRequestSystemMessageContentParts create( + List val) { + return new InnerChatCompletionRequestSystemMessageContentParts(val); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestSystemMessageContentPart.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestSystemMessageContentPart.java new file mode 100644 index 000000000..a9bd07d2a --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestSystemMessageContentPart.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +/** ChatCompletionRequestSystemMessageContentPart */ +@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChatCompletionRequestMessageContentPartText.class), +}) +public interface ChatCompletionRequestSystemMessageContentPart {} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestToolMessage.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestToolMessage.java new file mode 100644 index 000000000..be7a4d865 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestToolMessage.java @@ -0,0 +1,285 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +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; + +/** ChatCompletionRequestToolMessage */ +// CHECKSTYLE:OFF +public class ChatCompletionRequestToolMessage implements ChatCompletionRequestMessage +// CHECKSTYLE:ON +{ + /** The role of the messages author, in this case `tool`. */ + public enum RoleEnum { + /** The TOOL option of this ChatCompletionRequestToolMessage */ + TOOL("tool"); + + private String value; + + RoleEnum(String value) { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value The String value + * @return The enum value of type ChatCompletionRequestToolMessage + */ + @JsonCreator + @Nonnull + public static RoleEnum fromValue(@Nonnull final String value) { + for (RoleEnum b : RoleEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("role") + private RoleEnum role; + + @JsonProperty("content") + private ChatCompletionRequestToolMessageContent content; + + @JsonProperty("tool_call_id") + private String toolCallId; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the role of this {@link ChatCompletionRequestToolMessage} instance and return the same + * instance. + * + * @param role The role of the messages author, in this case `tool`. + * @return The same instance of this {@link ChatCompletionRequestToolMessage} class + */ + @Nonnull + public ChatCompletionRequestToolMessage role(@Nonnull final RoleEnum role) { + this.role = role; + return this; + } + + /** + * The role of the messages author, in this case `tool`. + * + * @return role The role of this {@link ChatCompletionRequestToolMessage} instance. + */ + @Nonnull + public RoleEnum getRole() { + return role; + } + + /** + * Set the role of this {@link ChatCompletionRequestToolMessage} instance. + * + * @param role The role of the messages author, in this case `tool`. + */ + public void setRole(@Nonnull final RoleEnum role) { + this.role = role; + } + + /** + * Set the content of this {@link ChatCompletionRequestToolMessage} instance and return the same + * instance. + * + * @param content The content of this {@link ChatCompletionRequestToolMessage} + * @return The same instance of this {@link ChatCompletionRequestToolMessage} class + */ + @Nonnull + public ChatCompletionRequestToolMessage content( + @Nonnull final ChatCompletionRequestToolMessageContent content) { + this.content = content; + return this; + } + + /** + * Get content + * + * @return content The content of this {@link ChatCompletionRequestToolMessage} instance. + */ + @Nonnull + public ChatCompletionRequestToolMessageContent getContent() { + return content; + } + + /** + * Set the content of this {@link ChatCompletionRequestToolMessage} instance. + * + * @param content The content of this {@link ChatCompletionRequestToolMessage} + */ + public void setContent(@Nonnull final ChatCompletionRequestToolMessageContent content) { + this.content = content; + } + + /** + * Set the toolCallId of this {@link ChatCompletionRequestToolMessage} instance and return the + * same instance. + * + * @param toolCallId Tool call that this message is responding to. + * @return The same instance of this {@link ChatCompletionRequestToolMessage} class + */ + @Nonnull + public ChatCompletionRequestToolMessage toolCallId(@Nonnull final String toolCallId) { + this.toolCallId = toolCallId; + return this; + } + + /** + * Tool call that this message is responding to. + * + * @return toolCallId The toolCallId of this {@link ChatCompletionRequestToolMessage} instance. + */ + @Nonnull + public String getToolCallId() { + return toolCallId; + } + + /** + * Set the toolCallId of this {@link ChatCompletionRequestToolMessage} instance. + * + * @param toolCallId Tool call that this message is responding to. + */ + public void setToolCallId(@Nonnull final String toolCallId) { + this.toolCallId = toolCallId; + } + + /** + * Get the names of the unrecognizable properties of the {@link ChatCompletionRequestToolMessage}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ChatCompletionRequestToolMessage} + * instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ChatCompletionRequestToolMessage has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ChatCompletionRequestToolMessage} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ChatCompletionRequestToolMessage chatCompletionRequestToolMessage = + (ChatCompletionRequestToolMessage) o; + return Objects.equals( + this.cloudSdkCustomFields, chatCompletionRequestToolMessage.cloudSdkCustomFields) + && Objects.equals(this.role, chatCompletionRequestToolMessage.role) + && Objects.equals(this.content, chatCompletionRequestToolMessage.content) + && Objects.equals(this.toolCallId, chatCompletionRequestToolMessage.toolCallId); + } + + @Override + public int hashCode() { + return Objects.hash(role, content, toolCallId, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ChatCompletionRequestToolMessage {\n"); + sb.append(" role: ").append(toIndentedString(role)).append("\n"); + sb.append(" content: ").append(toIndentedString(content)).append("\n"); + sb.append(" toolCallId: ").append(toIndentedString(toolCallId)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestToolMessageContent.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestToolMessageContent.java new file mode 100644 index 000000000..edab8187b --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestToolMessageContent.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import java.util.List; + +/** The contents of the tool message. */ +public interface ChatCompletionRequestToolMessageContent { + /** + * Helper class to create a String that implements {@link + * ChatCompletionRequestToolMessageContent}. + */ + record InnerString(@com.fasterxml.jackson.annotation.JsonValue String value) + implements ChatCompletionRequestToolMessageContent {} + + /** + * Creator to enable deserialization of a String. + * + * @param val the value to use + * @return a new instance of {@link InnerString}. + */ + @com.fasterxml.jackson.annotation.JsonCreator + static InnerString create(String val) { + return new InnerString(val); + } + + /** + * Helper class to create a list of ChatCompletionRequestToolMessageContentPart that implements + * {@link ChatCompletionRequestToolMessageContent}. + */ + record InnerChatCompletionRequestToolMessageContentParts( + @com.fasterxml.jackson.annotation.JsonValue + List values) + implements ChatCompletionRequestToolMessageContent {} + + /** + * Creator to enable deserialization of a list of ChatCompletionRequestToolMessageContentPart. + * + * @param val the value to use + * @return a new instance of {@link InnerChatCompletionRequestToolMessageContentParts}. + */ + @com.fasterxml.jackson.annotation.JsonCreator + static InnerChatCompletionRequestToolMessageContentParts create( + List val) { + return new InnerChatCompletionRequestToolMessageContentParts(val); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestToolMessageContentPart.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestToolMessageContentPart.java new file mode 100644 index 000000000..b2bc25f0d --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestToolMessageContentPart.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +/** ChatCompletionRequestToolMessageContentPart */ +@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChatCompletionRequestMessageContentPartText.class), +}) +public interface ChatCompletionRequestToolMessageContentPart {} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestUserMessage.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestUserMessage.java new file mode 100644 index 000000000..a92b34e48 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestUserMessage.java @@ -0,0 +1,288 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +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; + +/** ChatCompletionRequestUserMessage */ +// CHECKSTYLE:OFF +public class ChatCompletionRequestUserMessage implements ChatCompletionRequestMessage +// CHECKSTYLE:ON +{ + @JsonProperty("content") + private ChatCompletionRequestUserMessageContent content; + + /** The role of the messages author, in this case `user`. */ + public enum RoleEnum { + /** The USER option of this ChatCompletionRequestUserMessage */ + USER("user"); + + private String value; + + RoleEnum(String value) { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value The String value + * @return The enum value of type ChatCompletionRequestUserMessage + */ + @JsonCreator + @Nonnull + public static RoleEnum fromValue(@Nonnull final String value) { + for (RoleEnum b : RoleEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("role") + private RoleEnum role; + + @JsonProperty("name") + private String name; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the content of this {@link ChatCompletionRequestUserMessage} instance and return the same + * instance. + * + * @param content The content of this {@link ChatCompletionRequestUserMessage} + * @return The same instance of this {@link ChatCompletionRequestUserMessage} class + */ + @Nonnull + public ChatCompletionRequestUserMessage content( + @Nonnull final ChatCompletionRequestUserMessageContent content) { + this.content = content; + return this; + } + + /** + * Get content + * + * @return content The content of this {@link ChatCompletionRequestUserMessage} instance. + */ + @Nonnull + public ChatCompletionRequestUserMessageContent getContent() { + return content; + } + + /** + * Set the content of this {@link ChatCompletionRequestUserMessage} instance. + * + * @param content The content of this {@link ChatCompletionRequestUserMessage} + */ + public void setContent(@Nonnull final ChatCompletionRequestUserMessageContent content) { + this.content = content; + } + + /** + * Set the role of this {@link ChatCompletionRequestUserMessage} instance and return the same + * instance. + * + * @param role The role of the messages author, in this case `user`. + * @return The same instance of this {@link ChatCompletionRequestUserMessage} class + */ + @Nonnull + public ChatCompletionRequestUserMessage role(@Nonnull final RoleEnum role) { + this.role = role; + return this; + } + + /** + * The role of the messages author, in this case `user`. + * + * @return role The role of this {@link ChatCompletionRequestUserMessage} instance. + */ + @Nonnull + public RoleEnum getRole() { + return role; + } + + /** + * Set the role of this {@link ChatCompletionRequestUserMessage} instance. + * + * @param role The role of the messages author, in this case `user`. + */ + public void setRole(@Nonnull final RoleEnum role) { + this.role = role; + } + + /** + * Set the name of this {@link ChatCompletionRequestUserMessage} instance and return the same + * instance. + * + * @param name An optional name for the participant. Provides the model information to + * differentiate between participants of the same role. + * @return The same instance of this {@link ChatCompletionRequestUserMessage} class + */ + @Nonnull + public ChatCompletionRequestUserMessage name(@Nullable final String name) { + this.name = name; + return this; + } + + /** + * An optional name for the participant. Provides the model information to differentiate between + * participants of the same role. + * + * @return name The name of this {@link ChatCompletionRequestUserMessage} instance. + */ + @Nonnull + public String getName() { + return name; + } + + /** + * Set the name of this {@link ChatCompletionRequestUserMessage} instance. + * + * @param name An optional name for the participant. Provides the model information to + * differentiate between participants of the same role. + */ + public void setName(@Nullable final String name) { + this.name = name; + } + + /** + * Get the names of the unrecognizable properties of the {@link ChatCompletionRequestUserMessage}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ChatCompletionRequestUserMessage} + * instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ChatCompletionRequestUserMessage has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ChatCompletionRequestUserMessage} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ChatCompletionRequestUserMessage chatCompletionRequestUserMessage = + (ChatCompletionRequestUserMessage) o; + return Objects.equals( + this.cloudSdkCustomFields, chatCompletionRequestUserMessage.cloudSdkCustomFields) + && Objects.equals(this.content, chatCompletionRequestUserMessage.content) + && Objects.equals(this.role, chatCompletionRequestUserMessage.role) + && Objects.equals(this.name, chatCompletionRequestUserMessage.name); + } + + @Override + public int hashCode() { + return Objects.hash(content, role, name, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ChatCompletionRequestUserMessage {\n"); + sb.append(" content: ").append(toIndentedString(content)).append("\n"); + sb.append(" role: ").append(toIndentedString(role)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestUserMessageContent.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestUserMessageContent.java new file mode 100644 index 000000000..4fa32ac29 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestUserMessageContent.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import java.util.List; + +/** The contents of the user message. */ +public interface ChatCompletionRequestUserMessageContent { + /** + * Helper class to create a String that implements {@link + * ChatCompletionRequestUserMessageContent}. + */ + record InnerString(@com.fasterxml.jackson.annotation.JsonValue String value) + implements ChatCompletionRequestUserMessageContent {} + + /** + * Creator to enable deserialization of a String. + * + * @param val the value to use + * @return a new instance of {@link InnerString}. + */ + @com.fasterxml.jackson.annotation.JsonCreator + static InnerString create(String val) { + return new InnerString(val); + } + + /** + * Helper class to create a list of ChatCompletionRequestUserMessageContentPart that implements + * {@link ChatCompletionRequestUserMessageContent}. + */ + record InnerChatCompletionRequestUserMessageContentParts( + @com.fasterxml.jackson.annotation.JsonValue + List values) + implements ChatCompletionRequestUserMessageContent {} + + /** + * Creator to enable deserialization of a list of ChatCompletionRequestUserMessageContentPart. + * + * @param val the value to use + * @return a new instance of {@link InnerChatCompletionRequestUserMessageContentParts}. + */ + @com.fasterxml.jackson.annotation.JsonCreator + static InnerChatCompletionRequestUserMessageContentParts create( + List val) { + return new InnerChatCompletionRequestUserMessageContentParts(val); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestUserMessageContentPart.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestUserMessageContentPart.java new file mode 100644 index 000000000..87397c501 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionRequestUserMessageContentPart.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +/** ChatCompletionRequestUserMessageContentPart */ +@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ChatCompletionRequestMessageContentPartImage.class), + @JsonSubTypes.Type(value = ChatCompletionRequestMessageContentPartText.class), +}) +public interface ChatCompletionRequestUserMessageContentPart {} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionResponseMessage.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionResponseMessage.java new file mode 100644 index 000000000..78493bf37 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionResponseMessage.java @@ -0,0 +1,328 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** A chat completion message generated by the model. */ +// CHECKSTYLE:OFF +public class ChatCompletionResponseMessage +// CHECKSTYLE:ON +{ + @JsonProperty("role") + private ChatCompletionResponseMessageRole role; + + @JsonProperty("refusal") + private String refusal; + + @JsonProperty("content") + private String content; + + @JsonProperty("tool_calls") + private List toolCalls = new ArrayList<>(); + + @JsonProperty("function_call") + private ChatCompletionFunctionCall functionCall; + + // @JsonProperty("context") // TODO: add context + // private AzureChatExtensionsMessageContext context; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the role of this {@link ChatCompletionResponseMessage} instance and return the same + * instance. + * + * @param role The role of this {@link ChatCompletionResponseMessage} + * @return The same instance of this {@link ChatCompletionResponseMessage} class + */ + @Nonnull + public ChatCompletionResponseMessage role(@Nonnull final ChatCompletionResponseMessageRole role) { + this.role = role; + return this; + } + + /** + * Get role + * + * @return role The role of this {@link ChatCompletionResponseMessage} instance. + */ + @Nonnull + public ChatCompletionResponseMessageRole getRole() { + return role; + } + + /** + * Set the role of this {@link ChatCompletionResponseMessage} instance. + * + * @param role The role of this {@link ChatCompletionResponseMessage} + */ + public void setRole(@Nonnull final ChatCompletionResponseMessageRole role) { + this.role = role; + } + + /** + * Set the refusal of this {@link ChatCompletionResponseMessage} instance and return the same + * instance. + * + * @param refusal The refusal message generated by the model. + * @return The same instance of this {@link ChatCompletionResponseMessage} class + */ + @Nonnull + public ChatCompletionResponseMessage refusal(@Nullable final String refusal) { + this.refusal = refusal; + return this; + } + + /** + * The refusal message generated by the model. + * + * @return refusal The refusal of this {@link ChatCompletionResponseMessage} instance. + */ + @Nullable + public String getRefusal() { + return refusal; + } + + /** + * Set the refusal of this {@link ChatCompletionResponseMessage} instance. + * + * @param refusal The refusal message generated by the model. + */ + public void setRefusal(@Nullable final String refusal) { + this.refusal = refusal; + } + + /** + * Set the content of this {@link ChatCompletionResponseMessage} instance and return the same + * instance. + * + * @param content The contents of the message. + * @return The same instance of this {@link ChatCompletionResponseMessage} class + */ + @Nonnull + public ChatCompletionResponseMessage content(@Nullable final String content) { + this.content = content; + return this; + } + + /** + * The contents of the message. + * + * @return content The content of this {@link ChatCompletionResponseMessage} instance. + */ + @Nullable + public String getContent() { + return content; + } + + /** + * Set the content of this {@link ChatCompletionResponseMessage} instance. + * + * @param content The contents of the message. + */ + public void setContent(@Nullable final String content) { + this.content = content; + } + + /** + * Set the toolCalls of this {@link ChatCompletionResponseMessage} instance and return the same + * instance. + * + * @param toolCalls The tool calls generated by the model, such as function calls. + * @return The same instance of this {@link ChatCompletionResponseMessage} class + */ + @Nonnull + public ChatCompletionResponseMessage toolCalls( + @Nullable final List toolCalls) { + this.toolCalls = toolCalls; + return this; + } + + /** + * Add one toolCalls instance to this {@link ChatCompletionResponseMessage}. + * + * @param toolCallsItem The toolCalls that should be added + * @return The same instance of type {@link ChatCompletionResponseMessage} + */ + @Nonnull + public ChatCompletionResponseMessage addToolCallsItem( + @Nonnull final ChatCompletionMessageToolCall toolCallsItem) { + if (this.toolCalls == null) { + this.toolCalls = new ArrayList<>(); + } + this.toolCalls.add(toolCallsItem); + return this; + } + + /** + * The tool calls generated by the model, such as function calls. + * + * @return toolCalls The toolCalls of this {@link ChatCompletionResponseMessage} instance. + */ + @Nonnull + public List getToolCalls() { + return toolCalls; + } + + /** + * Set the toolCalls of this {@link ChatCompletionResponseMessage} instance. + * + * @param toolCalls The tool calls generated by the model, such as function calls. + */ + public void setToolCalls(@Nullable final List toolCalls) { + this.toolCalls = toolCalls; + } + + /** + * Set the functionCall of this {@link ChatCompletionResponseMessage} instance and return the same + * instance. + * + * @param functionCall The functionCall of this {@link ChatCompletionResponseMessage} + * @return The same instance of this {@link ChatCompletionResponseMessage} class + */ + @Nonnull + public ChatCompletionResponseMessage functionCall( + @Nullable final ChatCompletionFunctionCall functionCall) { + this.functionCall = functionCall; + return this; + } + + /** + * Get functionCall + * + * @return functionCall The functionCall of this {@link ChatCompletionResponseMessage} instance. + */ + @Nonnull + public ChatCompletionFunctionCall getFunctionCall() { + return functionCall; + } + + /** + * Set the functionCall of this {@link ChatCompletionResponseMessage} instance. + * + * @param functionCall The functionCall of this {@link ChatCompletionResponseMessage} + */ + public void setFunctionCall(@Nullable final ChatCompletionFunctionCall functionCall) { + this.functionCall = functionCall; + } + + /** + * Get the names of the unrecognizable properties of the {@link ChatCompletionResponseMessage}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ChatCompletionResponseMessage} + * instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ChatCompletionResponseMessage has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ChatCompletionResponseMessage} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ChatCompletionResponseMessage chatCompletionResponseMessage = + (ChatCompletionResponseMessage) o; + return Objects.equals( + this.cloudSdkCustomFields, chatCompletionResponseMessage.cloudSdkCustomFields) + && Objects.equals(this.role, chatCompletionResponseMessage.role) + && Objects.equals(this.refusal, chatCompletionResponseMessage.refusal) + && Objects.equals(this.content, chatCompletionResponseMessage.content) + && Objects.equals(this.toolCalls, chatCompletionResponseMessage.toolCalls) + && Objects.equals(this.functionCall, chatCompletionResponseMessage.functionCall); + } + + @Override + public int hashCode() { + return Objects.hash(role, refusal, content, toolCalls, functionCall, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ChatCompletionResponseMessage {\n"); + sb.append(" role: ").append(toIndentedString(role)).append("\n"); + sb.append(" refusal: ").append(toIndentedString(refusal)).append("\n"); + sb.append(" content: ").append(toIndentedString(content)).append("\n"); + sb.append(" toolCalls: ").append(toIndentedString(toolCalls)).append("\n"); + sb.append(" functionCall: ").append(toIndentedString(functionCall)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionResponseMessageRole.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionResponseMessageRole.java new file mode 100644 index 000000000..ae8753288 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionResponseMessageRole.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import javax.annotation.Nonnull; + +/** The role of the author of the response message. */ +public enum ChatCompletionResponseMessageRole { + ASSISTANT("assistant"); + + private final String value; + + ChatCompletionResponseMessageRole(String value) { + this.value = value; + } + + /** + * @return The enum value. + */ + @JsonValue + public String getValue() { + return value; + } + + /** + * @return The String representation of the enum value. + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Converts the given value to its enum representation. + * + * @param value The input value. + * @return The enum representation of the given value. + */ + @JsonCreator + public static ChatCompletionResponseMessageRole fromValue(@Nonnull final String value) { + for (final ChatCompletionResponseMessageRole b : ChatCompletionResponseMessageRole.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionStreamOptions.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionStreamOptions.java new file mode 100644 index 000000000..f4a2ec79a --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionStreamOptions.java @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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; + +/** Options for streaming response. Only set this when you set `stream: true`. */ +// CHECKSTYLE:OFF +public class ChatCompletionStreamOptions +// CHECKSTYLE:ON +{ + @JsonProperty("include_usage") + private Boolean includeUsage; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the includeUsage of this {@link ChatCompletionStreamOptions} instance and return the same + * instance. + * + * @param includeUsage If set, an additional chunk will be streamed before the `data: + * [DONE]` message. The `usage` field on this chunk shows the token usage + * statistics for the entire request, and the `choices` field will always be an + * empty array. All other chunks will also include a `usage` field, but with a null + * value. + * @return The same instance of this {@link ChatCompletionStreamOptions} class + */ + @Nonnull + public ChatCompletionStreamOptions includeUsage(@Nullable final Boolean includeUsage) { + this.includeUsage = includeUsage; + return this; + } + + /** + * If set, an additional chunk will be streamed before the `data: [DONE]` message. The + * `usage` field on this chunk shows the token usage statistics for the entire request, + * and the `choices` field will always be an empty array. All other chunks will also + * include a `usage` field, but with a null value. + * + * @return includeUsage The includeUsage of this {@link ChatCompletionStreamOptions} instance. + */ + @Nonnull + public Boolean isIncludeUsage() { + return includeUsage; + } + + /** + * Set the includeUsage of this {@link ChatCompletionStreamOptions} instance. + * + * @param includeUsage If set, an additional chunk will be streamed before the `data: + * [DONE]` message. The `usage` field on this chunk shows the token usage + * statistics for the entire request, and the `choices` field will always be an + * empty array. All other chunks will also include a `usage` field, but with a null + * value. + */ + public void setIncludeUsage(@Nullable final Boolean includeUsage) { + this.includeUsage = includeUsage; + } + + /** + * Get the names of the unrecognizable properties of the {@link ChatCompletionStreamOptions}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ChatCompletionStreamOptions} + * instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ChatCompletionStreamOptions has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ChatCompletionStreamOptions} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ChatCompletionStreamOptions chatCompletionStreamOptions = (ChatCompletionStreamOptions) o; + return Objects.equals( + this.cloudSdkCustomFields, chatCompletionStreamOptions.cloudSdkCustomFields) + && Objects.equals(this.includeUsage, chatCompletionStreamOptions.includeUsage); + } + + @Override + public int hashCode() { + return Objects.hash(includeUsage, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ChatCompletionStreamOptions {\n"); + sb.append(" includeUsage: ").append(toIndentedString(includeUsage)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionStreamResponseDelta.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionStreamResponseDelta.java new file mode 100644 index 000000000..8724ef708 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionStreamResponseDelta.java @@ -0,0 +1,392 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** A chat completion delta generated by streamed model responses. */ +// CHECKSTYLE:OFF +public class ChatCompletionStreamResponseDelta +// CHECKSTYLE:ON +{ + @JsonProperty("content") + private String content; + + @JsonProperty("function_call") + private ChatCompletionStreamResponseDeltaFunctionCall functionCall; + + @JsonProperty("tool_calls") + private List toolCalls = new ArrayList<>(); + + /** The role of the author of this message. */ + public enum RoleEnum { + /** The SYSTEM option of this ChatCompletionStreamResponseDelta */ + SYSTEM("system"), + + /** The USER option of this ChatCompletionStreamResponseDelta */ + USER("user"), + + /** The ASSISTANT option of this ChatCompletionStreamResponseDelta */ + ASSISTANT("assistant"), + + /** The TOOL option of this ChatCompletionStreamResponseDelta */ + TOOL("tool"); + + private String value; + + RoleEnum(String value) { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value The String value + * @return The enum value of type ChatCompletionStreamResponseDelta + */ + @JsonCreator + @Nonnull + public static RoleEnum fromValue(@Nonnull final String value) { + for (RoleEnum b : RoleEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("role") + private RoleEnum role; + + @JsonProperty("refusal") + private String refusal; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the content of this {@link ChatCompletionStreamResponseDelta} instance and return the same + * instance. + * + * @param content The contents of the chunk message. + * @return The same instance of this {@link ChatCompletionStreamResponseDelta} class + */ + @Nonnull + public ChatCompletionStreamResponseDelta content(@Nullable final String content) { + this.content = content; + return this; + } + + /** + * The contents of the chunk message. + * + * @return content The content of this {@link ChatCompletionStreamResponseDelta} instance. + */ + @Nullable + public String getContent() { + return content; + } + + /** + * Set the content of this {@link ChatCompletionStreamResponseDelta} instance. + * + * @param content The contents of the chunk message. + */ + public void setContent(@Nullable final String content) { + this.content = content; + } + + /** + * Set the functionCall of this {@link ChatCompletionStreamResponseDelta} instance and return the + * same instance. + * + * @param functionCall The functionCall of this {@link ChatCompletionStreamResponseDelta} + * @return The same instance of this {@link ChatCompletionStreamResponseDelta} class + */ + @Nonnull + public ChatCompletionStreamResponseDelta functionCall( + @Nullable final ChatCompletionStreamResponseDeltaFunctionCall functionCall) { + this.functionCall = functionCall; + return this; + } + + /** + * Get functionCall + * + * @return functionCall The functionCall of this {@link ChatCompletionStreamResponseDelta} + * instance. + * @deprecated + */ + @Deprecated + @Nonnull + public ChatCompletionStreamResponseDeltaFunctionCall getFunctionCall() { + return functionCall; + } + + /** + * Set the functionCall of this {@link ChatCompletionStreamResponseDelta} instance. + * + * @param functionCall The functionCall of this {@link ChatCompletionStreamResponseDelta} + */ + public void setFunctionCall( + @Nullable final ChatCompletionStreamResponseDeltaFunctionCall functionCall) { + this.functionCall = functionCall; + } + + /** + * Set the toolCalls of this {@link ChatCompletionStreamResponseDelta} instance and return the + * same instance. + * + * @param toolCalls The toolCalls of this {@link ChatCompletionStreamResponseDelta} + * @return The same instance of this {@link ChatCompletionStreamResponseDelta} class + */ + @Nonnull + public ChatCompletionStreamResponseDelta toolCalls( + @Nullable final List toolCalls) { + this.toolCalls = toolCalls; + return this; + } + + /** + * Add one toolCalls instance to this {@link ChatCompletionStreamResponseDelta}. + * + * @param toolCallsItem The toolCalls that should be added + * @return The same instance of type {@link ChatCompletionStreamResponseDelta} + */ + @Nonnull + public ChatCompletionStreamResponseDelta addToolCallsItem( + @Nonnull final ChatCompletionMessageToolCallChunk toolCallsItem) { + if (this.toolCalls == null) { + this.toolCalls = new ArrayList<>(); + } + this.toolCalls.add(toolCallsItem); + return this; + } + + /** + * Get toolCalls + * + * @return toolCalls The toolCalls of this {@link ChatCompletionStreamResponseDelta} instance. + */ + @Nonnull + public List getToolCalls() { + return toolCalls; + } + + /** + * Set the toolCalls of this {@link ChatCompletionStreamResponseDelta} instance. + * + * @param toolCalls The toolCalls of this {@link ChatCompletionStreamResponseDelta} + */ + public void setToolCalls(@Nullable final List toolCalls) { + this.toolCalls = toolCalls; + } + + /** + * Set the role of this {@link ChatCompletionStreamResponseDelta} instance and return the same + * instance. + * + * @param role The role of the author of this message. + * @return The same instance of this {@link ChatCompletionStreamResponseDelta} class + */ + @Nonnull + public ChatCompletionStreamResponseDelta role(@Nullable final RoleEnum role) { + this.role = role; + return this; + } + + /** + * The role of the author of this message. + * + * @return role The role of this {@link ChatCompletionStreamResponseDelta} instance. + */ + @Nonnull + public RoleEnum getRole() { + return role; + } + + /** + * Set the role of this {@link ChatCompletionStreamResponseDelta} instance. + * + * @param role The role of the author of this message. + */ + public void setRole(@Nullable final RoleEnum role) { + this.role = role; + } + + /** + * Set the refusal of this {@link ChatCompletionStreamResponseDelta} instance and return the same + * instance. + * + * @param refusal The refusal message generated by the model. + * @return The same instance of this {@link ChatCompletionStreamResponseDelta} class + */ + @Nonnull + public ChatCompletionStreamResponseDelta refusal(@Nullable final String refusal) { + this.refusal = refusal; + return this; + } + + /** + * The refusal message generated by the model. + * + * @return refusal The refusal of this {@link ChatCompletionStreamResponseDelta} instance. + */ + @Nullable + public String getRefusal() { + return refusal; + } + + /** + * Set the refusal of this {@link ChatCompletionStreamResponseDelta} instance. + * + * @param refusal The refusal message generated by the model. + */ + public void setRefusal(@Nullable final String refusal) { + this.refusal = refusal; + } + + /** + * Get the names of the unrecognizable properties of the {@link + * ChatCompletionStreamResponseDelta}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ChatCompletionStreamResponseDelta} + * instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ChatCompletionStreamResponseDelta has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ChatCompletionStreamResponseDelta} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ChatCompletionStreamResponseDelta chatCompletionStreamResponseDelta = + (ChatCompletionStreamResponseDelta) o; + return Objects.equals( + this.cloudSdkCustomFields, chatCompletionStreamResponseDelta.cloudSdkCustomFields) + && Objects.equals(this.content, chatCompletionStreamResponseDelta.content) + && Objects.equals(this.functionCall, chatCompletionStreamResponseDelta.functionCall) + && Objects.equals(this.toolCalls, chatCompletionStreamResponseDelta.toolCalls) + && Objects.equals(this.role, chatCompletionStreamResponseDelta.role) + && Objects.equals(this.refusal, chatCompletionStreamResponseDelta.refusal); + } + + @Override + public int hashCode() { + return Objects.hash(content, functionCall, toolCalls, role, refusal, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ChatCompletionStreamResponseDelta {\n"); + sb.append(" content: ").append(toIndentedString(content)).append("\n"); + sb.append(" functionCall: ").append(toIndentedString(functionCall)).append("\n"); + sb.append(" toolCalls: ").append(toIndentedString(toolCalls)).append("\n"); + sb.append(" role: ").append(toIndentedString(role)).append("\n"); + sb.append(" refusal: ").append(toIndentedString(refusal)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionStreamResponseDeltaFunctionCall.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionStreamResponseDeltaFunctionCall.java new file mode 100644 index 000000000..32b8767b2 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionStreamResponseDeltaFunctionCall.java @@ -0,0 +1,212 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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; + +/** + * Deprecated and replaced by `tool_calls`. The name and arguments of a function that + * should be called, as generated by the model. + * + * @deprecated + */ +@Deprecated +// CHECKSTYLE:OFF +public class ChatCompletionStreamResponseDeltaFunctionCall +// CHECKSTYLE:ON +{ + @JsonProperty("arguments") + private String arguments; + + @JsonProperty("name") + private String name; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the arguments of this {@link ChatCompletionStreamResponseDeltaFunctionCall} instance and + * return the same instance. + * + * @param arguments The arguments to call the function with, as generated by the model in JSON + * format. Note that the model does not always generate valid JSON, and may hallucinate + * parameters not defined by your function schema. Validate the arguments in your code before + * calling your function. + * @return The same instance of this {@link ChatCompletionStreamResponseDeltaFunctionCall} class + */ + @Nonnull + public ChatCompletionStreamResponseDeltaFunctionCall arguments(@Nullable final String arguments) { + this.arguments = arguments; + return this; + } + + /** + * The arguments to call the function with, as generated by the model in JSON format. Note that + * the model does not always generate valid JSON, and may hallucinate parameters not defined by + * your function schema. Validate the arguments in your code before calling your function. + * + * @return arguments The arguments of this {@link ChatCompletionStreamResponseDeltaFunctionCall} + * instance. + */ + @Nonnull + public String getArguments() { + return arguments; + } + + /** + * Set the arguments of this {@link ChatCompletionStreamResponseDeltaFunctionCall} instance. + * + * @param arguments The arguments to call the function with, as generated by the model in JSON + * format. Note that the model does not always generate valid JSON, and may hallucinate + * parameters not defined by your function schema. Validate the arguments in your code before + * calling your function. + */ + public void setArguments(@Nullable final String arguments) { + this.arguments = arguments; + } + + /** + * Set the name of this {@link ChatCompletionStreamResponseDeltaFunctionCall} instance and return + * the same instance. + * + * @param name The name of the function to call. + * @return The same instance of this {@link ChatCompletionStreamResponseDeltaFunctionCall} class + */ + @Nonnull + public ChatCompletionStreamResponseDeltaFunctionCall name(@Nullable final String name) { + this.name = name; + return this; + } + + /** + * The name of the function to call. + * + * @return name The name of this {@link ChatCompletionStreamResponseDeltaFunctionCall} instance. + */ + @Nonnull + public String getName() { + return name; + } + + /** + * Set the name of this {@link ChatCompletionStreamResponseDeltaFunctionCall} instance. + * + * @param name The name of the function to call. + */ + public void setName(@Nullable final String name) { + this.name = name; + } + + /** + * Get the names of the unrecognizable properties of the {@link + * ChatCompletionStreamResponseDeltaFunctionCall}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link + * ChatCompletionStreamResponseDeltaFunctionCall} instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ChatCompletionStreamResponseDeltaFunctionCall has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ChatCompletionStreamResponseDeltaFunctionCall} + * 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ChatCompletionStreamResponseDeltaFunctionCall + chatCompletionStreamResponseDeltaFunctionCall = + (ChatCompletionStreamResponseDeltaFunctionCall) o; + return Objects.equals( + this.cloudSdkCustomFields, + chatCompletionStreamResponseDeltaFunctionCall.cloudSdkCustomFields) + && Objects.equals(this.arguments, chatCompletionStreamResponseDeltaFunctionCall.arguments) + && Objects.equals(this.name, chatCompletionStreamResponseDeltaFunctionCall.name); + } + + @Override + public int hashCode() { + return Objects.hash(arguments, name, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ChatCompletionStreamResponseDeltaFunctionCall {\n"); + sb.append(" arguments: ").append(toIndentedString(arguments)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionTokenLogprob.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionTokenLogprob.java new file mode 100644 index 000000000..a7bbfcbe0 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionTokenLogprob.java @@ -0,0 +1,314 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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.math.BigDecimal; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** ChatCompletionTokenLogprob */ +// CHECKSTYLE:OFF +public class ChatCompletionTokenLogprob +// CHECKSTYLE:ON +{ + @JsonProperty("token") + private String token; + + @JsonProperty("logprob") + private BigDecimal logprob; + + @JsonProperty("bytes") + private List bytes; + + @JsonProperty("top_logprobs") + private List topLogprobs = new ArrayList<>(); + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the token of this {@link ChatCompletionTokenLogprob} instance and return the same instance. + * + * @param token The token. + * @return The same instance of this {@link ChatCompletionTokenLogprob} class + */ + @Nonnull + public ChatCompletionTokenLogprob token(@Nonnull final String token) { + this.token = token; + return this; + } + + /** + * The token. + * + * @return token The token of this {@link ChatCompletionTokenLogprob} instance. + */ + @Nonnull + public String getToken() { + return token; + } + + /** + * Set the token of this {@link ChatCompletionTokenLogprob} instance. + * + * @param token The token. + */ + public void setToken(@Nonnull final String token) { + this.token = token; + } + + /** + * Set the logprob of this {@link ChatCompletionTokenLogprob} instance and return the same + * instance. + * + * @param logprob The log probability of this token. + * @return The same instance of this {@link ChatCompletionTokenLogprob} class + */ + @Nonnull + public ChatCompletionTokenLogprob logprob(@Nonnull final BigDecimal logprob) { + this.logprob = logprob; + return this; + } + + /** + * The log probability of this token. + * + * @return logprob The logprob of this {@link ChatCompletionTokenLogprob} instance. + */ + @Nonnull + public BigDecimal getLogprob() { + return logprob; + } + + /** + * Set the logprob of this {@link ChatCompletionTokenLogprob} instance. + * + * @param logprob The log probability of this token. + */ + public void setLogprob(@Nonnull final BigDecimal logprob) { + this.logprob = logprob; + } + + /** + * Set the bytes of this {@link ChatCompletionTokenLogprob} instance and return the same instance. + * + * @param bytes A list of integers representing the UTF-8 bytes representation of the token. + * Useful in instances where characters are represented by multiple tokens and their byte + * representations must be combined to generate the correct text representation. Can be + * `null` if there is no bytes representation for the token. + * @return The same instance of this {@link ChatCompletionTokenLogprob} class + */ + @Nonnull + public ChatCompletionTokenLogprob bytes(@Nullable final List bytes) { + this.bytes = bytes; + return this; + } + + /** + * Add one bytes instance to this {@link ChatCompletionTokenLogprob}. + * + * @param bytesItem The bytes that should be added + * @return The same instance of type {@link ChatCompletionTokenLogprob} + */ + @Nonnull + public ChatCompletionTokenLogprob addBytesItem(@Nonnull final Integer bytesItem) { + if (this.bytes == null) { + this.bytes = new ArrayList<>(); + } + this.bytes.add(bytesItem); + return this; + } + + /** + * A list of integers representing the UTF-8 bytes representation of the token. Useful in + * instances where characters are represented by multiple tokens and their byte representations + * must be combined to generate the correct text representation. Can be `null` if there + * is no bytes representation for the token. + * + * @return bytes The bytes of this {@link ChatCompletionTokenLogprob} instance. + */ + @Nullable + public List getBytes() { + return bytes; + } + + /** + * Set the bytes of this {@link ChatCompletionTokenLogprob} instance. + * + * @param bytes A list of integers representing the UTF-8 bytes representation of the token. + * Useful in instances where characters are represented by multiple tokens and their byte + * representations must be combined to generate the correct text representation. Can be + * `null` if there is no bytes representation for the token. + */ + public void setBytes(@Nullable final List bytes) { + this.bytes = bytes; + } + + /** + * Set the topLogprobs of this {@link ChatCompletionTokenLogprob} instance and return the same + * instance. + * + * @param topLogprobs List of the most likely tokens and their log probability, at this token + * position. In rare cases, there may be fewer than the number of requested + * `top_logprobs` returned. + * @return The same instance of this {@link ChatCompletionTokenLogprob} class + */ + @Nonnull + public ChatCompletionTokenLogprob topLogprobs( + @Nonnull final List topLogprobs) { + this.topLogprobs = topLogprobs; + return this; + } + + /** + * Add one topLogprobs instance to this {@link ChatCompletionTokenLogprob}. + * + * @param topLogprobsItem The topLogprobs that should be added + * @return The same instance of type {@link ChatCompletionTokenLogprob} + */ + @Nonnull + public ChatCompletionTokenLogprob addTopLogprobsItem( + @Nonnull final ChatCompletionTokenLogprobTopLogprobsInner topLogprobsItem) { + if (this.topLogprobs == null) { + this.topLogprobs = new ArrayList<>(); + } + this.topLogprobs.add(topLogprobsItem); + return this; + } + + /** + * List of the most likely tokens and their log probability, at this token position. In rare + * cases, there may be fewer than the number of requested `top_logprobs` returned. + * + * @return topLogprobs The topLogprobs of this {@link ChatCompletionTokenLogprob} instance. + */ + @Nonnull + public List getTopLogprobs() { + return topLogprobs; + } + + /** + * Set the topLogprobs of this {@link ChatCompletionTokenLogprob} instance. + * + * @param topLogprobs List of the most likely tokens and their log probability, at this token + * position. In rare cases, there may be fewer than the number of requested + * `top_logprobs` returned. + */ + public void setTopLogprobs( + @Nonnull final List topLogprobs) { + this.topLogprobs = topLogprobs; + } + + /** + * Get the names of the unrecognizable properties of the {@link ChatCompletionTokenLogprob}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ChatCompletionTokenLogprob} + * instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ChatCompletionTokenLogprob has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ChatCompletionTokenLogprob} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ChatCompletionTokenLogprob chatCompletionTokenLogprob = (ChatCompletionTokenLogprob) o; + return Objects.equals( + this.cloudSdkCustomFields, chatCompletionTokenLogprob.cloudSdkCustomFields) + && Objects.equals(this.token, chatCompletionTokenLogprob.token) + && Objects.equals(this.logprob, chatCompletionTokenLogprob.logprob) + && Objects.equals(this.bytes, chatCompletionTokenLogprob.bytes) + && Objects.equals(this.topLogprobs, chatCompletionTokenLogprob.topLogprobs); + } + + @Override + public int hashCode() { + return Objects.hash(token, logprob, bytes, topLogprobs, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ChatCompletionTokenLogprob {\n"); + sb.append(" token: ").append(toIndentedString(token)).append("\n"); + sb.append(" logprob: ").append(toIndentedString(logprob)).append("\n"); + sb.append(" bytes: ").append(toIndentedString(bytes)).append("\n"); + sb.append(" topLogprobs: ").append(toIndentedString(topLogprobs)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionTokenLogprobTopLogprobsInner.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionTokenLogprobTopLogprobsInner.java new file mode 100644 index 000000000..0892f90aa --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionTokenLogprobTopLogprobsInner.java @@ -0,0 +1,261 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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.math.BigDecimal; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** ChatCompletionTokenLogprobTopLogprobsInner */ +// CHECKSTYLE:OFF +public class ChatCompletionTokenLogprobTopLogprobsInner +// CHECKSTYLE:ON +{ + @JsonProperty("token") + private String token; + + @JsonProperty("logprob") + private BigDecimal logprob; + + @JsonProperty("bytes") + private List bytes; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the token of this {@link ChatCompletionTokenLogprobTopLogprobsInner} instance and return + * the same instance. + * + * @param token The token. + * @return The same instance of this {@link ChatCompletionTokenLogprobTopLogprobsInner} class + */ + @Nonnull + public ChatCompletionTokenLogprobTopLogprobsInner token(@Nonnull final String token) { + this.token = token; + return this; + } + + /** + * The token. + * + * @return token The token of this {@link ChatCompletionTokenLogprobTopLogprobsInner} instance. + */ + @Nonnull + public String getToken() { + return token; + } + + /** + * Set the token of this {@link ChatCompletionTokenLogprobTopLogprobsInner} instance. + * + * @param token The token. + */ + public void setToken(@Nonnull final String token) { + this.token = token; + } + + /** + * Set the logprob of this {@link ChatCompletionTokenLogprobTopLogprobsInner} instance and return + * the same instance. + * + * @param logprob The log probability of this token. + * @return The same instance of this {@link ChatCompletionTokenLogprobTopLogprobsInner} class + */ + @Nonnull + public ChatCompletionTokenLogprobTopLogprobsInner logprob(@Nonnull final BigDecimal logprob) { + this.logprob = logprob; + return this; + } + + /** + * The log probability of this token. + * + * @return logprob The logprob of this {@link ChatCompletionTokenLogprobTopLogprobsInner} + * instance. + */ + @Nonnull + public BigDecimal getLogprob() { + return logprob; + } + + /** + * Set the logprob of this {@link ChatCompletionTokenLogprobTopLogprobsInner} instance. + * + * @param logprob The log probability of this token. + */ + public void setLogprob(@Nonnull final BigDecimal logprob) { + this.logprob = logprob; + } + + /** + * Set the bytes of this {@link ChatCompletionTokenLogprobTopLogprobsInner} instance and return + * the same instance. + * + * @param bytes A list of integers representing the UTF-8 bytes representation of the token. + * Useful in instances where characters are represented by multiple tokens and their byte + * representations must be combined to generate the correct text representation. Can be + * `null` if there is no bytes representation for the token. + * @return The same instance of this {@link ChatCompletionTokenLogprobTopLogprobsInner} class + */ + @Nonnull + public ChatCompletionTokenLogprobTopLogprobsInner bytes(@Nullable final List bytes) { + this.bytes = bytes; + return this; + } + + /** + * Add one bytes instance to this {@link ChatCompletionTokenLogprobTopLogprobsInner}. + * + * @param bytesItem The bytes that should be added + * @return The same instance of type {@link ChatCompletionTokenLogprobTopLogprobsInner} + */ + @Nonnull + public ChatCompletionTokenLogprobTopLogprobsInner addBytesItem(@Nonnull final Integer bytesItem) { + if (this.bytes == null) { + this.bytes = new ArrayList<>(); + } + this.bytes.add(bytesItem); + return this; + } + + /** + * A list of integers representing the UTF-8 bytes representation of the token. Useful in + * instances where characters are represented by multiple tokens and their byte representations + * must be combined to generate the correct text representation. Can be `null` if there + * is no bytes representation for the token. + * + * @return bytes The bytes of this {@link ChatCompletionTokenLogprobTopLogprobsInner} instance. + */ + @Nullable + public List getBytes() { + return bytes; + } + + /** + * Set the bytes of this {@link ChatCompletionTokenLogprobTopLogprobsInner} instance. + * + * @param bytes A list of integers representing the UTF-8 bytes representation of the token. + * Useful in instances where characters are represented by multiple tokens and their byte + * representations must be combined to generate the correct text representation. Can be + * `null` if there is no bytes representation for the token. + */ + public void setBytes(@Nullable final List bytes) { + this.bytes = bytes; + } + + /** + * Get the names of the unrecognizable properties of the {@link + * ChatCompletionTokenLogprobTopLogprobsInner}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link + * ChatCompletionTokenLogprobTopLogprobsInner} instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ChatCompletionTokenLogprobTopLogprobsInner has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ChatCompletionTokenLogprobTopLogprobsInner} + * 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ChatCompletionTokenLogprobTopLogprobsInner chatCompletionTokenLogprobTopLogprobsInner = + (ChatCompletionTokenLogprobTopLogprobsInner) o; + return Objects.equals( + this.cloudSdkCustomFields, + chatCompletionTokenLogprobTopLogprobsInner.cloudSdkCustomFields) + && Objects.equals(this.token, chatCompletionTokenLogprobTopLogprobsInner.token) + && Objects.equals(this.logprob, chatCompletionTokenLogprobTopLogprobsInner.logprob) + && Objects.equals(this.bytes, chatCompletionTokenLogprobTopLogprobsInner.bytes); + } + + @Override + public int hashCode() { + return Objects.hash(token, logprob, bytes, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ChatCompletionTokenLogprobTopLogprobsInner {\n"); + sb.append(" token: ").append(toIndentedString(token)).append("\n"); + sb.append(" logprob: ").append(toIndentedString(logprob)).append("\n"); + sb.append(" bytes: ").append(toIndentedString(bytes)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionTool.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionTool.java new file mode 100644 index 000000000..c1be05459 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionTool.java @@ -0,0 +1,240 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +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; + +/** ChatCompletionTool */ +// CHECKSTYLE:OFF +public class ChatCompletionTool +// CHECKSTYLE:ON +{ + /** The type of the tool. Currently, only `function` is supported. */ + public enum TypeEnum { + /** The FUNCTION option of this ChatCompletionTool */ + FUNCTION("function"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value The String value + * @return The enum value of type ChatCompletionTool + */ + @JsonCreator + @Nonnull + public static TypeEnum fromValue(@Nonnull final String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("type") + private TypeEnum type; + + @JsonProperty("function") + private FunctionObject function; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the type of this {@link ChatCompletionTool} instance and return the same instance. + * + * @param type The type of the tool. Currently, only `function` is supported. + * @return The same instance of this {@link ChatCompletionTool} class + */ + @Nonnull + public ChatCompletionTool type(@Nonnull final TypeEnum type) { + this.type = type; + return this; + } + + /** + * The type of the tool. Currently, only `function` is supported. + * + * @return type The type of this {@link ChatCompletionTool} instance. + */ + @Nonnull + public TypeEnum getType() { + return type; + } + + /** + * Set the type of this {@link ChatCompletionTool} instance. + * + * @param type The type of the tool. Currently, only `function` is supported. + */ + public void setType(@Nonnull final TypeEnum type) { + this.type = type; + } + + /** + * Set the function of this {@link ChatCompletionTool} instance and return the same instance. + * + * @param function The function of this {@link ChatCompletionTool} + * @return The same instance of this {@link ChatCompletionTool} class + */ + @Nonnull + public ChatCompletionTool function(@Nonnull final FunctionObject function) { + this.function = function; + return this; + } + + /** + * Get function + * + * @return function The function of this {@link ChatCompletionTool} instance. + */ + @Nonnull + public FunctionObject getFunction() { + return function; + } + + /** + * Set the function of this {@link ChatCompletionTool} instance. + * + * @param function The function of this {@link ChatCompletionTool} + */ + public void setFunction(@Nonnull final FunctionObject function) { + this.function = function; + } + + /** + * Get the names of the unrecognizable properties of the {@link ChatCompletionTool}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ChatCompletionTool} instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException("ChatCompletionTool has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ChatCompletionTool} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ChatCompletionTool chatCompletionTool = (ChatCompletionTool) o; + return Objects.equals(this.cloudSdkCustomFields, chatCompletionTool.cloudSdkCustomFields) + && Objects.equals(this.type, chatCompletionTool.type) + && Objects.equals(this.function, chatCompletionTool.function); + } + + @Override + public int hashCode() { + return Objects.hash(type, function, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ChatCompletionTool {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" function: ").append(toIndentedString(function)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionToolChoiceOption.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionToolChoiceOption.java new file mode 100644 index 000000000..1dd535968 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionToolChoiceOption.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Controls which (if any) tool is called by the model. `none` means the model will not + * call any tool and instead generates a message. `auto` means the model can pick between + * generating a message or calling one or more tools. `required` means the model must call + * one or more tools. Specifying a particular tool via `{\"type\": + * \"function\", \"function\": {\"name\": + * \"my_function\"}}` forces the model to call that tool. `none` is the + * default when no tools are present. `auto` is the default if tools are present. + */ +public interface ChatCompletionToolChoiceOption { + /** + * Helper class to create a ChatCompletionNamedToolChoice that implements {@link + * ChatCompletionToolChoiceOption}. + */ + record InnerChatCompletionNamedToolChoice(@JsonValue ChatCompletionNamedToolChoice value) + implements ChatCompletionToolChoiceOption {} + + /** + * Creator to enable deserialization of a ChatCompletionNamedToolChoice. + * + * @param val the value to use + * @return a new instance of {@link InnerChatCompletionNamedToolChoice}. + */ + @JsonCreator + static InnerChatCompletionNamedToolChoice create(ChatCompletionNamedToolChoice val) { + return new InnerChatCompletionNamedToolChoice(val); + } + + /** Helper class to create a String that implements {@link ChatCompletionToolChoiceOption}. */ + record InnerString(@JsonValue String value) implements ChatCompletionToolChoiceOption {} + + /** + * Creator to enable deserialization of a String. + * + * @param val the value to use + * @return a new instance of {@link InnerString}. + */ + @JsonCreator + static InnerString create(String val) { + return new InnerString(val); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionsCreate200Response.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionsCreate200Response.java new file mode 100644 index 000000000..a5bf3e78a --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionsCreate200Response.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +/** ChatCompletionsCreate200Response */ +@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION) +@JsonSubTypes({ + @JsonSubTypes.Type(value = CreateChatCompletionResponse.class), + @JsonSubTypes.Type(value = CreateChatCompletionStreamResponse.class), +}) +public interface ChatCompletionsCreate200Response {} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionsRequestCommon.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionsRequestCommon.java new file mode 100644 index 000000000..dea3cf93b --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionsRequestCommon.java @@ -0,0 +1,574 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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.math.BigDecimal; +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; + +/** ChatCompletionsRequestCommon */ +// CHECKSTYLE:OFF +public class ChatCompletionsRequestCommon +// CHECKSTYLE:ON +{ + @JsonProperty("temperature") + private BigDecimal temperature = new BigDecimal("1"); + + @JsonProperty("top_p") + private BigDecimal topP = new BigDecimal("1"); + + @JsonProperty("stream") + private Boolean stream = false; + + @JsonProperty("stop") + private ChatCompletionsRequestCommonStop stop = null; + + @JsonProperty("max_tokens") + private Integer maxTokens = 4096; + + @JsonProperty("max_completion_tokens") + private Integer maxCompletionTokens; + + @JsonProperty("presence_penalty") + private BigDecimal presencePenalty = new BigDecimal("0"); + + @JsonProperty("frequency_penalty") + private BigDecimal frequencyPenalty = new BigDecimal("0"); + + @JsonProperty("logit_bias") + private Object logitBias; + + @JsonProperty("user") + private String user; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the temperature of this {@link ChatCompletionsRequestCommon} instance and return the same + * instance. + * + * @param temperature What sampling temperature to use, between 0 and 2. Higher values like 0.8 + * will make the output more random, while lower values like 0.2 will make it more focused and + * deterministic. We generally recommend altering this or `top_p` but not both. + * Minimum: 0 Maximum: 2 + * @return The same instance of this {@link ChatCompletionsRequestCommon} class + */ + @Nonnull + public ChatCompletionsRequestCommon temperature(@Nullable final BigDecimal temperature) { + this.temperature = temperature; + return this; + } + + /** + * What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output + * more random, while lower values like 0.2 will make it more focused and deterministic. We + * generally recommend altering this or `top_p` but not both. minimum: 0 maximum: 2 + * + * @return temperature The temperature of this {@link ChatCompletionsRequestCommon} instance. + */ + @Nullable + public BigDecimal getTemperature() { + return temperature; + } + + /** + * Set the temperature of this {@link ChatCompletionsRequestCommon} instance. + * + * @param temperature What sampling temperature to use, between 0 and 2. Higher values like 0.8 + * will make the output more random, while lower values like 0.2 will make it more focused and + * deterministic. We generally recommend altering this or `top_p` but not both. + * Minimum: 0 Maximum: 2 + */ + public void setTemperature(@Nullable final BigDecimal temperature) { + this.temperature = temperature; + } + + /** + * Set the topP of this {@link ChatCompletionsRequestCommon} instance and return the same + * instance. + * + * @param topP An alternative to sampling with temperature, called nucleus sampling, where the + * model considers the results of the tokens with top_p probability mass. So 0.1 means only + * the tokens comprising the top 10% probability mass are considered. We generally recommend + * altering this or `temperature` but not both. Minimum: 0 Maximum: 1 + * @return The same instance of this {@link ChatCompletionsRequestCommon} class + */ + @Nonnull + public ChatCompletionsRequestCommon topP(@Nullable final BigDecimal topP) { + this.topP = topP; + return this; + } + + /** + * An alternative to sampling with temperature, called nucleus sampling, where the model considers + * the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising + * the top 10% probability mass are considered. We generally recommend altering this or + * `temperature` but not both. minimum: 0 maximum: 1 + * + * @return topP The topP of this {@link ChatCompletionsRequestCommon} instance. + */ + @Nullable + public BigDecimal getTopP() { + return topP; + } + + /** + * Set the topP of this {@link ChatCompletionsRequestCommon} instance. + * + * @param topP An alternative to sampling with temperature, called nucleus sampling, where the + * model considers the results of the tokens with top_p probability mass. So 0.1 means only + * the tokens comprising the top 10% probability mass are considered. We generally recommend + * altering this or `temperature` but not both. Minimum: 0 Maximum: 1 + */ + public void setTopP(@Nullable final BigDecimal topP) { + this.topP = topP; + } + + /** + * Set the stream of this {@link ChatCompletionsRequestCommon} instance and return the same + * instance. + * + * @param stream If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent + * as data-only server-sent events as they become available, with the stream terminated by a + * `data: [DONE]` message. + * @return The same instance of this {@link ChatCompletionsRequestCommon} class + */ + @Nonnull + public ChatCompletionsRequestCommon stream(@Nullable final Boolean stream) { + this.stream = stream; + return this; + } + + /** + * If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only + * server-sent events as they become available, with the stream terminated by a `data: + * [DONE]` message. + * + * @return stream The stream of this {@link ChatCompletionsRequestCommon} instance. + */ + @Nullable + public Boolean isStream() { + return stream; + } + + /** + * Set the stream of this {@link ChatCompletionsRequestCommon} instance. + * + * @param stream If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent + * as data-only server-sent events as they become available, with the stream terminated by a + * `data: [DONE]` message. + */ + public void setStream(@Nullable final Boolean stream) { + this.stream = stream; + } + + /** + * Set the stop of this {@link ChatCompletionsRequestCommon} instance and return the same + * instance. + * + * @param stop The stop of this {@link ChatCompletionsRequestCommon} + * @return The same instance of this {@link ChatCompletionsRequestCommon} class + */ + @Nonnull + public ChatCompletionsRequestCommon stop(@Nullable final ChatCompletionsRequestCommonStop stop) { + this.stop = stop; + return this; + } + + /** + * Get stop + * + * @return stop The stop of this {@link ChatCompletionsRequestCommon} instance. + */ + @Nonnull + public ChatCompletionsRequestCommonStop getStop() { + return stop; + } + + /** + * Set the stop of this {@link ChatCompletionsRequestCommon} instance. + * + * @param stop The stop of this {@link ChatCompletionsRequestCommon} + */ + public void setStop(@Nullable final ChatCompletionsRequestCommonStop stop) { + this.stop = stop; + } + + /** + * Set the maxTokens of this {@link ChatCompletionsRequestCommon} instance and return the same + * instance. + * + * @param maxTokens The maximum number of tokens allowed for the generated answer. By default, the + * number of tokens the model can return will be (4096 - prompt tokens). This value is now + * deprecated in favor of `max_completion_tokens`, and is not compatible with o1 + * series models. + * @return The same instance of this {@link ChatCompletionsRequestCommon} class + */ + @Nonnull + public ChatCompletionsRequestCommon maxTokens(@Nullable final Integer maxTokens) { + this.maxTokens = maxTokens; + return this; + } + + /** + * The maximum number of tokens allowed for the generated answer. By default, the number of tokens + * the model can return will be (4096 - prompt tokens). This value is now deprecated in favor of + * `max_completion_tokens`, and is not compatible with o1 series models. + * + * @return maxTokens The maxTokens of this {@link ChatCompletionsRequestCommon} instance. + */ + @Nonnull + public Integer getMaxTokens() { + return maxTokens; + } + + /** + * Set the maxTokens of this {@link ChatCompletionsRequestCommon} instance. + * + * @param maxTokens The maximum number of tokens allowed for the generated answer. By default, the + * number of tokens the model can return will be (4096 - prompt tokens). This value is now + * deprecated in favor of `max_completion_tokens`, and is not compatible with o1 + * series models. + */ + public void setMaxTokens(@Nullable final Integer maxTokens) { + this.maxTokens = maxTokens; + } + + /** + * Set the maxCompletionTokens of this {@link ChatCompletionsRequestCommon} instance and return + * the same instance. + * + * @param maxCompletionTokens An upper bound for the number of tokens that can be generated for a + * completion, including visible output tokens and reasoning tokens. + * @return The same instance of this {@link ChatCompletionsRequestCommon} class + */ + @Nonnull + public ChatCompletionsRequestCommon maxCompletionTokens( + @Nullable final Integer maxCompletionTokens) { + this.maxCompletionTokens = maxCompletionTokens; + return this; + } + + /** + * An upper bound for the number of tokens that can be generated for a completion, including + * visible output tokens and reasoning tokens. + * + * @return maxCompletionTokens The maxCompletionTokens of this {@link + * ChatCompletionsRequestCommon} instance. + */ + @Nullable + public Integer getMaxCompletionTokens() { + return maxCompletionTokens; + } + + /** + * Set the maxCompletionTokens of this {@link ChatCompletionsRequestCommon} instance. + * + * @param maxCompletionTokens An upper bound for the number of tokens that can be generated for a + * completion, including visible output tokens and reasoning tokens. + */ + public void setMaxCompletionTokens(@Nullable final Integer maxCompletionTokens) { + this.maxCompletionTokens = maxCompletionTokens; + } + + /** + * Set the presencePenalty of this {@link ChatCompletionsRequestCommon} instance and return the + * same instance. + * + * @param presencePenalty Number between -2.0 and 2.0. Positive values penalize new tokens based + * on whether they appear in the text so far, increasing the model's likelihood to talk + * about new topics. Minimum: -2 Maximum: 2 + * @return The same instance of this {@link ChatCompletionsRequestCommon} class + */ + @Nonnull + public ChatCompletionsRequestCommon presencePenalty(@Nullable final BigDecimal presencePenalty) { + this.presencePenalty = presencePenalty; + return this; + } + + /** + * Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear + * in the text so far, increasing the model's likelihood to talk about new topics. minimum: -2 + * maximum: 2 + * + * @return presencePenalty The presencePenalty of this {@link ChatCompletionsRequestCommon} + * instance. + */ + @Nonnull + public BigDecimal getPresencePenalty() { + return presencePenalty; + } + + /** + * Set the presencePenalty of this {@link ChatCompletionsRequestCommon} instance. + * + * @param presencePenalty Number between -2.0 and 2.0. Positive values penalize new tokens based + * on whether they appear in the text so far, increasing the model's likelihood to talk + * about new topics. Minimum: -2 Maximum: 2 + */ + public void setPresencePenalty(@Nullable final BigDecimal presencePenalty) { + this.presencePenalty = presencePenalty; + } + + /** + * Set the frequencyPenalty of this {@link ChatCompletionsRequestCommon} instance and return the + * same instance. + * + * @param frequencyPenalty Number between -2.0 and 2.0. Positive values penalize new tokens based + * on their existing frequency in the text so far, decreasing the model's likelihood to + * repeat the same line verbatim. Minimum: -2 Maximum: 2 + * @return The same instance of this {@link ChatCompletionsRequestCommon} class + */ + @Nonnull + public ChatCompletionsRequestCommon frequencyPenalty( + @Nullable final BigDecimal frequencyPenalty) { + this.frequencyPenalty = frequencyPenalty; + return this; + } + + /** + * Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing + * frequency in the text so far, decreasing the model's likelihood to repeat the same line + * verbatim. minimum: -2 maximum: 2 + * + * @return frequencyPenalty The frequencyPenalty of this {@link ChatCompletionsRequestCommon} + * instance. + */ + @Nonnull + public BigDecimal getFrequencyPenalty() { + return frequencyPenalty; + } + + /** + * Set the frequencyPenalty of this {@link ChatCompletionsRequestCommon} instance. + * + * @param frequencyPenalty Number between -2.0 and 2.0. Positive values penalize new tokens based + * on their existing frequency in the text so far, decreasing the model's likelihood to + * repeat the same line verbatim. Minimum: -2 Maximum: 2 + */ + public void setFrequencyPenalty(@Nullable final BigDecimal frequencyPenalty) { + this.frequencyPenalty = frequencyPenalty; + } + + /** + * Set the logitBias of this {@link ChatCompletionsRequestCommon} instance and return the same + * instance. + * + * @param logitBias Modify the likelihood of specified tokens appearing in the completion. Accepts + * a json object that maps tokens (specified by their token ID in the tokenizer) to an + * associated bias value from -100 to 100. Mathematically, the bias is added to the logits + * generated by the model prior to sampling. The exact effect will vary per model, but values + * between -1 and 1 should decrease or increase likelihood of selection; values like -100 or + * 100 should result in a ban or exclusive selection of the relevant token. + * @return The same instance of this {@link ChatCompletionsRequestCommon} class + */ + @Nonnull + public ChatCompletionsRequestCommon logitBias(@Nullable final Object logitBias) { + this.logitBias = logitBias; + return this; + } + + /** + * Modify the likelihood of specified tokens appearing in the completion. Accepts a json object + * that maps tokens (specified by their token ID in the tokenizer) to an associated bias value + * from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior + * to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease + * or increase likelihood of selection; values like -100 or 100 should result in a ban or + * exclusive selection of the relevant token. + * + * @return logitBias The logitBias of this {@link ChatCompletionsRequestCommon} instance. + */ + @Nullable + public Object getLogitBias() { + return logitBias; + } + + /** + * Set the logitBias of this {@link ChatCompletionsRequestCommon} instance. + * + * @param logitBias Modify the likelihood of specified tokens appearing in the completion. Accepts + * a json object that maps tokens (specified by their token ID in the tokenizer) to an + * associated bias value from -100 to 100. Mathematically, the bias is added to the logits + * generated by the model prior to sampling. The exact effect will vary per model, but values + * between -1 and 1 should decrease or increase likelihood of selection; values like -100 or + * 100 should result in a ban or exclusive selection of the relevant token. + */ + public void setLogitBias(@Nullable final Object logitBias) { + this.logitBias = logitBias; + } + + /** + * Set the user of this {@link ChatCompletionsRequestCommon} instance and return the same + * instance. + * + * @param user A unique identifier representing your end-user, which can help Azure OpenAI to + * monitor and detect abuse. + * @return The same instance of this {@link ChatCompletionsRequestCommon} class + */ + @Nonnull + public ChatCompletionsRequestCommon user(@Nullable final String user) { + this.user = user; + return this; + } + + /** + * A unique identifier representing your end-user, which can help Azure OpenAI to monitor and + * detect abuse. + * + * @return user The user of this {@link ChatCompletionsRequestCommon} instance. + */ + @Nonnull + public String getUser() { + return user; + } + + /** + * Set the user of this {@link ChatCompletionsRequestCommon} instance. + * + * @param user A unique identifier representing your end-user, which can help Azure OpenAI to + * monitor and detect abuse. + */ + public void setUser(@Nullable final String user) { + this.user = user; + } + + /** + * Get the names of the unrecognizable properties of the {@link ChatCompletionsRequestCommon}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ChatCompletionsRequestCommon} + * instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ChatCompletionsRequestCommon has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ChatCompletionsRequestCommon} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ChatCompletionsRequestCommon chatCompletionsRequestCommon = + (ChatCompletionsRequestCommon) o; + return Objects.equals( + this.cloudSdkCustomFields, chatCompletionsRequestCommon.cloudSdkCustomFields) + && Objects.equals(this.temperature, chatCompletionsRequestCommon.temperature) + && Objects.equals(this.topP, chatCompletionsRequestCommon.topP) + && Objects.equals(this.stream, chatCompletionsRequestCommon.stream) + && Objects.equals(this.stop, chatCompletionsRequestCommon.stop) + && Objects.equals(this.maxTokens, chatCompletionsRequestCommon.maxTokens) + && Objects.equals( + this.maxCompletionTokens, chatCompletionsRequestCommon.maxCompletionTokens) + && Objects.equals(this.presencePenalty, chatCompletionsRequestCommon.presencePenalty) + && Objects.equals(this.frequencyPenalty, chatCompletionsRequestCommon.frequencyPenalty) + && Objects.equals(this.logitBias, chatCompletionsRequestCommon.logitBias) + && Objects.equals(this.user, chatCompletionsRequestCommon.user); + } + + @Override + public int hashCode() { + return Objects.hash( + temperature, + topP, + stream, + stop, + maxTokens, + maxCompletionTokens, + presencePenalty, + frequencyPenalty, + logitBias, + user, + cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ChatCompletionsRequestCommon {\n"); + sb.append(" temperature: ").append(toIndentedString(temperature)).append("\n"); + sb.append(" topP: ").append(toIndentedString(topP)).append("\n"); + sb.append(" stream: ").append(toIndentedString(stream)).append("\n"); + sb.append(" stop: ").append(toIndentedString(stop)).append("\n"); + sb.append(" maxTokens: ").append(toIndentedString(maxTokens)).append("\n"); + sb.append(" maxCompletionTokens: ") + .append(toIndentedString(maxCompletionTokens)) + .append("\n"); + sb.append(" presencePenalty: ").append(toIndentedString(presencePenalty)).append("\n"); + sb.append(" frequencyPenalty: ").append(toIndentedString(frequencyPenalty)).append("\n"); + sb.append(" logitBias: ").append(toIndentedString(logitBias)).append("\n"); + sb.append(" user: ").append(toIndentedString(user)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionsRequestCommonStop.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionsRequestCommonStop.java new file mode 100644 index 000000000..798e3b790 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ChatCompletionsRequestCommonStop.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import java.util.List; + +/** Up to 4 sequences where the API will stop generating further tokens. */ +public interface ChatCompletionsRequestCommonStop { + /** Helper class to create a String that implements {@link ChatCompletionsRequestCommonStop}. */ + record InnerString(@com.fasterxml.jackson.annotation.JsonValue String value) + implements ChatCompletionsRequestCommonStop {} + + /** + * Creator to enable deserialization of a String. + * + * @param val the value to use + * @return a new instance of {@link InnerString}. + */ + @com.fasterxml.jackson.annotation.JsonCreator + static InnerString create(String val) { + return new InnerString(val); + } + + /** + * Helper class to create a list of String that implements {@link + * ChatCompletionsRequestCommonStop}. + */ + record InnerStrings(@com.fasterxml.jackson.annotation.JsonValue List values) + implements ChatCompletionsRequestCommonStop {} + + /** + * Creator to enable deserialization of a list of String. + * + * @param val the value to use + * @return a new instance of {@link InnerStrings}. + */ + @com.fasterxml.jackson.annotation.JsonCreator + static InnerStrings create(List val) { + return new InnerStrings(val); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/CompletionUsage.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/CompletionUsage.java new file mode 100644 index 000000000..7e2c0383e --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/CompletionUsage.java @@ -0,0 +1,266 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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; + +/** Usage statistics for the completion request. */ +// CHECKSTYLE:OFF +public class CompletionUsage +// CHECKSTYLE:ON +{ + @JsonProperty("prompt_tokens") + private Integer promptTokens; + + @JsonProperty("completion_tokens") + private Integer completionTokens; + + @JsonProperty("total_tokens") + private Integer totalTokens; + + @JsonProperty("completion_tokens_details") + private CompletionUsageCompletionTokensDetails completionTokensDetails; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the promptTokens of this {@link CompletionUsage} instance and return the same instance. + * + * @param promptTokens Number of tokens in the prompt. + * @return The same instance of this {@link CompletionUsage} class + */ + @Nonnull + public CompletionUsage promptTokens(@Nonnull final Integer promptTokens) { + this.promptTokens = promptTokens; + return this; + } + + /** + * Number of tokens in the prompt. + * + * @return promptTokens The promptTokens of this {@link CompletionUsage} instance. + */ + @Nonnull + public Integer getPromptTokens() { + return promptTokens; + } + + /** + * Set the promptTokens of this {@link CompletionUsage} instance. + * + * @param promptTokens Number of tokens in the prompt. + */ + public void setPromptTokens(@Nonnull final Integer promptTokens) { + this.promptTokens = promptTokens; + } + + /** + * Set the completionTokens of this {@link CompletionUsage} instance and return the same instance. + * + * @param completionTokens Number of tokens in the generated completion. + * @return The same instance of this {@link CompletionUsage} class + */ + @Nonnull + public CompletionUsage completionTokens(@Nonnull final Integer completionTokens) { + this.completionTokens = completionTokens; + return this; + } + + /** + * Number of tokens in the generated completion. + * + * @return completionTokens The completionTokens of this {@link CompletionUsage} instance. + */ + @Nonnull + public Integer getCompletionTokens() { + return completionTokens; + } + + /** + * Set the completionTokens of this {@link CompletionUsage} instance. + * + * @param completionTokens Number of tokens in the generated completion. + */ + public void setCompletionTokens(@Nonnull final Integer completionTokens) { + this.completionTokens = completionTokens; + } + + /** + * Set the totalTokens of this {@link CompletionUsage} instance and return the same instance. + * + * @param totalTokens Total number of tokens used in the request (prompt + completion). + * @return The same instance of this {@link CompletionUsage} class + */ + @Nonnull + public CompletionUsage totalTokens(@Nonnull final Integer totalTokens) { + this.totalTokens = totalTokens; + return this; + } + + /** + * Total number of tokens used in the request (prompt + completion). + * + * @return totalTokens The totalTokens of this {@link CompletionUsage} instance. + */ + @Nonnull + public Integer getTotalTokens() { + return totalTokens; + } + + /** + * Set the totalTokens of this {@link CompletionUsage} instance. + * + * @param totalTokens Total number of tokens used in the request (prompt + completion). + */ + public void setTotalTokens(@Nonnull final Integer totalTokens) { + this.totalTokens = totalTokens; + } + + /** + * Set the completionTokensDetails of this {@link CompletionUsage} instance and return the same + * instance. + * + * @param completionTokensDetails The completionTokensDetails of this {@link CompletionUsage} + * @return The same instance of this {@link CompletionUsage} class + */ + @Nonnull + public CompletionUsage completionTokensDetails( + @Nullable final CompletionUsageCompletionTokensDetails completionTokensDetails) { + this.completionTokensDetails = completionTokensDetails; + return this; + } + + /** + * Get completionTokensDetails + * + * @return completionTokensDetails The completionTokensDetails of this {@link CompletionUsage} + * instance. + */ + @Nonnull + public CompletionUsageCompletionTokensDetails getCompletionTokensDetails() { + return completionTokensDetails; + } + + /** + * Set the completionTokensDetails of this {@link CompletionUsage} instance. + * + * @param completionTokensDetails The completionTokensDetails of this {@link CompletionUsage} + */ + public void setCompletionTokensDetails( + @Nullable final CompletionUsageCompletionTokensDetails completionTokensDetails) { + this.completionTokensDetails = completionTokensDetails; + } + + /** + * Get the names of the unrecognizable properties of the {@link CompletionUsage}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link CompletionUsage} instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException("CompletionUsage has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link CompletionUsage} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final CompletionUsage completionUsage = (CompletionUsage) o; + return Objects.equals(this.cloudSdkCustomFields, completionUsage.cloudSdkCustomFields) + && Objects.equals(this.promptTokens, completionUsage.promptTokens) + && Objects.equals(this.completionTokens, completionUsage.completionTokens) + && Objects.equals(this.totalTokens, completionUsage.totalTokens) + && Objects.equals(this.completionTokensDetails, completionUsage.completionTokensDetails); + } + + @Override + public int hashCode() { + return Objects.hash( + promptTokens, completionTokens, totalTokens, completionTokensDetails, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class CompletionUsage {\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(" completionTokensDetails: ") + .append(toIndentedString(completionTokensDetails)) + .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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/CompletionUsageCompletionTokensDetails.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/CompletionUsageCompletionTokensDetails.java new file mode 100644 index 000000000..6008b1320 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/CompletionUsageCompletionTokensDetails.java @@ -0,0 +1,161 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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 CompletionUsageCompletionTokensDetails +// CHECKSTYLE:ON +{ + @JsonProperty("reasoning_tokens") + private Integer reasoningTokens; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the reasoningTokens of this {@link CompletionUsageCompletionTokensDetails} instance and + * return the same instance. + * + * @param reasoningTokens Tokens generated by the model for reasoning. + * @return The same instance of this {@link CompletionUsageCompletionTokensDetails} class + */ + @Nonnull + public CompletionUsageCompletionTokensDetails reasoningTokens( + @Nullable final Integer reasoningTokens) { + this.reasoningTokens = reasoningTokens; + return this; + } + + /** + * Tokens generated by the model for reasoning. + * + * @return reasoningTokens The reasoningTokens of this {@link + * CompletionUsageCompletionTokensDetails} instance. + */ + @Nonnull + public Integer getReasoningTokens() { + return reasoningTokens; + } + + /** + * Set the reasoningTokens of this {@link CompletionUsageCompletionTokensDetails} instance. + * + * @param reasoningTokens Tokens generated by the model for reasoning. + */ + public void setReasoningTokens(@Nullable final Integer reasoningTokens) { + this.reasoningTokens = reasoningTokens; + } + + /** + * Get the names of the unrecognizable properties of the {@link + * CompletionUsageCompletionTokensDetails}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link + * CompletionUsageCompletionTokensDetails} instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "CompletionUsageCompletionTokensDetails has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link CompletionUsageCompletionTokensDetails} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final CompletionUsageCompletionTokensDetails completionUsageCompletionTokensDetails = + (CompletionUsageCompletionTokensDetails) o; + return Objects.equals( + this.cloudSdkCustomFields, completionUsageCompletionTokensDetails.cloudSdkCustomFields) + && Objects.equals( + this.reasoningTokens, completionUsageCompletionTokensDetails.reasoningTokens); + } + + @Override + public int hashCode() { + return Objects.hash(reasoningTokens, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class CompletionUsageCompletionTokensDetails {\n"); + sb.append(" reasoningTokens: ").append(toIndentedString(reasoningTokens)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ContentFilterChoiceResults.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ContentFilterChoiceResults.java new file mode 100644 index 000000000..36c251474 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ContentFilterChoiceResults.java @@ -0,0 +1,444 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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; + +/** + * Information about the content filtering category (hate, sexual, violence, self_harm), if it has + * been detected, as well as the severity level (very_low, low, medium, high-scale that determines + * the intensity and risk level of harmful content) and if it has been filtered or not. Information + * about third party text and profanity, if it has been detected, and if it has been filtered or + * not. And information about customer block list, if it has been filtered and its id. + */ +// CHECKSTYLE:OFF +public class ContentFilterChoiceResults +// CHECKSTYLE:ON +{ + @JsonProperty("sexual") + private ContentFilterSeverityResult sexual; + + @JsonProperty("violence") + private ContentFilterSeverityResult violence; + + @JsonProperty("hate") + private ContentFilterSeverityResult hate; + + @JsonProperty("self_harm") + private ContentFilterSeverityResult selfHarm; + + @JsonProperty("profanity") + private ContentFilterDetectedResult profanity; + + @JsonProperty("error") + private ErrorBase error; + + @JsonProperty("protected_material_text") + private ContentFilterDetectedResult protectedMaterialText; + + @JsonProperty("protected_material_code") + private ContentFilterDetectedWithCitationResult protectedMaterialCode; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the sexual of this {@link ContentFilterChoiceResults} instance and return the same + * instance. + * + * @param sexual The sexual of this {@link ContentFilterChoiceResults} + * @return The same instance of this {@link ContentFilterChoiceResults} class + */ + @Nonnull + public ContentFilterChoiceResults sexual(@Nullable final ContentFilterSeverityResult sexual) { + this.sexual = sexual; + return this; + } + + /** + * Get sexual + * + * @return sexual The sexual of this {@link ContentFilterChoiceResults} instance. + */ + @Nonnull + public ContentFilterSeverityResult getSexual() { + return sexual; + } + + /** + * Set the sexual of this {@link ContentFilterChoiceResults} instance. + * + * @param sexual The sexual of this {@link ContentFilterChoiceResults} + */ + public void setSexual(@Nullable final ContentFilterSeverityResult sexual) { + this.sexual = sexual; + } + + /** + * Set the violence of this {@link ContentFilterChoiceResults} instance and return the same + * instance. + * + * @param violence The violence of this {@link ContentFilterChoiceResults} + * @return The same instance of this {@link ContentFilterChoiceResults} class + */ + @Nonnull + public ContentFilterChoiceResults violence(@Nullable final ContentFilterSeverityResult violence) { + this.violence = violence; + return this; + } + + /** + * Get violence + * + * @return violence The violence of this {@link ContentFilterChoiceResults} instance. + */ + @Nonnull + public ContentFilterSeverityResult getViolence() { + return violence; + } + + /** + * Set the violence of this {@link ContentFilterChoiceResults} instance. + * + * @param violence The violence of this {@link ContentFilterChoiceResults} + */ + public void setViolence(@Nullable final ContentFilterSeverityResult violence) { + this.violence = violence; + } + + /** + * Set the hate of this {@link ContentFilterChoiceResults} instance and return the same instance. + * + * @param hate The hate of this {@link ContentFilterChoiceResults} + * @return The same instance of this {@link ContentFilterChoiceResults} class + */ + @Nonnull + public ContentFilterChoiceResults hate(@Nullable final ContentFilterSeverityResult hate) { + this.hate = hate; + return this; + } + + /** + * Get hate + * + * @return hate The hate of this {@link ContentFilterChoiceResults} instance. + */ + @Nonnull + public ContentFilterSeverityResult getHate() { + return hate; + } + + /** + * Set the hate of this {@link ContentFilterChoiceResults} instance. + * + * @param hate The hate of this {@link ContentFilterChoiceResults} + */ + public void setHate(@Nullable final ContentFilterSeverityResult hate) { + this.hate = hate; + } + + /** + * Set the selfHarm of this {@link ContentFilterChoiceResults} instance and return the same + * instance. + * + * @param selfHarm The selfHarm of this {@link ContentFilterChoiceResults} + * @return The same instance of this {@link ContentFilterChoiceResults} class + */ + @Nonnull + public ContentFilterChoiceResults selfHarm(@Nullable final ContentFilterSeverityResult selfHarm) { + this.selfHarm = selfHarm; + return this; + } + + /** + * Get selfHarm + * + * @return selfHarm The selfHarm of this {@link ContentFilterChoiceResults} instance. + */ + @Nonnull + public ContentFilterSeverityResult getSelfHarm() { + return selfHarm; + } + + /** + * Set the selfHarm of this {@link ContentFilterChoiceResults} instance. + * + * @param selfHarm The selfHarm of this {@link ContentFilterChoiceResults} + */ + public void setSelfHarm(@Nullable final ContentFilterSeverityResult selfHarm) { + this.selfHarm = selfHarm; + } + + /** + * Set the profanity of this {@link ContentFilterChoiceResults} instance and return the same + * instance. + * + * @param profanity The profanity of this {@link ContentFilterChoiceResults} + * @return The same instance of this {@link ContentFilterChoiceResults} class + */ + @Nonnull + public ContentFilterChoiceResults profanity( + @Nullable final ContentFilterDetectedResult profanity) { + this.profanity = profanity; + return this; + } + + /** + * Get profanity + * + * @return profanity The profanity of this {@link ContentFilterChoiceResults} instance. + */ + @Nonnull + public ContentFilterDetectedResult getProfanity() { + return profanity; + } + + /** + * Set the profanity of this {@link ContentFilterChoiceResults} instance. + * + * @param profanity The profanity of this {@link ContentFilterChoiceResults} + */ + public void setProfanity(@Nullable final ContentFilterDetectedResult profanity) { + this.profanity = profanity; + } + + /** + * Set the error of this {@link ContentFilterChoiceResults} instance and return the same instance. + * + * @param error The error of this {@link ContentFilterChoiceResults} + * @return The same instance of this {@link ContentFilterChoiceResults} class + */ + @Nonnull + public ContentFilterChoiceResults error(@Nullable final ErrorBase error) { + this.error = error; + return this; + } + + /** + * Get error + * + * @return error The error of this {@link ContentFilterChoiceResults} instance. + */ + @Nonnull + public ErrorBase getError() { + return error; + } + + /** + * Set the error of this {@link ContentFilterChoiceResults} instance. + * + * @param error The error of this {@link ContentFilterChoiceResults} + */ + public void setError(@Nullable final ErrorBase error) { + this.error = error; + } + + /** + * Set the protectedMaterialText of this {@link ContentFilterChoiceResults} instance and return + * the same instance. + * + * @param protectedMaterialText The protectedMaterialText of this {@link + * ContentFilterChoiceResults} + * @return The same instance of this {@link ContentFilterChoiceResults} class + */ + @Nonnull + public ContentFilterChoiceResults protectedMaterialText( + @Nullable final ContentFilterDetectedResult protectedMaterialText) { + this.protectedMaterialText = protectedMaterialText; + return this; + } + + /** + * Get protectedMaterialText + * + * @return protectedMaterialText The protectedMaterialText of this {@link + * ContentFilterChoiceResults} instance. + */ + @Nonnull + public ContentFilterDetectedResult getProtectedMaterialText() { + return protectedMaterialText; + } + + /** + * Set the protectedMaterialText of this {@link ContentFilterChoiceResults} instance. + * + * @param protectedMaterialText The protectedMaterialText of this {@link + * ContentFilterChoiceResults} + */ + public void setProtectedMaterialText( + @Nullable final ContentFilterDetectedResult protectedMaterialText) { + this.protectedMaterialText = protectedMaterialText; + } + + /** + * Set the protectedMaterialCode of this {@link ContentFilterChoiceResults} instance and return + * the same instance. + * + * @param protectedMaterialCode The protectedMaterialCode of this {@link + * ContentFilterChoiceResults} + * @return The same instance of this {@link ContentFilterChoiceResults} class + */ + @Nonnull + public ContentFilterChoiceResults protectedMaterialCode( + @Nullable final ContentFilterDetectedWithCitationResult protectedMaterialCode) { + this.protectedMaterialCode = protectedMaterialCode; + return this; + } + + /** + * Get protectedMaterialCode + * + * @return protectedMaterialCode The protectedMaterialCode of this {@link + * ContentFilterChoiceResults} instance. + */ + @Nonnull + public ContentFilterDetectedWithCitationResult getProtectedMaterialCode() { + return protectedMaterialCode; + } + + /** + * Set the protectedMaterialCode of this {@link ContentFilterChoiceResults} instance. + * + * @param protectedMaterialCode The protectedMaterialCode of this {@link + * ContentFilterChoiceResults} + */ + public void setProtectedMaterialCode( + @Nullable final ContentFilterDetectedWithCitationResult protectedMaterialCode) { + this.protectedMaterialCode = protectedMaterialCode; + } + + /** + * Get the names of the unrecognizable properties of the {@link ContentFilterChoiceResults}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ContentFilterChoiceResults} + * instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ContentFilterChoiceResults has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ContentFilterChoiceResults} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ContentFilterChoiceResults contentFilterChoiceResults = (ContentFilterChoiceResults) o; + return Objects.equals( + this.cloudSdkCustomFields, contentFilterChoiceResults.cloudSdkCustomFields) + && Objects.equals(this.sexual, contentFilterChoiceResults.sexual) + && Objects.equals(this.violence, contentFilterChoiceResults.violence) + && Objects.equals(this.hate, contentFilterChoiceResults.hate) + && Objects.equals(this.selfHarm, contentFilterChoiceResults.selfHarm) + && Objects.equals(this.profanity, contentFilterChoiceResults.profanity) + && Objects.equals(this.error, contentFilterChoiceResults.error) + && Objects.equals( + this.protectedMaterialText, contentFilterChoiceResults.protectedMaterialText) + && Objects.equals( + this.protectedMaterialCode, contentFilterChoiceResults.protectedMaterialCode); + } + + @Override + public int hashCode() { + return Objects.hash( + sexual, + violence, + hate, + selfHarm, + profanity, + error, + protectedMaterialText, + protectedMaterialCode, + cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ContentFilterChoiceResults {\n"); + sb.append(" sexual: ").append(toIndentedString(sexual)).append("\n"); + sb.append(" violence: ").append(toIndentedString(violence)).append("\n"); + sb.append(" hate: ").append(toIndentedString(hate)).append("\n"); + sb.append(" selfHarm: ").append(toIndentedString(selfHarm)).append("\n"); + sb.append(" profanity: ").append(toIndentedString(profanity)).append("\n"); + sb.append(" error: ").append(toIndentedString(error)).append("\n"); + sb.append(" protectedMaterialText: ") + .append(toIndentedString(protectedMaterialText)) + .append("\n"); + sb.append(" protectedMaterialCode: ") + .append(toIndentedString(protectedMaterialCode)) + .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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ContentFilterDetectedResult.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ContentFilterDetectedResult.java new file mode 100644 index 000000000..6fac94b02 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ContentFilterDetectedResult.java @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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; + +/** ContentFilterDetectedResult */ +// CHECKSTYLE:OFF +public class ContentFilterDetectedResult +// CHECKSTYLE:ON +{ + @JsonProperty("filtered") + private Boolean filtered; + + @JsonProperty("detected") + private Boolean detected; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the filtered of this {@link ContentFilterDetectedResult} instance and return the same + * instance. + * + * @param filtered The filtered of this {@link ContentFilterDetectedResult} + * @return The same instance of this {@link ContentFilterDetectedResult} class + */ + @Nonnull + public ContentFilterDetectedResult filtered(@Nonnull final Boolean filtered) { + this.filtered = filtered; + return this; + } + + /** + * Get filtered + * + * @return filtered The filtered of this {@link ContentFilterDetectedResult} instance. + */ + @Nonnull + public Boolean isFiltered() { + return filtered; + } + + /** + * Set the filtered of this {@link ContentFilterDetectedResult} instance. + * + * @param filtered The filtered of this {@link ContentFilterDetectedResult} + */ + public void setFiltered(@Nonnull final Boolean filtered) { + this.filtered = filtered; + } + + /** + * Set the detected of this {@link ContentFilterDetectedResult} instance and return the same + * instance. + * + * @param detected The detected of this {@link ContentFilterDetectedResult} + * @return The same instance of this {@link ContentFilterDetectedResult} class + */ + @Nonnull + public ContentFilterDetectedResult detected(@Nonnull final Boolean detected) { + this.detected = detected; + return this; + } + + /** + * Get detected + * + * @return detected The detected of this {@link ContentFilterDetectedResult} instance. + */ + @Nonnull + public Boolean isDetected() { + return detected; + } + + /** + * Set the detected of this {@link ContentFilterDetectedResult} instance. + * + * @param detected The detected of this {@link ContentFilterDetectedResult} + */ + public void setDetected(@Nonnull final Boolean detected) { + this.detected = detected; + } + + /** + * Get the names of the unrecognizable properties of the {@link ContentFilterDetectedResult}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ContentFilterDetectedResult} + * instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ContentFilterDetectedResult has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ContentFilterDetectedResult} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ContentFilterDetectedResult contentFilterDetectedResult = (ContentFilterDetectedResult) o; + return Objects.equals( + this.cloudSdkCustomFields, contentFilterDetectedResult.cloudSdkCustomFields) + && Objects.equals(this.filtered, contentFilterDetectedResult.filtered) + && Objects.equals(this.detected, contentFilterDetectedResult.detected); + } + + @Override + public int hashCode() { + return Objects.hash(filtered, detected, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ContentFilterDetectedResult {\n"); + sb.append(" filtered: ").append(toIndentedString(filtered)).append("\n"); + sb.append(" detected: ").append(toIndentedString(detected)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ContentFilterDetectedWithCitationResult.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ContentFilterDetectedWithCitationResult.java new file mode 100644 index 000000000..a70cd8730 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ContentFilterDetectedWithCitationResult.java @@ -0,0 +1,234 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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; + +/** ContentFilterDetectedWithCitationResult */ +// CHECKSTYLE:OFF +public class ContentFilterDetectedWithCitationResult +// CHECKSTYLE:ON +{ + @JsonProperty("filtered") + private Boolean filtered; + + @JsonProperty("detected") + private Boolean detected; + + @JsonProperty("citation") + private ContentFilterDetectedWithCitationResultAllOfCitation citation; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the filtered of this {@link ContentFilterDetectedWithCitationResult} instance and return + * the same instance. + * + * @param filtered The filtered of this {@link ContentFilterDetectedWithCitationResult} + * @return The same instance of this {@link ContentFilterDetectedWithCitationResult} class + */ + @Nonnull + public ContentFilterDetectedWithCitationResult filtered(@Nonnull final Boolean filtered) { + this.filtered = filtered; + return this; + } + + /** + * Get filtered + * + * @return filtered The filtered of this {@link ContentFilterDetectedWithCitationResult} instance. + */ + @Nonnull + public Boolean isFiltered() { + return filtered; + } + + /** + * Set the filtered of this {@link ContentFilterDetectedWithCitationResult} instance. + * + * @param filtered The filtered of this {@link ContentFilterDetectedWithCitationResult} + */ + public void setFiltered(@Nonnull final Boolean filtered) { + this.filtered = filtered; + } + + /** + * Set the detected of this {@link ContentFilterDetectedWithCitationResult} instance and return + * the same instance. + * + * @param detected The detected of this {@link ContentFilterDetectedWithCitationResult} + * @return The same instance of this {@link ContentFilterDetectedWithCitationResult} class + */ + @Nonnull + public ContentFilterDetectedWithCitationResult detected(@Nonnull final Boolean detected) { + this.detected = detected; + return this; + } + + /** + * Get detected + * + * @return detected The detected of this {@link ContentFilterDetectedWithCitationResult} instance. + */ + @Nonnull + public Boolean isDetected() { + return detected; + } + + /** + * Set the detected of this {@link ContentFilterDetectedWithCitationResult} instance. + * + * @param detected The detected of this {@link ContentFilterDetectedWithCitationResult} + */ + public void setDetected(@Nonnull final Boolean detected) { + this.detected = detected; + } + + /** + * Set the citation of this {@link ContentFilterDetectedWithCitationResult} instance and return + * the same instance. + * + * @param citation The citation of this {@link ContentFilterDetectedWithCitationResult} + * @return The same instance of this {@link ContentFilterDetectedWithCitationResult} class + */ + @Nonnull + public ContentFilterDetectedWithCitationResult citation( + @Nullable final ContentFilterDetectedWithCitationResultAllOfCitation citation) { + this.citation = citation; + return this; + } + + /** + * Get citation + * + * @return citation The citation of this {@link ContentFilterDetectedWithCitationResult} instance. + */ + @Nonnull + public ContentFilterDetectedWithCitationResultAllOfCitation getCitation() { + return citation; + } + + /** + * Set the citation of this {@link ContentFilterDetectedWithCitationResult} instance. + * + * @param citation The citation of this {@link ContentFilterDetectedWithCitationResult} + */ + public void setCitation( + @Nullable final ContentFilterDetectedWithCitationResultAllOfCitation citation) { + this.citation = citation; + } + + /** + * Get the names of the unrecognizable properties of the {@link + * ContentFilterDetectedWithCitationResult}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link + * ContentFilterDetectedWithCitationResult} instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ContentFilterDetectedWithCitationResult has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ContentFilterDetectedWithCitationResult} + * 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ContentFilterDetectedWithCitationResult contentFilterDetectedWithCitationResult = + (ContentFilterDetectedWithCitationResult) o; + return Objects.equals( + this.cloudSdkCustomFields, contentFilterDetectedWithCitationResult.cloudSdkCustomFields) + && Objects.equals(this.filtered, contentFilterDetectedWithCitationResult.filtered) + && Objects.equals(this.detected, contentFilterDetectedWithCitationResult.detected) + && Objects.equals(this.citation, contentFilterDetectedWithCitationResult.citation); + } + + @Override + public int hashCode() { + return Objects.hash(filtered, detected, citation, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ContentFilterDetectedWithCitationResult {\n"); + sb.append(" filtered: ").append(toIndentedString(filtered)).append("\n"); + sb.append(" detected: ").append(toIndentedString(detected)).append("\n"); + sb.append(" citation: ").append(toIndentedString(citation)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ContentFilterDetectedWithCitationResultAllOfCitation.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ContentFilterDetectedWithCitationResultAllOfCitation.java new file mode 100644 index 000000000..563cb5a15 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ContentFilterDetectedWithCitationResultAllOfCitation.java @@ -0,0 +1,205 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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; + +/** ContentFilterDetectedWithCitationResultAllOfCitation */ +// CHECKSTYLE:OFF +public class ContentFilterDetectedWithCitationResultAllOfCitation +// CHECKSTYLE:ON +{ + @JsonProperty("URL") + private String URL; + + @JsonProperty("license") + private String license; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the URL of this {@link ContentFilterDetectedWithCitationResultAllOfCitation} instance and + * return the same instance. + * + * @param URL The URL of this {@link ContentFilterDetectedWithCitationResultAllOfCitation} + * @return The same instance of this {@link ContentFilterDetectedWithCitationResultAllOfCitation} + * class + */ + @Nonnull + public ContentFilterDetectedWithCitationResultAllOfCitation URL(@Nullable final String URL) { + this.URL = URL; + return this; + } + + /** + * Get URL + * + * @return URL The URL of this {@link ContentFilterDetectedWithCitationResultAllOfCitation} + * instance. + */ + @Nonnull + public String getURL() { + return URL; + } + + /** + * Set the URL of this {@link ContentFilterDetectedWithCitationResultAllOfCitation} instance. + * + * @param URL The URL of this {@link ContentFilterDetectedWithCitationResultAllOfCitation} + */ + public void setURL(@Nullable final String URL) { + this.URL = URL; + } + + /** + * Set the license of this {@link ContentFilterDetectedWithCitationResultAllOfCitation} instance + * and return the same instance. + * + * @param license The license of this {@link ContentFilterDetectedWithCitationResultAllOfCitation} + * @return The same instance of this {@link ContentFilterDetectedWithCitationResultAllOfCitation} + * class + */ + @Nonnull + public ContentFilterDetectedWithCitationResultAllOfCitation license( + @Nullable final String license) { + this.license = license; + return this; + } + + /** + * Get license + * + * @return license The license of this {@link + * ContentFilterDetectedWithCitationResultAllOfCitation} instance. + */ + @Nonnull + public String getLicense() { + return license; + } + + /** + * Set the license of this {@link ContentFilterDetectedWithCitationResultAllOfCitation} instance. + * + * @param license The license of this {@link ContentFilterDetectedWithCitationResultAllOfCitation} + */ + public void setLicense(@Nullable final String license) { + this.license = license; + } + + /** + * Get the names of the unrecognizable properties of the {@link + * ContentFilterDetectedWithCitationResultAllOfCitation}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link + * ContentFilterDetectedWithCitationResultAllOfCitation} instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ContentFilterDetectedWithCitationResultAllOfCitation has no field with name '" + + name + + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link + * ContentFilterDetectedWithCitationResultAllOfCitation} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ContentFilterDetectedWithCitationResultAllOfCitation + contentFilterDetectedWithCitationResultAllOfCitation = + (ContentFilterDetectedWithCitationResultAllOfCitation) o; + return Objects.equals( + this.cloudSdkCustomFields, + contentFilterDetectedWithCitationResultAllOfCitation.cloudSdkCustomFields) + && Objects.equals(this.URL, contentFilterDetectedWithCitationResultAllOfCitation.URL) + && Objects.equals( + this.license, contentFilterDetectedWithCitationResultAllOfCitation.license); + } + + @Override + public int hashCode() { + return Objects.hash(URL, license, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ContentFilterDetectedWithCitationResultAllOfCitation {\n"); + sb.append(" URL: ").append(toIndentedString(URL)).append("\n"); + sb.append(" license: ").append(toIndentedString(license)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ContentFilterPromptResults.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ContentFilterPromptResults.java new file mode 100644 index 000000000..844c6f6f1 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ContentFilterPromptResults.java @@ -0,0 +1,384 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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; + +/** + * Information about the content filtering category (hate, sexual, violence, self_harm), if it has + * been detected, as well as the severity level (very_low, low, medium, high-scale that determines + * the intensity and risk level of harmful content) and if it has been filtered or not. Information + * about jailbreak content and profanity, if it has been detected, and if it has been filtered or + * not. And information about customer block list, if it has been filtered and its id. + */ +// CHECKSTYLE:OFF +public class ContentFilterPromptResults +// CHECKSTYLE:ON +{ + @JsonProperty("sexual") + private ContentFilterSeverityResult sexual; + + @JsonProperty("violence") + private ContentFilterSeverityResult violence; + + @JsonProperty("hate") + private ContentFilterSeverityResult hate; + + @JsonProperty("self_harm") + private ContentFilterSeverityResult selfHarm; + + @JsonProperty("profanity") + private ContentFilterDetectedResult profanity; + + @JsonProperty("error") + private ErrorBase error; + + @JsonProperty("jailbreak") + private ContentFilterDetectedResult jailbreak; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the sexual of this {@link ContentFilterPromptResults} instance and return the same + * instance. + * + * @param sexual The sexual of this {@link ContentFilterPromptResults} + * @return The same instance of this {@link ContentFilterPromptResults} class + */ + @Nonnull + public ContentFilterPromptResults sexual(@Nullable final ContentFilterSeverityResult sexual) { + this.sexual = sexual; + return this; + } + + /** + * Get sexual + * + * @return sexual The sexual of this {@link ContentFilterPromptResults} instance. + */ + @Nonnull + public ContentFilterSeverityResult getSexual() { + return sexual; + } + + /** + * Set the sexual of this {@link ContentFilterPromptResults} instance. + * + * @param sexual The sexual of this {@link ContentFilterPromptResults} + */ + public void setSexual(@Nullable final ContentFilterSeverityResult sexual) { + this.sexual = sexual; + } + + /** + * Set the violence of this {@link ContentFilterPromptResults} instance and return the same + * instance. + * + * @param violence The violence of this {@link ContentFilterPromptResults} + * @return The same instance of this {@link ContentFilterPromptResults} class + */ + @Nonnull + public ContentFilterPromptResults violence(@Nullable final ContentFilterSeverityResult violence) { + this.violence = violence; + return this; + } + + /** + * Get violence + * + * @return violence The violence of this {@link ContentFilterPromptResults} instance. + */ + @Nonnull + public ContentFilterSeverityResult getViolence() { + return violence; + } + + /** + * Set the violence of this {@link ContentFilterPromptResults} instance. + * + * @param violence The violence of this {@link ContentFilterPromptResults} + */ + public void setViolence(@Nullable final ContentFilterSeverityResult violence) { + this.violence = violence; + } + + /** + * Set the hate of this {@link ContentFilterPromptResults} instance and return the same instance. + * + * @param hate The hate of this {@link ContentFilterPromptResults} + * @return The same instance of this {@link ContentFilterPromptResults} class + */ + @Nonnull + public ContentFilterPromptResults hate(@Nullable final ContentFilterSeverityResult hate) { + this.hate = hate; + return this; + } + + /** + * Get hate + * + * @return hate The hate of this {@link ContentFilterPromptResults} instance. + */ + @Nonnull + public ContentFilterSeverityResult getHate() { + return hate; + } + + /** + * Set the hate of this {@link ContentFilterPromptResults} instance. + * + * @param hate The hate of this {@link ContentFilterPromptResults} + */ + public void setHate(@Nullable final ContentFilterSeverityResult hate) { + this.hate = hate; + } + + /** + * Set the selfHarm of this {@link ContentFilterPromptResults} instance and return the same + * instance. + * + * @param selfHarm The selfHarm of this {@link ContentFilterPromptResults} + * @return The same instance of this {@link ContentFilterPromptResults} class + */ + @Nonnull + public ContentFilterPromptResults selfHarm(@Nullable final ContentFilterSeverityResult selfHarm) { + this.selfHarm = selfHarm; + return this; + } + + /** + * Get selfHarm + * + * @return selfHarm The selfHarm of this {@link ContentFilterPromptResults} instance. + */ + @Nonnull + public ContentFilterSeverityResult getSelfHarm() { + return selfHarm; + } + + /** + * Set the selfHarm of this {@link ContentFilterPromptResults} instance. + * + * @param selfHarm The selfHarm of this {@link ContentFilterPromptResults} + */ + public void setSelfHarm(@Nullable final ContentFilterSeverityResult selfHarm) { + this.selfHarm = selfHarm; + } + + /** + * Set the profanity of this {@link ContentFilterPromptResults} instance and return the same + * instance. + * + * @param profanity The profanity of this {@link ContentFilterPromptResults} + * @return The same instance of this {@link ContentFilterPromptResults} class + */ + @Nonnull + public ContentFilterPromptResults profanity( + @Nullable final ContentFilterDetectedResult profanity) { + this.profanity = profanity; + return this; + } + + /** + * Get profanity + * + * @return profanity The profanity of this {@link ContentFilterPromptResults} instance. + */ + @Nonnull + public ContentFilterDetectedResult getProfanity() { + return profanity; + } + + /** + * Set the profanity of this {@link ContentFilterPromptResults} instance. + * + * @param profanity The profanity of this {@link ContentFilterPromptResults} + */ + public void setProfanity(@Nullable final ContentFilterDetectedResult profanity) { + this.profanity = profanity; + } + + /** + * Set the error of this {@link ContentFilterPromptResults} instance and return the same instance. + * + * @param error The error of this {@link ContentFilterPromptResults} + * @return The same instance of this {@link ContentFilterPromptResults} class + */ + @Nonnull + public ContentFilterPromptResults error(@Nullable final ErrorBase error) { + this.error = error; + return this; + } + + /** + * Get error + * + * @return error The error of this {@link ContentFilterPromptResults} instance. + */ + @Nonnull + public ErrorBase getError() { + return error; + } + + /** + * Set the error of this {@link ContentFilterPromptResults} instance. + * + * @param error The error of this {@link ContentFilterPromptResults} + */ + public void setError(@Nullable final ErrorBase error) { + this.error = error; + } + + /** + * Set the jailbreak of this {@link ContentFilterPromptResults} instance and return the same + * instance. + * + * @param jailbreak The jailbreak of this {@link ContentFilterPromptResults} + * @return The same instance of this {@link ContentFilterPromptResults} class + */ + @Nonnull + public ContentFilterPromptResults jailbreak( + @Nullable final ContentFilterDetectedResult jailbreak) { + this.jailbreak = jailbreak; + return this; + } + + /** + * Get jailbreak + * + * @return jailbreak The jailbreak of this {@link ContentFilterPromptResults} instance. + */ + @Nonnull + public ContentFilterDetectedResult getJailbreak() { + return jailbreak; + } + + /** + * Set the jailbreak of this {@link ContentFilterPromptResults} instance. + * + * @param jailbreak The jailbreak of this {@link ContentFilterPromptResults} + */ + public void setJailbreak(@Nullable final ContentFilterDetectedResult jailbreak) { + this.jailbreak = jailbreak; + } + + /** + * Get the names of the unrecognizable properties of the {@link ContentFilterPromptResults}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ContentFilterPromptResults} + * instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ContentFilterPromptResults has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ContentFilterPromptResults} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ContentFilterPromptResults contentFilterPromptResults = (ContentFilterPromptResults) o; + return Objects.equals( + this.cloudSdkCustomFields, contentFilterPromptResults.cloudSdkCustomFields) + && Objects.equals(this.sexual, contentFilterPromptResults.sexual) + && Objects.equals(this.violence, contentFilterPromptResults.violence) + && Objects.equals(this.hate, contentFilterPromptResults.hate) + && Objects.equals(this.selfHarm, contentFilterPromptResults.selfHarm) + && Objects.equals(this.profanity, contentFilterPromptResults.profanity) + && Objects.equals(this.error, contentFilterPromptResults.error) + && Objects.equals(this.jailbreak, contentFilterPromptResults.jailbreak); + } + + @Override + public int hashCode() { + return Objects.hash( + sexual, violence, hate, selfHarm, profanity, error, jailbreak, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ContentFilterPromptResults {\n"); + sb.append(" sexual: ").append(toIndentedString(sexual)).append("\n"); + sb.append(" violence: ").append(toIndentedString(violence)).append("\n"); + sb.append(" hate: ").append(toIndentedString(hate)).append("\n"); + sb.append(" selfHarm: ").append(toIndentedString(selfHarm)).append("\n"); + sb.append(" profanity: ").append(toIndentedString(profanity)).append("\n"); + sb.append(" error: ").append(toIndentedString(error)).append("\n"); + sb.append(" jailbreak: ").append(toIndentedString(jailbreak)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ContentFilterResultBase.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ContentFilterResultBase.java new file mode 100644 index 000000000..6148b8434 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ContentFilterResultBase.java @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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; + +/** ContentFilterResultBase */ +// CHECKSTYLE:OFF +public class ContentFilterResultBase +// CHECKSTYLE:ON +{ + @JsonProperty("filtered") + private Boolean filtered; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the filtered of this {@link ContentFilterResultBase} instance and return the same instance. + * + * @param filtered The filtered of this {@link ContentFilterResultBase} + * @return The same instance of this {@link ContentFilterResultBase} class + */ + @Nonnull + public ContentFilterResultBase filtered(@Nonnull final Boolean filtered) { + this.filtered = filtered; + return this; + } + + /** + * Get filtered + * + * @return filtered The filtered of this {@link ContentFilterResultBase} instance. + */ + @Nonnull + public Boolean isFiltered() { + return filtered; + } + + /** + * Set the filtered of this {@link ContentFilterResultBase} instance. + * + * @param filtered The filtered of this {@link ContentFilterResultBase} + */ + public void setFiltered(@Nonnull final Boolean filtered) { + this.filtered = filtered; + } + + /** + * Get the names of the unrecognizable properties of the {@link ContentFilterResultBase}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ContentFilterResultBase} instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ContentFilterResultBase has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ContentFilterResultBase} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ContentFilterResultBase contentFilterResultBase = (ContentFilterResultBase) o; + return Objects.equals(this.cloudSdkCustomFields, contentFilterResultBase.cloudSdkCustomFields) + && Objects.equals(this.filtered, contentFilterResultBase.filtered); + } + + @Override + public int hashCode() { + return Objects.hash(filtered, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ContentFilterResultBase {\n"); + sb.append(" filtered: ").append(toIndentedString(filtered)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ContentFilterResultsBase.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ContentFilterResultsBase.java new file mode 100644 index 000000000..967653c9f --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ContentFilterResultsBase.java @@ -0,0 +1,335 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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; + +/** Information about the content filtering results. */ +// CHECKSTYLE:OFF +public class ContentFilterResultsBase +// CHECKSTYLE:ON +{ + @JsonProperty("sexual") + private ContentFilterSeverityResult sexual; + + @JsonProperty("violence") + private ContentFilterSeverityResult violence; + + @JsonProperty("hate") + private ContentFilterSeverityResult hate; + + @JsonProperty("self_harm") + private ContentFilterSeverityResult selfHarm; + + @JsonProperty("profanity") + private ContentFilterDetectedResult profanity; + + @JsonProperty("error") + private ErrorBase error; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the sexual of this {@link ContentFilterResultsBase} instance and return the same instance. + * + * @param sexual The sexual of this {@link ContentFilterResultsBase} + * @return The same instance of this {@link ContentFilterResultsBase} class + */ + @Nonnull + public ContentFilterResultsBase sexual(@Nullable final ContentFilterSeverityResult sexual) { + this.sexual = sexual; + return this; + } + + /** + * Get sexual + * + * @return sexual The sexual of this {@link ContentFilterResultsBase} instance. + */ + @Nonnull + public ContentFilterSeverityResult getSexual() { + return sexual; + } + + /** + * Set the sexual of this {@link ContentFilterResultsBase} instance. + * + * @param sexual The sexual of this {@link ContentFilterResultsBase} + */ + public void setSexual(@Nullable final ContentFilterSeverityResult sexual) { + this.sexual = sexual; + } + + /** + * Set the violence of this {@link ContentFilterResultsBase} instance and return the same + * instance. + * + * @param violence The violence of this {@link ContentFilterResultsBase} + * @return The same instance of this {@link ContentFilterResultsBase} class + */ + @Nonnull + public ContentFilterResultsBase violence(@Nullable final ContentFilterSeverityResult violence) { + this.violence = violence; + return this; + } + + /** + * Get violence + * + * @return violence The violence of this {@link ContentFilterResultsBase} instance. + */ + @Nonnull + public ContentFilterSeverityResult getViolence() { + return violence; + } + + /** + * Set the violence of this {@link ContentFilterResultsBase} instance. + * + * @param violence The violence of this {@link ContentFilterResultsBase} + */ + public void setViolence(@Nullable final ContentFilterSeverityResult violence) { + this.violence = violence; + } + + /** + * Set the hate of this {@link ContentFilterResultsBase} instance and return the same instance. + * + * @param hate The hate of this {@link ContentFilterResultsBase} + * @return The same instance of this {@link ContentFilterResultsBase} class + */ + @Nonnull + public ContentFilterResultsBase hate(@Nullable final ContentFilterSeverityResult hate) { + this.hate = hate; + return this; + } + + /** + * Get hate + * + * @return hate The hate of this {@link ContentFilterResultsBase} instance. + */ + @Nonnull + public ContentFilterSeverityResult getHate() { + return hate; + } + + /** + * Set the hate of this {@link ContentFilterResultsBase} instance. + * + * @param hate The hate of this {@link ContentFilterResultsBase} + */ + public void setHate(@Nullable final ContentFilterSeverityResult hate) { + this.hate = hate; + } + + /** + * Set the selfHarm of this {@link ContentFilterResultsBase} instance and return the same + * instance. + * + * @param selfHarm The selfHarm of this {@link ContentFilterResultsBase} + * @return The same instance of this {@link ContentFilterResultsBase} class + */ + @Nonnull + public ContentFilterResultsBase selfHarm(@Nullable final ContentFilterSeverityResult selfHarm) { + this.selfHarm = selfHarm; + return this; + } + + /** + * Get selfHarm + * + * @return selfHarm The selfHarm of this {@link ContentFilterResultsBase} instance. + */ + @Nonnull + public ContentFilterSeverityResult getSelfHarm() { + return selfHarm; + } + + /** + * Set the selfHarm of this {@link ContentFilterResultsBase} instance. + * + * @param selfHarm The selfHarm of this {@link ContentFilterResultsBase} + */ + public void setSelfHarm(@Nullable final ContentFilterSeverityResult selfHarm) { + this.selfHarm = selfHarm; + } + + /** + * Set the profanity of this {@link ContentFilterResultsBase} instance and return the same + * instance. + * + * @param profanity The profanity of this {@link ContentFilterResultsBase} + * @return The same instance of this {@link ContentFilterResultsBase} class + */ + @Nonnull + public ContentFilterResultsBase profanity(@Nullable final ContentFilterDetectedResult profanity) { + this.profanity = profanity; + return this; + } + + /** + * Get profanity + * + * @return profanity The profanity of this {@link ContentFilterResultsBase} instance. + */ + @Nonnull + public ContentFilterDetectedResult getProfanity() { + return profanity; + } + + /** + * Set the profanity of this {@link ContentFilterResultsBase} instance. + * + * @param profanity The profanity of this {@link ContentFilterResultsBase} + */ + public void setProfanity(@Nullable final ContentFilterDetectedResult profanity) { + this.profanity = profanity; + } + + /** + * Set the error of this {@link ContentFilterResultsBase} instance and return the same instance. + * + * @param error The error of this {@link ContentFilterResultsBase} + * @return The same instance of this {@link ContentFilterResultsBase} class + */ + @Nonnull + public ContentFilterResultsBase error(@Nullable final ErrorBase error) { + this.error = error; + return this; + } + + /** + * Get error + * + * @return error The error of this {@link ContentFilterResultsBase} instance. + */ + @Nonnull + public ErrorBase getError() { + return error; + } + + /** + * Set the error of this {@link ContentFilterResultsBase} instance. + * + * @param error The error of this {@link ContentFilterResultsBase} + */ + public void setError(@Nullable final ErrorBase error) { + this.error = error; + } + + /** + * Get the names of the unrecognizable properties of the {@link ContentFilterResultsBase}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ContentFilterResultsBase} instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ContentFilterResultsBase has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ContentFilterResultsBase} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ContentFilterResultsBase contentFilterResultsBase = (ContentFilterResultsBase) o; + return Objects.equals(this.cloudSdkCustomFields, contentFilterResultsBase.cloudSdkCustomFields) + && Objects.equals(this.sexual, contentFilterResultsBase.sexual) + && Objects.equals(this.violence, contentFilterResultsBase.violence) + && Objects.equals(this.hate, contentFilterResultsBase.hate) + && Objects.equals(this.selfHarm, contentFilterResultsBase.selfHarm) + && Objects.equals(this.profanity, contentFilterResultsBase.profanity) + && Objects.equals(this.error, contentFilterResultsBase.error); + } + + @Override + public int hashCode() { + return Objects.hash(sexual, violence, hate, selfHarm, profanity, error, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ContentFilterResultsBase {\n"); + sb.append(" sexual: ").append(toIndentedString(sexual)).append("\n"); + sb.append(" violence: ").append(toIndentedString(violence)).append("\n"); + sb.append(" hate: ").append(toIndentedString(hate)).append("\n"); + sb.append(" selfHarm: ").append(toIndentedString(selfHarm)).append("\n"); + sb.append(" profanity: ").append(toIndentedString(profanity)).append("\n"); + sb.append(" error: ").append(toIndentedString(error)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ContentFilterSeverityResult.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ContentFilterSeverityResult.java new file mode 100644 index 000000000..784c6bd53 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ContentFilterSeverityResult.java @@ -0,0 +1,254 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +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; + +/** ContentFilterSeverityResult */ +// CHECKSTYLE:OFF +public class ContentFilterSeverityResult +// CHECKSTYLE:ON +{ + @JsonProperty("filtered") + private Boolean filtered; + + /** Gets or Sets severity */ + public enum SeverityEnum { + /** The SAFE option of this ContentFilterSeverityResult */ + SAFE("safe"), + + /** The LOW option of this ContentFilterSeverityResult */ + LOW("low"), + + /** The MEDIUM option of this ContentFilterSeverityResult */ + MEDIUM("medium"), + + /** The HIGH option of this ContentFilterSeverityResult */ + HIGH("high"); + + private String value; + + SeverityEnum(String value) { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value The String value + * @return The enum value of type ContentFilterSeverityResult + */ + @JsonCreator + @Nonnull + public static SeverityEnum fromValue(@Nonnull final String value) { + for (SeverityEnum b : SeverityEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("severity") + private SeverityEnum severity; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the filtered of this {@link ContentFilterSeverityResult} instance and return the same + * instance. + * + * @param filtered The filtered of this {@link ContentFilterSeverityResult} + * @return The same instance of this {@link ContentFilterSeverityResult} class + */ + @Nonnull + public ContentFilterSeverityResult filtered(@Nonnull final Boolean filtered) { + this.filtered = filtered; + return this; + } + + /** + * Get filtered + * + * @return filtered The filtered of this {@link ContentFilterSeverityResult} instance. + */ + @Nonnull + public Boolean isFiltered() { + return filtered; + } + + /** + * Set the filtered of this {@link ContentFilterSeverityResult} instance. + * + * @param filtered The filtered of this {@link ContentFilterSeverityResult} + */ + public void setFiltered(@Nonnull final Boolean filtered) { + this.filtered = filtered; + } + + /** + * Set the severity of this {@link ContentFilterSeverityResult} instance and return the same + * instance. + * + * @param severity The severity of this {@link ContentFilterSeverityResult} + * @return The same instance of this {@link ContentFilterSeverityResult} class + */ + @Nonnull + public ContentFilterSeverityResult severity(@Nonnull final SeverityEnum severity) { + this.severity = severity; + return this; + } + + /** + * Get severity + * + * @return severity The severity of this {@link ContentFilterSeverityResult} instance. + */ + @Nonnull + public SeverityEnum getSeverity() { + return severity; + } + + /** + * Set the severity of this {@link ContentFilterSeverityResult} instance. + * + * @param severity The severity of this {@link ContentFilterSeverityResult} + */ + public void setSeverity(@Nonnull final SeverityEnum severity) { + this.severity = severity; + } + + /** + * Get the names of the unrecognizable properties of the {@link ContentFilterSeverityResult}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ContentFilterSeverityResult} + * instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ContentFilterSeverityResult has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ContentFilterSeverityResult} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ContentFilterSeverityResult contentFilterSeverityResult = (ContentFilterSeverityResult) o; + return Objects.equals( + this.cloudSdkCustomFields, contentFilterSeverityResult.cloudSdkCustomFields) + && Objects.equals(this.filtered, contentFilterSeverityResult.filtered) + && Objects.equals(this.severity, contentFilterSeverityResult.severity); + } + + @Override + public int hashCode() { + return Objects.hash(filtered, severity, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ContentFilterSeverityResult {\n"); + sb.append(" filtered: ").append(toIndentedString(filtered)).append("\n"); + sb.append(" severity: ").append(toIndentedString(severity)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/CreateChatCompletionRequest.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/CreateChatCompletionRequest.java new file mode 100644 index 000000000..62aa5f0f8 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/CreateChatCompletionRequest.java @@ -0,0 +1,1156 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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.math.BigDecimal; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** CreateChatCompletionRequest */ +// CHECKSTYLE:OFF +public class CreateChatCompletionRequest +// CHECKSTYLE:ON +{ + @JsonProperty("temperature") + private BigDecimal temperature = new BigDecimal("1"); + + @JsonProperty("top_p") + private BigDecimal topP = new BigDecimal("1"); + + @JsonProperty("stream") + private Boolean stream = false; + + @JsonProperty("stop") + private CreateChatCompletionRequestAllOfStop stop = null; + + @JsonProperty("max_tokens") + private Integer maxTokens; + + @JsonProperty("max_completion_tokens") + private Integer maxCompletionTokens; + + @JsonProperty("presence_penalty") + private BigDecimal presencePenalty = new BigDecimal("0"); + + @JsonProperty("frequency_penalty") + private BigDecimal frequencyPenalty = new BigDecimal("0"); + + @JsonProperty("logit_bias") + private Map logitBias; + + @JsonProperty("user") + private String user; + + @JsonProperty("messages") + private List messages = new ArrayList<>(); + + // @JsonProperty("data_sources") // IGNORED TODO + // private List dataSources = new ArrayList<>(); + + @JsonProperty("logprobs") + private Boolean logprobs = false; + + @JsonProperty("top_logprobs") + private Integer topLogprobs; + + @JsonProperty("n") + private Integer n = 1; + + @JsonProperty("parallel_tool_calls") + private Boolean parallelToolCalls = true; + + @JsonProperty("response_format") + private CreateChatCompletionRequestAllOfResponseFormat responseFormat; + + @JsonProperty("seed") + private Integer seed; + + @JsonProperty("stream_options") + private ChatCompletionStreamOptions streamOptions; + + @JsonProperty("tools") + private List tools = new ArrayList<>(); + + @JsonProperty("tool_choice") + private ChatCompletionToolChoiceOption toolChoice; + + @JsonProperty("function_call") + private CreateChatCompletionRequestAllOfFunctionCall functionCall; + + @JsonProperty("functions") + private List functions = new ArrayList<>(); + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the temperature of this {@link CreateChatCompletionRequest} instance and return the same + * instance. + * + * @param temperature What sampling temperature to use, between 0 and 2. Higher values like 0.8 + * will make the output more random, while lower values like 0.2 will make it more focused and + * deterministic. We generally recommend altering this or `top_p` but not both. + * Minimum: 0 Maximum: 2 + * @return The same instance of this {@link CreateChatCompletionRequest} class + */ + @Nonnull + public CreateChatCompletionRequest temperature(@Nullable final BigDecimal temperature) { + this.temperature = temperature; + return this; + } + + /** + * What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output + * more random, while lower values like 0.2 will make it more focused and deterministic. We + * generally recommend altering this or `top_p` but not both. minimum: 0 maximum: 2 + * + * @return temperature The temperature of this {@link CreateChatCompletionRequest} instance. + */ + @Nullable + public BigDecimal getTemperature() { + return temperature; + } + + /** + * Set the temperature of this {@link CreateChatCompletionRequest} instance. + * + * @param temperature What sampling temperature to use, between 0 and 2. Higher values like 0.8 + * will make the output more random, while lower values like 0.2 will make it more focused and + * deterministic. We generally recommend altering this or `top_p` but not both. + * Minimum: 0 Maximum: 2 + */ + public void setTemperature(@Nullable final BigDecimal temperature) { + this.temperature = temperature; + } + + /** + * Set the topP of this {@link CreateChatCompletionRequest} instance and return the same instance. + * + * @param topP An alternative to sampling with temperature, called nucleus sampling, where the + * model considers the results of the tokens with top_p probability mass. So 0.1 means only + * the tokens comprising the top 10% probability mass are considered. We generally recommend + * altering this or `temperature` but not both. Minimum: 0 Maximum: 1 + * @return The same instance of this {@link CreateChatCompletionRequest} class + */ + @Nonnull + public CreateChatCompletionRequest topP(@Nullable final BigDecimal topP) { + this.topP = topP; + return this; + } + + /** + * An alternative to sampling with temperature, called nucleus sampling, where the model considers + * the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising + * the top 10% probability mass are considered. We generally recommend altering this or + * `temperature` but not both. minimum: 0 maximum: 1 + * + * @return topP The topP of this {@link CreateChatCompletionRequest} instance. + */ + @Nullable + public BigDecimal getTopP() { + return topP; + } + + /** + * Set the topP of this {@link CreateChatCompletionRequest} instance. + * + * @param topP An alternative to sampling with temperature, called nucleus sampling, where the + * model considers the results of the tokens with top_p probability mass. So 0.1 means only + * the tokens comprising the top 10% probability mass are considered. We generally recommend + * altering this or `temperature` but not both. Minimum: 0 Maximum: 1 + */ + public void setTopP(@Nullable final BigDecimal topP) { + this.topP = topP; + } + + /** + * Set the stream of this {@link CreateChatCompletionRequest} instance and return the same + * instance. + * + * @param stream If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent + * as data-only [server-sent + * events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) + * as they become available, with the stream terminated by a `data: [DONE]` message. + * [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions). + * @return The same instance of this {@link CreateChatCompletionRequest} class + */ + @Nonnull + public CreateChatCompletionRequest stream(@Nullable final Boolean stream) { + this.stream = stream; + return this; + } + + /** + * If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only + * [server-sent + * events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) + * as they become available, with the stream terminated by a `data: [DONE]` message. + * [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions). + * + * @return stream The stream of this {@link CreateChatCompletionRequest} instance. + */ + @Nullable + public Boolean isStream() { + return stream; + } + + /** + * Set the stream of this {@link CreateChatCompletionRequest} instance. + * + * @param stream If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent + * as data-only [server-sent + * events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) + * as they become available, with the stream terminated by a `data: [DONE]` message. + * [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions). + */ + public void setStream(@Nullable final Boolean stream) { + this.stream = stream; + } + + /** + * Set the stop of this {@link CreateChatCompletionRequest} instance and return the same instance. + * + * @param stop The stop of this {@link CreateChatCompletionRequest} + * @return The same instance of this {@link CreateChatCompletionRequest} class + */ + @Nonnull + public CreateChatCompletionRequest stop( + @Nullable final CreateChatCompletionRequestAllOfStop stop) { + this.stop = stop; + return this; + } + + /** + * Get stop + * + * @return stop The stop of this {@link CreateChatCompletionRequest} instance. + */ + @Nonnull + public CreateChatCompletionRequestAllOfStop getStop() { + return stop; + } + + /** + * Set the stop of this {@link CreateChatCompletionRequest} instance. + * + * @param stop The stop of this {@link CreateChatCompletionRequest} + */ + public void setStop(@Nullable final CreateChatCompletionRequestAllOfStop stop) { + this.stop = stop; + } + + /** + * Set the maxTokens of this {@link CreateChatCompletionRequest} instance and return the same + * instance. + * + * @param maxTokens The maximum number of [tokens](/tokenizer) that can be generated in the chat + * completion. The total length of input tokens and generated tokens is limited by the + * model's context length. [Example Python + * code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting + * tokens. + * @return The same instance of this {@link CreateChatCompletionRequest} class + */ + @Nonnull + public CreateChatCompletionRequest maxTokens(@Nullable final Integer maxTokens) { + this.maxTokens = maxTokens; + return this; + } + + /** + * The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. The + * total length of input tokens and generated tokens is limited by the model's context length. + * [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) + * for counting tokens. + * + * @return maxTokens The maxTokens of this {@link CreateChatCompletionRequest} instance. + */ + @Nullable + public Integer getMaxTokens() { + return maxTokens; + } + + /** + * Set the maxTokens of this {@link CreateChatCompletionRequest} instance. + * + * @param maxTokens The maximum number of [tokens](/tokenizer) that can be generated in the chat + * completion. The total length of input tokens and generated tokens is limited by the + * model's context length. [Example Python + * code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting + * tokens. + */ + public void setMaxTokens(@Nullable final Integer maxTokens) { + this.maxTokens = maxTokens; + } + + /** + * Set the maxCompletionTokens of this {@link CreateChatCompletionRequest} instance and return the + * same instance. + * + * @param maxCompletionTokens An upper bound for the number of tokens that can be generated for a + * completion, including visible output tokens and reasoning tokens. + * @return The same instance of this {@link CreateChatCompletionRequest} class + */ + @Nonnull + public CreateChatCompletionRequest maxCompletionTokens( + @Nullable final Integer maxCompletionTokens) { + this.maxCompletionTokens = maxCompletionTokens; + return this; + } + + /** + * An upper bound for the number of tokens that can be generated for a completion, including + * visible output tokens and reasoning tokens. + * + * @return maxCompletionTokens The maxCompletionTokens of this {@link CreateChatCompletionRequest} + * instance. + */ + @Nullable + public Integer getMaxCompletionTokens() { + return maxCompletionTokens; + } + + /** + * Set the maxCompletionTokens of this {@link CreateChatCompletionRequest} instance. + * + * @param maxCompletionTokens An upper bound for the number of tokens that can be generated for a + * completion, including visible output tokens and reasoning tokens. + */ + public void setMaxCompletionTokens(@Nullable final Integer maxCompletionTokens) { + this.maxCompletionTokens = maxCompletionTokens; + } + + /** + * Set the presencePenalty of this {@link CreateChatCompletionRequest} instance and return the + * same instance. + * + * @param presencePenalty Number between -2.0 and 2.0. Positive values penalize new tokens based + * on whether they appear in the text so far, increasing the model's likelihood to talk + * about new topics. Minimum: -2 Maximum: 2 + * @return The same instance of this {@link CreateChatCompletionRequest} class + */ + @Nonnull + public CreateChatCompletionRequest presencePenalty(@Nullable final BigDecimal presencePenalty) { + this.presencePenalty = presencePenalty; + return this; + } + + /** + * Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear + * in the text so far, increasing the model's likelihood to talk about new topics. minimum: -2 + * maximum: 2 + * + * @return presencePenalty The presencePenalty of this {@link CreateChatCompletionRequest} + * instance. + */ + @Nullable + public BigDecimal getPresencePenalty() { + return presencePenalty; + } + + /** + * Set the presencePenalty of this {@link CreateChatCompletionRequest} instance. + * + * @param presencePenalty Number between -2.0 and 2.0. Positive values penalize new tokens based + * on whether they appear in the text so far, increasing the model's likelihood to talk + * about new topics. Minimum: -2 Maximum: 2 + */ + public void setPresencePenalty(@Nullable final BigDecimal presencePenalty) { + this.presencePenalty = presencePenalty; + } + + /** + * Set the frequencyPenalty of this {@link CreateChatCompletionRequest} instance and return the + * same instance. + * + * @param frequencyPenalty Number between -2.0 and 2.0. Positive values penalize new tokens based + * on their existing frequency in the text so far, decreasing the model's likelihood to + * repeat the same line verbatim. Minimum: -2 Maximum: 2 + * @return The same instance of this {@link CreateChatCompletionRequest} class + */ + @Nonnull + public CreateChatCompletionRequest frequencyPenalty(@Nullable final BigDecimal frequencyPenalty) { + this.frequencyPenalty = frequencyPenalty; + return this; + } + + /** + * Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing + * frequency in the text so far, decreasing the model's likelihood to repeat the same line + * verbatim. minimum: -2 maximum: 2 + * + * @return frequencyPenalty The frequencyPenalty of this {@link CreateChatCompletionRequest} + * instance. + */ + @Nullable + public BigDecimal getFrequencyPenalty() { + return frequencyPenalty; + } + + /** + * Set the frequencyPenalty of this {@link CreateChatCompletionRequest} instance. + * + * @param frequencyPenalty Number between -2.0 and 2.0. Positive values penalize new tokens based + * on their existing frequency in the text so far, decreasing the model's likelihood to + * repeat the same line verbatim. Minimum: -2 Maximum: 2 + */ + public void setFrequencyPenalty(@Nullable final BigDecimal frequencyPenalty) { + this.frequencyPenalty = frequencyPenalty; + } + + /** + * Set the logitBias of this {@link CreateChatCompletionRequest} instance and return the same + * instance. + * + * @param logitBias Modify the likelihood of specified tokens appearing in the completion. Accepts + * a JSON object that maps tokens (specified by their token ID in the tokenizer) to an + * associated bias value from -100 to 100. Mathematically, the bias is added to the logits + * generated by the model prior to sampling. The exact effect will vary per model, but values + * between -1 and 1 should decrease or increase likelihood of selection; values like -100 or + * 100 should result in a ban or exclusive selection of the relevant token. + * @return The same instance of this {@link CreateChatCompletionRequest} class + */ + @Nonnull + public CreateChatCompletionRequest logitBias(@Nullable final Map logitBias) { + this.logitBias = logitBias; + return this; + } + + /** + * Put one logitBias instance to this {@link CreateChatCompletionRequest} instance. + * + * @param key The String key of this logitBias instance + * @param logitBiasItem The logitBias that should be added under the given key + * @return The same instance of type {@link CreateChatCompletionRequest} + */ + @Nonnull + public CreateChatCompletionRequest putlogitBiasItem( + @Nonnull final String key, @Nonnull final Integer logitBiasItem) { + if (this.logitBias == null) { + this.logitBias = new HashMap<>(); + } + this.logitBias.put(key, logitBiasItem); + return this; + } + + /** + * Modify the likelihood of specified tokens appearing in the completion. Accepts a JSON object + * that maps tokens (specified by their token ID in the tokenizer) to an associated bias value + * from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior + * to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease + * or increase likelihood of selection; values like -100 or 100 should result in a ban or + * exclusive selection of the relevant token. + * + * @return logitBias The logitBias of this {@link CreateChatCompletionRequest} instance. + */ + @Nullable + public Map getLogitBias() { + return logitBias; + } + + /** + * Set the logitBias of this {@link CreateChatCompletionRequest} instance. + * + * @param logitBias Modify the likelihood of specified tokens appearing in the completion. Accepts + * a JSON object that maps tokens (specified by their token ID in the tokenizer) to an + * associated bias value from -100 to 100. Mathematically, the bias is added to the logits + * generated by the model prior to sampling. The exact effect will vary per model, but values + * between -1 and 1 should decrease or increase likelihood of selection; values like -100 or + * 100 should result in a ban or exclusive selection of the relevant token. + */ + public void setLogitBias(@Nullable final Map logitBias) { + this.logitBias = logitBias; + } + + /** + * Set the user of this {@link CreateChatCompletionRequest} instance and return the same instance. + * + * @param user A unique identifier representing your end-user, which can help to monitor and + * detect abuse. + * @return The same instance of this {@link CreateChatCompletionRequest} class + */ + @Nonnull + public CreateChatCompletionRequest user(@Nullable final String user) { + this.user = user; + return this; + } + + /** + * A unique identifier representing your end-user, which can help to monitor and detect abuse. + * + * @return user The user of this {@link CreateChatCompletionRequest} instance. + */ + @Nonnull + public String getUser() { + return user; + } + + /** + * Set the user of this {@link CreateChatCompletionRequest} instance. + * + * @param user A unique identifier representing your end-user, which can help to monitor and + * detect abuse. + */ + public void setUser(@Nullable final String user) { + this.user = user; + } + + /** + * Set the messages of this {@link CreateChatCompletionRequest} instance and return the same + * instance. + * + * @param messages A list of messages comprising the conversation so far. [Example Python + * code](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_format_inputs_to_ChatGPT_models.ipynb). + * @return The same instance of this {@link CreateChatCompletionRequest} class + */ + @Nonnull + public CreateChatCompletionRequest messages( + @Nonnull final List messages) { + this.messages = messages; + return this; + } + + /** + * Add one messages instance to this {@link CreateChatCompletionRequest}. + * + * @param messagesItem The messages that should be added + * @return The same instance of type {@link CreateChatCompletionRequest} + */ + @Nonnull + public CreateChatCompletionRequest addMessagesItem( + @Nonnull final ChatCompletionRequestMessage messagesItem) { + if (this.messages == null) { + this.messages = new ArrayList<>(); + } + this.messages.add(messagesItem); + return this; + } + + /** + * A list of messages comprising the conversation so far. [Example Python + * code](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_format_inputs_to_ChatGPT_models.ipynb). + * + * @return messages The messages of this {@link CreateChatCompletionRequest} instance. + */ + @Nonnull + public List getMessages() { + return messages; + } + + /** + * Set the messages of this {@link CreateChatCompletionRequest} instance. + * + * @param messages A list of messages comprising the conversation so far. [Example Python + * code](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_format_inputs_to_ChatGPT_models.ipynb). + */ + public void setMessages(@Nonnull final List messages) { + this.messages = messages; + } + + /** + * Set the logprobs of this {@link CreateChatCompletionRequest} instance and return the same + * instance. + * + * @param logprobs Whether to return log probabilities of the output tokens or not. If true, + * returns the log probabilities of each output token returned in the `content` of + * `message`. + * @return The same instance of this {@link CreateChatCompletionRequest} class + */ + @Nonnull + public CreateChatCompletionRequest logprobs(@Nullable final Boolean logprobs) { + this.logprobs = logprobs; + return this; + } + + /** + * Whether to return log probabilities of the output tokens or not. If true, returns the log + * probabilities of each output token returned in the `content` of `message`. + * + * @return logprobs The logprobs of this {@link CreateChatCompletionRequest} instance. + */ + @Nullable + public Boolean isLogprobs() { + return logprobs; + } + + /** + * Set the logprobs of this {@link CreateChatCompletionRequest} instance. + * + * @param logprobs Whether to return log probabilities of the output tokens or not. If true, + * returns the log probabilities of each output token returned in the `content` of + * `message`. + */ + public void setLogprobs(@Nullable final Boolean logprobs) { + this.logprobs = logprobs; + } + + /** + * Set the topLogprobs of this {@link CreateChatCompletionRequest} instance and return the same + * instance. + * + * @param topLogprobs An integer between 0 and 20 specifying the number of most likely tokens to + * return at each token position, each with an associated log probability. + * `logprobs` must be set to `true` if this parameter is used. Minimum: 0 + * Maximum: 20 + * @return The same instance of this {@link CreateChatCompletionRequest} class + */ + @Nonnull + public CreateChatCompletionRequest topLogprobs(@Nullable final Integer topLogprobs) { + this.topLogprobs = topLogprobs; + return this; + } + + /** + * An integer between 0 and 20 specifying the number of most likely tokens to return at each token + * position, each with an associated log probability. `logprobs` must be set to + * `true` if this parameter is used. minimum: 0 maximum: 20 + * + * @return topLogprobs The topLogprobs of this {@link CreateChatCompletionRequest} instance. + */ + @Nullable + public Integer getTopLogprobs() { + return topLogprobs; + } + + /** + * Set the topLogprobs of this {@link CreateChatCompletionRequest} instance. + * + * @param topLogprobs An integer between 0 and 20 specifying the number of most likely tokens to + * return at each token position, each with an associated log probability. + * `logprobs` must be set to `true` if this parameter is used. Minimum: 0 + * Maximum: 20 + */ + public void setTopLogprobs(@Nullable final Integer topLogprobs) { + this.topLogprobs = topLogprobs; + } + + /** + * Set the n of this {@link CreateChatCompletionRequest} instance and return the same instance. + * + * @param n How many chat completion choices to generate for each input message. Note that you + * will be charged based on the number of generated tokens across all of the choices. Keep + * `n` as `1` to minimize costs. Minimum: 1 Maximum: 128 + * @return The same instance of this {@link CreateChatCompletionRequest} class + */ + @Nonnull + public CreateChatCompletionRequest n(@Nullable final Integer n) { + this.n = n; + return this; + } + + /** + * How many chat completion choices to generate for each input message. Note that you will be + * charged based on the number of generated tokens across all of the choices. Keep `n` + * as `1` to minimize costs. minimum: 1 maximum: 128 + * + * @return n The n of this {@link CreateChatCompletionRequest} instance. + */ + @Nullable + public Integer getN() { + return n; + } + + /** + * Set the n of this {@link CreateChatCompletionRequest} instance. + * + * @param n How many chat completion choices to generate for each input message. Note that you + * will be charged based on the number of generated tokens across all of the choices. Keep + * `n` as `1` to minimize costs. Minimum: 1 Maximum: 128 + */ + public void setN(@Nullable final Integer n) { + this.n = n; + } + + /** + * Set the parallelToolCalls of this {@link CreateChatCompletionRequest} instance and return the + * same instance. + * + * @param parallelToolCalls Whether to enable parallel function calling during tool use. + * @return The same instance of this {@link CreateChatCompletionRequest} class + */ + @Nonnull + public CreateChatCompletionRequest parallelToolCalls(@Nullable final Boolean parallelToolCalls) { + this.parallelToolCalls = parallelToolCalls; + return this; + } + + /** + * Whether to enable parallel function calling during tool use. + * + * @return parallelToolCalls The parallelToolCalls of this {@link CreateChatCompletionRequest} + * instance. + */ + @Nonnull + public Boolean isParallelToolCalls() { + return parallelToolCalls; + } + + /** + * Set the parallelToolCalls of this {@link CreateChatCompletionRequest} instance. + * + * @param parallelToolCalls Whether to enable parallel function calling during tool use. + */ + public void setParallelToolCalls(@Nullable final Boolean parallelToolCalls) { + this.parallelToolCalls = parallelToolCalls; + } + + /** + * Set the responseFormat of this {@link CreateChatCompletionRequest} instance and return the same + * instance. + * + * @param responseFormat The responseFormat of this {@link CreateChatCompletionRequest} + * @return The same instance of this {@link CreateChatCompletionRequest} class + */ + @Nonnull + public CreateChatCompletionRequest responseFormat( + @Nullable final CreateChatCompletionRequestAllOfResponseFormat responseFormat) { + this.responseFormat = responseFormat; + return this; + } + + /** + * Get responseFormat + * + * @return responseFormat The responseFormat of this {@link CreateChatCompletionRequest} instance. + */ + @Nonnull + public CreateChatCompletionRequestAllOfResponseFormat getResponseFormat() { + return responseFormat; + } + + /** + * Set the responseFormat of this {@link CreateChatCompletionRequest} instance. + * + * @param responseFormat The responseFormat of this {@link CreateChatCompletionRequest} + */ + public void setResponseFormat( + @Nullable final CreateChatCompletionRequestAllOfResponseFormat responseFormat) { + this.responseFormat = responseFormat; + } + + /** + * Set the seed of this {@link CreateChatCompletionRequest} instance and return the same instance. + * + * @param seed This feature is in Beta. If specified, our system will make a best effort to sample + * deterministically, such that repeated requests with the same `seed` and + * parameters should return the same result. Determinism is not guaranteed, and you should + * refer to the `system_fingerprint` response parameter to monitor changes in the + * backend. Minimum: -9223372036854775808 Maximum: 9223372036854775807 + * @return The same instance of this {@link CreateChatCompletionRequest} class + */ + @Nonnull + public CreateChatCompletionRequest seed(@Nullable final Integer seed) { + this.seed = seed; + return this; + } + + /** + * This feature is in Beta. If specified, our system will make a best effort to sample + * deterministically, such that repeated requests with the same `seed` and parameters + * should return the same result. Determinism is not guaranteed, and you should refer to the + * `system_fingerprint` response parameter to monitor changes in the backend. minimum: + * -9223372036854775808 maximum: 9223372036854775807 + * + * @return seed The seed of this {@link CreateChatCompletionRequest} instance. + */ + @Nullable + public Integer getSeed() { + return seed; + } + + /** + * Set the seed of this {@link CreateChatCompletionRequest} instance. + * + * @param seed This feature is in Beta. If specified, our system will make a best effort to sample + * deterministically, such that repeated requests with the same `seed` and + * parameters should return the same result. Determinism is not guaranteed, and you should + * refer to the `system_fingerprint` response parameter to monitor changes in the + * backend. Minimum: -9223372036854775808 Maximum: 9223372036854775807 + */ + public void setSeed(@Nullable final Integer seed) { + this.seed = seed; + } + + /** + * Set the streamOptions of this {@link CreateChatCompletionRequest} instance and return the same + * instance. + * + * @param streamOptions The streamOptions of this {@link CreateChatCompletionRequest} + * @return The same instance of this {@link CreateChatCompletionRequest} class + */ + @Nonnull + public CreateChatCompletionRequest streamOptions( + @Nullable final ChatCompletionStreamOptions streamOptions) { + this.streamOptions = streamOptions; + return this; + } + + /** + * Get streamOptions + * + * @return streamOptions The streamOptions of this {@link CreateChatCompletionRequest} instance. + */ + @Nullable + public ChatCompletionStreamOptions getStreamOptions() { + return streamOptions; + } + + /** + * Set the streamOptions of this {@link CreateChatCompletionRequest} instance. + * + * @param streamOptions The streamOptions of this {@link CreateChatCompletionRequest} + */ + public void setStreamOptions(@Nullable final ChatCompletionStreamOptions streamOptions) { + this.streamOptions = streamOptions; + } + + /** + * Set the tools of this {@link CreateChatCompletionRequest} instance and return the same + * instance. + * + * @param tools A list of tools the model may call. Currently, only functions are supported as a + * tool. Use this to provide a list of functions the model may generate JSON inputs for. A max + * of 128 functions are supported. + * @return The same instance of this {@link CreateChatCompletionRequest} class + */ + @Nonnull + public CreateChatCompletionRequest tools(@Nullable final List tools) { + this.tools = tools; + return this; + } + + /** + * Add one tools instance to this {@link CreateChatCompletionRequest}. + * + * @param toolsItem The tools that should be added + * @return The same instance of type {@link CreateChatCompletionRequest} + */ + @Nonnull + public CreateChatCompletionRequest addToolsItem(@Nonnull final ChatCompletionTool toolsItem) { + if (this.tools == null) { + this.tools = new ArrayList<>(); + } + this.tools.add(toolsItem); + return this; + } + + /** + * A list of tools the model may call. Currently, only functions are supported as a tool. Use this + * to provide a list of functions the model may generate JSON inputs for. A max of 128 functions + * are supported. + * + * @return tools The tools of this {@link CreateChatCompletionRequest} instance. + */ + @Nonnull + public List getTools() { + return tools; + } + + /** + * Set the tools of this {@link CreateChatCompletionRequest} instance. + * + * @param tools A list of tools the model may call. Currently, only functions are supported as a + * tool. Use this to provide a list of functions the model may generate JSON inputs for. A max + * of 128 functions are supported. + */ + public void setTools(@Nullable final List tools) { + this.tools = tools; + } + + /** + * Set the toolChoice of this {@link CreateChatCompletionRequest} instance and return the same + * instance. + * + * @param toolChoice The toolChoice of this {@link CreateChatCompletionRequest} + * @return The same instance of this {@link CreateChatCompletionRequest} class + */ + @Nonnull + public CreateChatCompletionRequest toolChoice( + @Nullable final ChatCompletionToolChoiceOption toolChoice) { + this.toolChoice = toolChoice; + return this; + } + + /** + * Get toolChoice + * + * @return toolChoice The toolChoice of this {@link CreateChatCompletionRequest} instance. + */ + @Nonnull + public ChatCompletionToolChoiceOption getToolChoice() { + return toolChoice; + } + + /** + * Set the toolChoice of this {@link CreateChatCompletionRequest} instance. + * + * @param toolChoice The toolChoice of this {@link CreateChatCompletionRequest} + */ + public void setToolChoice(@Nullable final ChatCompletionToolChoiceOption toolChoice) { + this.toolChoice = toolChoice; + } + + /** + * Set the functionCall of this {@link CreateChatCompletionRequest} instance and return the same + * instance. + * + * @param functionCall The functionCall of this {@link CreateChatCompletionRequest} + * @return The same instance of this {@link CreateChatCompletionRequest} class + */ + @Nonnull + public CreateChatCompletionRequest functionCall( + @Nullable final CreateChatCompletionRequestAllOfFunctionCall functionCall) { + this.functionCall = functionCall; + return this; + } + + /** + * Get functionCall + * + * @return functionCall The functionCall of this {@link CreateChatCompletionRequest} instance. + * @deprecated + */ + @Deprecated + @Nonnull + public CreateChatCompletionRequestAllOfFunctionCall getFunctionCall() { + return functionCall; + } + + /** + * Set the functionCall of this {@link CreateChatCompletionRequest} instance. + * + * @param functionCall The functionCall of this {@link CreateChatCompletionRequest} + */ + public void setFunctionCall( + @Nullable final CreateChatCompletionRequestAllOfFunctionCall functionCall) { + this.functionCall = functionCall; + } + + /** + * Set the functions of this {@link CreateChatCompletionRequest} instance and return the same + * instance. + * + * @param functions Deprecated in favor of `tools`. A list of functions the model may + * generate JSON inputs for. + * @return The same instance of this {@link CreateChatCompletionRequest} class + */ + @Nonnull + public CreateChatCompletionRequest functions( + @Nullable final List functions) { + this.functions = functions; + return this; + } + + /** + * Add one functions instance to this {@link CreateChatCompletionRequest}. + * + * @param functionsItem The functions that should be added + * @return The same instance of type {@link CreateChatCompletionRequest} + */ + @Nonnull + public CreateChatCompletionRequest addFunctionsItem( + @Nonnull final ChatCompletionFunctions functionsItem) { + if (this.functions == null) { + this.functions = new ArrayList<>(); + } + this.functions.add(functionsItem); + return this; + } + + /** + * Deprecated in favor of `tools`. A list of functions the model may generate JSON + * inputs for. + * + * @return functions The functions of this {@link CreateChatCompletionRequest} instance. + * @deprecated + */ + @Deprecated + @Nonnull + public List getFunctions() { + return functions; + } + + /** + * Set the functions of this {@link CreateChatCompletionRequest} instance. + * + * @param functions Deprecated in favor of `tools`. A list of functions the model may + * generate JSON inputs for. + */ + public void setFunctions(@Nullable final List functions) { + this.functions = functions; + } + + /** + * Get the names of the unrecognizable properties of the {@link CreateChatCompletionRequest}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link CreateChatCompletionRequest} + * instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "CreateChatCompletionRequest has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link CreateChatCompletionRequest} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final CreateChatCompletionRequest createChatCompletionRequest = (CreateChatCompletionRequest) o; + return Objects.equals( + this.cloudSdkCustomFields, createChatCompletionRequest.cloudSdkCustomFields) + && Objects.equals(this.temperature, createChatCompletionRequest.temperature) + && Objects.equals(this.topP, createChatCompletionRequest.topP) + && Objects.equals(this.stream, createChatCompletionRequest.stream) + && Objects.equals(this.stop, createChatCompletionRequest.stop) + && Objects.equals(this.maxTokens, createChatCompletionRequest.maxTokens) + && Objects.equals(this.maxCompletionTokens, createChatCompletionRequest.maxCompletionTokens) + && Objects.equals(this.presencePenalty, createChatCompletionRequest.presencePenalty) + && Objects.equals(this.frequencyPenalty, createChatCompletionRequest.frequencyPenalty) + && Objects.equals(this.logitBias, createChatCompletionRequest.logitBias) + && Objects.equals(this.user, createChatCompletionRequest.user) + && Objects.equals(this.messages, createChatCompletionRequest.messages) + && Objects.equals(this.logprobs, createChatCompletionRequest.logprobs) + && Objects.equals(this.topLogprobs, createChatCompletionRequest.topLogprobs) + && Objects.equals(this.n, createChatCompletionRequest.n) + && Objects.equals(this.parallelToolCalls, createChatCompletionRequest.parallelToolCalls) + && Objects.equals(this.responseFormat, createChatCompletionRequest.responseFormat) + && Objects.equals(this.seed, createChatCompletionRequest.seed) + && Objects.equals(this.streamOptions, createChatCompletionRequest.streamOptions) + && Objects.equals(this.tools, createChatCompletionRequest.tools) + && Objects.equals(this.toolChoice, createChatCompletionRequest.toolChoice) + && Objects.equals(this.functionCall, createChatCompletionRequest.functionCall) + && Objects.equals(this.functions, createChatCompletionRequest.functions); + } + + @Override + public int hashCode() { + return Objects.hash( + temperature, + topP, + stream, + stop, + maxTokens, + maxCompletionTokens, + presencePenalty, + frequencyPenalty, + logitBias, + user, + messages, + logprobs, + topLogprobs, + n, + parallelToolCalls, + responseFormat, + seed, + streamOptions, + tools, + toolChoice, + functionCall, + functions, + cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class CreateChatCompletionRequest {\n"); + sb.append(" temperature: ").append(toIndentedString(temperature)).append("\n"); + sb.append(" topP: ").append(toIndentedString(topP)).append("\n"); + sb.append(" stream: ").append(toIndentedString(stream)).append("\n"); + sb.append(" stop: ").append(toIndentedString(stop)).append("\n"); + sb.append(" maxTokens: ").append(toIndentedString(maxTokens)).append("\n"); + sb.append(" maxCompletionTokens: ") + .append(toIndentedString(maxCompletionTokens)) + .append("\n"); + sb.append(" presencePenalty: ").append(toIndentedString(presencePenalty)).append("\n"); + sb.append(" frequencyPenalty: ").append(toIndentedString(frequencyPenalty)).append("\n"); + sb.append(" logitBias: ").append(toIndentedString(logitBias)).append("\n"); + sb.append(" user: ").append(toIndentedString(user)).append("\n"); + sb.append(" messages: ").append(toIndentedString(messages)).append("\n"); + sb.append(" logprobs: ").append(toIndentedString(logprobs)).append("\n"); + sb.append(" topLogprobs: ").append(toIndentedString(topLogprobs)).append("\n"); + sb.append(" n: ").append(toIndentedString(n)).append("\n"); + sb.append(" parallelToolCalls: ").append(toIndentedString(parallelToolCalls)).append("\n"); + sb.append(" responseFormat: ").append(toIndentedString(responseFormat)).append("\n"); + sb.append(" seed: ").append(toIndentedString(seed)).append("\n"); + sb.append(" streamOptions: ").append(toIndentedString(streamOptions)).append("\n"); + sb.append(" tools: ").append(toIndentedString(tools)).append("\n"); + sb.append(" toolChoice: ").append(toIndentedString(toolChoice)).append("\n"); + sb.append(" functionCall: ").append(toIndentedString(functionCall)).append("\n"); + sb.append(" functions: ").append(toIndentedString(functions)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/CreateChatCompletionRequestAllOfFunctionCall.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/CreateChatCompletionRequestAllOfFunctionCall.java new file mode 100644 index 000000000..04298e7f2 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/CreateChatCompletionRequestAllOfFunctionCall.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Deprecated in favor of `tool_choice`. Controls which (if any) function is called by the + * model. `none` means the model will not call a function and instead generates a message. + * `auto` means the model can pick between generating a message or calling a function. + * Specifying a particular function via `{\"name\": \"my_function\"}` + * forces the model to call that function. `none` is the default when no functions are + * present. `auto` is the default if functions are present. + * + * @deprecated + */ +@Deprecated +public interface CreateChatCompletionRequestAllOfFunctionCall { + /** + * Helper class to create a ChatCompletionFunctionCallOption that implements {@link + * CreateChatCompletionRequestAllOfFunctionCall}. + */ + record InnerChatCompletionFunctionCallOption(@JsonValue ChatCompletionFunctionCallOption value) + implements CreateChatCompletionRequestAllOfFunctionCall {} + + /** + * Creator to enable deserialization of a ChatCompletionFunctionCallOption. + * + * @param val the value to use + * @return a new instance of {@link InnerChatCompletionFunctionCallOption}. + */ + @JsonCreator + static InnerChatCompletionFunctionCallOption create(ChatCompletionFunctionCallOption val) { + return new InnerChatCompletionFunctionCallOption(val); + } + + /** + * Helper class to create a String that implements {@link + * CreateChatCompletionRequestAllOfFunctionCall}. + */ + record InnerString(@JsonValue String value) + implements CreateChatCompletionRequestAllOfFunctionCall {} + + /** + * Creator to enable deserialization of a String. + * + * @param val the value to use + * @return a new instance of {@link InnerString}. + */ + @JsonCreator + static InnerString create(String val) { + return new InnerString(val); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/CreateChatCompletionRequestAllOfResponseFormat.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/CreateChatCompletionRequestAllOfResponseFormat.java new file mode 100644 index 000000000..0d244ec08 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/CreateChatCompletionRequestAllOfResponseFormat.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +/** + * An object specifying the format that the model must output. Compatible with + * [GPT-4o](https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models#gpt-4-and-gpt-4-turbo-models), + * [GPT-4o + * mini](https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models#gpt-4-and-gpt-4-turbo-models), + * [GPT-4 + * Turbo](https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models#gpt-4-and-gpt-4-turbo-models) + * and all + * [GPT-3.5](https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models#gpt-35) + * Turbo models newer than `gpt-3.5-turbo-1106`. Setting to `{ \"type\": + * \"json_schema\", \"json_schema\": {...} }` enables Structured Outputs + * which guarantees the model will match your supplied JSON schema. Setting to `{ + * \"type\": \"json_object\" }` enables JSON mode, which guarantees the + * message the model generates is valid JSON. **Important:** when using JSON mode, you **must** also + * instruct the model to produce JSON yourself via a system or user message. Without this, the model + * may generate an unending stream of whitespace until the generation reaches the token limit, + * resulting in a long-running and seemingly \"stuck\" request. Also note that the message + * content may be partially cut off if `finish_reason=\"length\"`, which + * indicates the generation exceeded `max_tokens` or the conversation exceeded the max + * context length. + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ResponseFormatJsonObject.class), + @JsonSubTypes.Type(value = ResponseFormatJsonSchema.class), + @JsonSubTypes.Type(value = ResponseFormatText.class), +}) +public interface CreateChatCompletionRequestAllOfResponseFormat {} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/CreateChatCompletionRequestAllOfStop.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/CreateChatCompletionRequestAllOfStop.java new file mode 100644 index 000000000..fde2082dd --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/CreateChatCompletionRequestAllOfStop.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import java.util.List; + +/** Up to 4 sequences where the API will stop generating further tokens. */ +public interface CreateChatCompletionRequestAllOfStop { + /** + * Helper class to create a String that implements {@link CreateChatCompletionRequestAllOfStop}. + */ + record InnerString(@com.fasterxml.jackson.annotation.JsonValue String value) + implements CreateChatCompletionRequestAllOfStop {} + + /** + * Creator to enable deserialization of a String. + * + * @param val the value to use + * @return a new instance of {@link InnerString}. + */ + @com.fasterxml.jackson.annotation.JsonCreator + static InnerString create(String val) { + return new InnerString(val); + } + + /** + * Helper class to create a list of String that implements {@link + * CreateChatCompletionRequestAllOfStop}. + */ + record InnerStrings(@com.fasterxml.jackson.annotation.JsonValue List values) + implements CreateChatCompletionRequestAllOfStop {} + + /** + * Creator to enable deserialization of a list of String. + * + * @param val the value to use + * @return a new instance of {@link InnerStrings}. + */ + @com.fasterxml.jackson.annotation.JsonCreator + static InnerStrings create(List val) { + return new InnerStrings(val); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/CreateChatCompletionResponse.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/CreateChatCompletionResponse.java new file mode 100644 index 000000000..31b205122 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/CreateChatCompletionResponse.java @@ -0,0 +1,534 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** Represents a chat completion response returned by model, based on the provided input. */ +// CHECKSTYLE:OFF +public class CreateChatCompletionResponse implements ChatCompletionsCreate200Response +// CHECKSTYLE:ON +{ + @JsonProperty("id") + private String id; + + @JsonProperty("prompt_filter_results") + private List promptFilterResults = new ArrayList<>(); + + @JsonProperty("choices") + private List choices = new ArrayList<>(); + + @JsonProperty("created") + private Integer created; + + @JsonProperty("model") + private String model; + + @JsonProperty("system_fingerprint") + private String systemFingerprint; + + /** The object type, which is always `chat.completion`. */ + public enum ObjectEnum { + /** The CHAT_COMPLETION option of this CreateChatCompletionResponse */ + CHAT_COMPLETION("chat.completion"), + /** The UNKNOWN_DEFAULT_OPEN_API option of this CreateChatCompletionResponse */ + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + ; + + private String value; + + ObjectEnum(String value) { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value The String value + * @return The enum value of type CreateChatCompletionResponse + */ + @JsonCreator + @Nonnull + public static ObjectEnum fromValue(@Nonnull final String value) { + for (ObjectEnum b : ObjectEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + + @JsonProperty("object") + private ObjectEnum _object; + + @JsonProperty("usage") + private CompletionUsage usage; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the id of this {@link CreateChatCompletionResponse} instance and return the same instance. + * + * @param id A unique identifier for the chat completion. + * @return The same instance of this {@link CreateChatCompletionResponse} class + */ + @Nonnull + public CreateChatCompletionResponse id(@Nonnull final String id) { + this.id = id; + return this; + } + + /** + * A unique identifier for the chat completion. + * + * @return id The id of this {@link CreateChatCompletionResponse} instance. + */ + @Nonnull + public String getId() { + return id; + } + + /** + * Set the id of this {@link CreateChatCompletionResponse} instance. + * + * @param id A unique identifier for the chat completion. + */ + public void setId(@Nonnull final String id) { + this.id = id; + } + + /** + * Set the promptFilterResults of this {@link CreateChatCompletionResponse} instance and return + * the same instance. + * + * @param promptFilterResults Content filtering results for zero or more prompts in the request. + * In a streaming request, results for different prompts may arrive at different times or in + * different orders. + * @return The same instance of this {@link CreateChatCompletionResponse} class + */ + @Nonnull + public CreateChatCompletionResponse promptFilterResults( + @Nullable final List promptFilterResults) { + this.promptFilterResults = promptFilterResults; + return this; + } + + /** + * Add one promptFilterResults instance to this {@link CreateChatCompletionResponse}. + * + * @param promptFilterResultsItem The promptFilterResults that should be added + * @return The same instance of type {@link CreateChatCompletionResponse} + */ + @Nonnull + public CreateChatCompletionResponse addPromptFilterResultsItem( + @Nonnull final PromptFilterResult promptFilterResultsItem) { + if (this.promptFilterResults == null) { + this.promptFilterResults = new ArrayList<>(); + } + this.promptFilterResults.add(promptFilterResultsItem); + return this; + } + + /** + * Content filtering results for zero or more prompts in the request. In a streaming request, + * results for different prompts may arrive at different times or in different orders. + * + * @return promptFilterResults The promptFilterResults of this {@link + * CreateChatCompletionResponse} instance. + */ + @Nonnull + public List getPromptFilterResults() { + return promptFilterResults; + } + + /** + * Set the promptFilterResults of this {@link CreateChatCompletionResponse} instance. + * + * @param promptFilterResults Content filtering results for zero or more prompts in the request. + * In a streaming request, results for different prompts may arrive at different times or in + * different orders. + */ + public void setPromptFilterResults(@Nullable final List promptFilterResults) { + this.promptFilterResults = promptFilterResults; + } + + /** + * Set the choices of this {@link CreateChatCompletionResponse} instance and return the same + * instance. + * + * @param choices A list of chat completion choices. Can be more than one if `n` is + * greater than 1. + * @return The same instance of this {@link CreateChatCompletionResponse} class + */ + @Nonnull + public CreateChatCompletionResponse choices( + @Nonnull final List choices) { + this.choices = choices; + return this; + } + + /** + * Add one choices instance to this {@link CreateChatCompletionResponse}. + * + * @param choicesItem The choices that should be added + * @return The same instance of type {@link CreateChatCompletionResponse} + */ + @Nonnull + public CreateChatCompletionResponse addChoicesItem( + @Nonnull final CreateChatCompletionResponseChoicesInner choicesItem) { + if (this.choices == null) { + this.choices = new ArrayList<>(); + } + this.choices.add(choicesItem); + return this; + } + + /** + * A list of chat completion choices. Can be more than one if `n` is greater than 1. + * + * @return choices The choices of this {@link CreateChatCompletionResponse} instance. + */ + @Nonnull + public List getChoices() { + return choices; + } + + /** + * Set the choices of this {@link CreateChatCompletionResponse} instance. + * + * @param choices A list of chat completion choices. Can be more than one if `n` is + * greater than 1. + */ + public void setChoices(@Nonnull final List choices) { + this.choices = choices; + } + + /** + * Set the created of this {@link CreateChatCompletionResponse} instance and return the same + * instance. + * + * @param created The Unix timestamp (in seconds) of when the chat completion was created. + * @return The same instance of this {@link CreateChatCompletionResponse} class + */ + @Nonnull + public CreateChatCompletionResponse created(@Nonnull final Integer created) { + this.created = created; + return this; + } + + /** + * The Unix timestamp (in seconds) of when the chat completion was created. + * + * @return created The created of this {@link CreateChatCompletionResponse} instance. + */ + @Nonnull + public Integer getCreated() { + return created; + } + + /** + * Set the created of this {@link CreateChatCompletionResponse} instance. + * + * @param created The Unix timestamp (in seconds) of when the chat completion was created. + */ + public void setCreated(@Nonnull final Integer created) { + this.created = created; + } + + /** + * Set the model of this {@link CreateChatCompletionResponse} instance and return the same + * instance. + * + * @param model The model used for the chat completion. + * @return The same instance of this {@link CreateChatCompletionResponse} class + */ + @Nonnull + public CreateChatCompletionResponse model(@Nonnull final String model) { + this.model = model; + return this; + } + + /** + * The model used for the chat completion. + * + * @return model The model of this {@link CreateChatCompletionResponse} instance. + */ + @Nonnull + public String getModel() { + return model; + } + + /** + * Set the model of this {@link CreateChatCompletionResponse} instance. + * + * @param model The model used for the chat completion. + */ + public void setModel(@Nonnull final String model) { + this.model = model; + } + + /** + * Set the systemFingerprint of this {@link CreateChatCompletionResponse} instance and return the + * same instance. + * + * @param systemFingerprint This fingerprint represents the backend configuration that the model + * runs with. Can be used in conjunction with the `seed` request parameter to + * understand when backend changes have been made that might impact determinism. + * @return The same instance of this {@link CreateChatCompletionResponse} class + */ + @Nonnull + public CreateChatCompletionResponse systemFingerprint(@Nullable final String systemFingerprint) { + this.systemFingerprint = systemFingerprint; + return this; + } + + /** + * This fingerprint represents the backend configuration that the model runs with. Can be used in + * conjunction with the `seed` request parameter to understand when backend changes have + * been made that might impact determinism. + * + * @return systemFingerprint The systemFingerprint of this {@link CreateChatCompletionResponse} + * instance. + */ + @Nonnull + public String getSystemFingerprint() { + return systemFingerprint; + } + + /** + * Set the systemFingerprint of this {@link CreateChatCompletionResponse} instance. + * + * @param systemFingerprint This fingerprint represents the backend configuration that the model + * runs with. Can be used in conjunction with the `seed` request parameter to + * understand when backend changes have been made that might impact determinism. + */ + public void setSystemFingerprint(@Nullable final String systemFingerprint) { + this.systemFingerprint = systemFingerprint; + } + + /** + * Set the _object of this {@link CreateChatCompletionResponse} instance and return the same + * instance. + * + * @param _object The object type, which is always `chat.completion`. + * @return The same instance of this {@link CreateChatCompletionResponse} class + */ + @Nonnull + public CreateChatCompletionResponse _object(@Nonnull final ObjectEnum _object) { + this._object = _object; + return this; + } + + /** + * The object type, which is always `chat.completion`. + * + * @return _object The _object of this {@link CreateChatCompletionResponse} instance. + */ + @Nonnull + public ObjectEnum getObject() { + return _object; + } + + /** + * Set the _object of this {@link CreateChatCompletionResponse} instance. + * + * @param _object The object type, which is always `chat.completion`. + */ + public void setObject(@Nonnull final ObjectEnum _object) { + this._object = _object; + } + + /** + * Set the usage of this {@link CreateChatCompletionResponse} instance and return the same + * instance. + * + * @param usage The usage of this {@link CreateChatCompletionResponse} + * @return The same instance of this {@link CreateChatCompletionResponse} class + */ + @Nonnull + public CreateChatCompletionResponse usage(@Nullable final CompletionUsage usage) { + this.usage = usage; + return this; + } + + /** + * Get usage + * + * @return usage The usage of this {@link CreateChatCompletionResponse} instance. + */ + @Nonnull + public CompletionUsage getUsage() { + return usage; + } + + /** + * Set the usage of this {@link CreateChatCompletionResponse} instance. + * + * @param usage The usage of this {@link CreateChatCompletionResponse} + */ + public void setUsage(@Nullable final CompletionUsage usage) { + this.usage = usage; + } + + /** + * Get the names of the unrecognizable properties of the {@link CreateChatCompletionResponse}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link CreateChatCompletionResponse} + * instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "CreateChatCompletionResponse has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link CreateChatCompletionResponse} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final CreateChatCompletionResponse createChatCompletionResponse = + (CreateChatCompletionResponse) o; + return Objects.equals( + this.cloudSdkCustomFields, createChatCompletionResponse.cloudSdkCustomFields) + && Objects.equals(this.id, createChatCompletionResponse.id) + && Objects.equals( + this.promptFilterResults, createChatCompletionResponse.promptFilterResults) + && Objects.equals(this.choices, createChatCompletionResponse.choices) + && Objects.equals(this.created, createChatCompletionResponse.created) + && Objects.equals(this.model, createChatCompletionResponse.model) + && Objects.equals(this.systemFingerprint, createChatCompletionResponse.systemFingerprint) + && Objects.equals(this._object, createChatCompletionResponse._object) + && Objects.equals(this.usage, createChatCompletionResponse.usage); + } + + @Override + public int hashCode() { + return Objects.hash( + id, + promptFilterResults, + choices, + created, + model, + systemFingerprint, + _object, + usage, + cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class CreateChatCompletionResponse {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" promptFilterResults: ") + .append(toIndentedString(promptFilterResults)) + .append("\n"); + sb.append(" choices: ").append(toIndentedString(choices)).append("\n"); + sb.append(" created: ").append(toIndentedString(created)).append("\n"); + sb.append(" model: ").append(toIndentedString(model)).append("\n"); + sb.append(" systemFingerprint: ").append(toIndentedString(systemFingerprint)).append("\n"); + sb.append(" _object: ").append(toIndentedString(_object)).append("\n"); + sb.append(" usage: ").append(toIndentedString(usage)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/CreateChatCompletionResponseChoicesInner.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/CreateChatCompletionResponseChoicesInner.java new file mode 100644 index 000000000..41fbd5d11 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/CreateChatCompletionResponseChoicesInner.java @@ -0,0 +1,408 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +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; + +/** CreateChatCompletionResponseChoicesInner */ +// CHECKSTYLE:OFF +public class CreateChatCompletionResponseChoicesInner +// CHECKSTYLE:ON +{ + /** + * The reason the model stopped generating tokens. This will be `stop` if the model hit + * a natural stop point or a provided stop sequence, `length` if the maximum number of + * tokens specified in the request was reached, `content_filter` if content was omitted + * due to a flag from our content filters, `tool_calls` if the model called a tool, or + * `function_call` (deprecated) if the model called a function. + */ + public enum FinishReasonEnum { + /** The STOP option of this CreateChatCompletionResponseChoicesInner */ + STOP("stop"), + + /** The LENGTH option of this CreateChatCompletionResponseChoicesInner */ + LENGTH("length"), + + /** The TOOL_CALLS option of this CreateChatCompletionResponseChoicesInner */ + TOOL_CALLS("tool_calls"), + + /** The CONTENT_FILTER option of this CreateChatCompletionResponseChoicesInner */ + CONTENT_FILTER("content_filter"), + + /** The FUNCTION_CALL option of this CreateChatCompletionResponseChoicesInner */ + FUNCTION_CALL("function_call"); + + private String value; + + FinishReasonEnum(String value) { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value The String value + * @return The enum value of type CreateChatCompletionResponseChoicesInner + */ + @JsonCreator + @Nonnull + public static FinishReasonEnum fromValue(@Nonnull final String value) { + for (FinishReasonEnum b : FinishReasonEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("finish_reason") + private FinishReasonEnum finishReason; + + @JsonProperty("index") + private Integer index; + + @JsonProperty("message") + private ChatCompletionResponseMessage message; + + @JsonProperty("content_filter_results") + private ContentFilterChoiceResults contentFilterResults; + + @JsonProperty("logprobs") + private CreateChatCompletionResponseChoicesInnerLogprobs logprobs; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the finishReason of this {@link CreateChatCompletionResponseChoicesInner} instance and + * return the same instance. + * + * @param finishReason The reason the model stopped generating tokens. This will be + * `stop` if the model hit a natural stop point or a provided stop sequence, + * `length` if the maximum number of tokens specified in the request was reached, + * `content_filter` if content was omitted due to a flag from our content filters, + * `tool_calls` if the model called a tool, or `function_call` + * (deprecated) if the model called a function. + * @return The same instance of this {@link CreateChatCompletionResponseChoicesInner} class + */ + @Nonnull + public CreateChatCompletionResponseChoicesInner finishReason( + @Nonnull final FinishReasonEnum finishReason) { + this.finishReason = finishReason; + return this; + } + + /** + * The reason the model stopped generating tokens. This will be `stop` if the model hit + * a natural stop point or a provided stop sequence, `length` if the maximum number of + * tokens specified in the request was reached, `content_filter` if content was omitted + * due to a flag from our content filters, `tool_calls` if the model called a tool, or + * `function_call` (deprecated) if the model called a function. + * + * @return finishReason The finishReason of this {@link CreateChatCompletionResponseChoicesInner} + * instance. + */ + @Nonnull + public FinishReasonEnum getFinishReason() { + return finishReason; + } + + /** + * Set the finishReason of this {@link CreateChatCompletionResponseChoicesInner} instance. + * + * @param finishReason The reason the model stopped generating tokens. This will be + * `stop` if the model hit a natural stop point or a provided stop sequence, + * `length` if the maximum number of tokens specified in the request was reached, + * `content_filter` if content was omitted due to a flag from our content filters, + * `tool_calls` if the model called a tool, or `function_call` + * (deprecated) if the model called a function. + */ + public void setFinishReason(@Nonnull final FinishReasonEnum finishReason) { + this.finishReason = finishReason; + } + + /** + * Set the index of this {@link CreateChatCompletionResponseChoicesInner} instance and return the + * same instance. + * + * @param index The index of the choice in the list of choices. + * @return The same instance of this {@link CreateChatCompletionResponseChoicesInner} class + */ + @Nonnull + public CreateChatCompletionResponseChoicesInner index(@Nonnull final Integer index) { + this.index = index; + return this; + } + + /** + * The index of the choice in the list of choices. + * + * @return index The index of this {@link CreateChatCompletionResponseChoicesInner} instance. + */ + @Nonnull + public Integer getIndex() { + return index; + } + + /** + * Set the index of this {@link CreateChatCompletionResponseChoicesInner} instance. + * + * @param index The index of the choice in the list of choices. + */ + public void setIndex(@Nonnull final Integer index) { + this.index = index; + } + + /** + * Set the message of this {@link CreateChatCompletionResponseChoicesInner} instance and return + * the same instance. + * + * @param message The message of this {@link CreateChatCompletionResponseChoicesInner} + * @return The same instance of this {@link CreateChatCompletionResponseChoicesInner} class + */ + @Nonnull + public CreateChatCompletionResponseChoicesInner message( + @Nonnull final ChatCompletionResponseMessage message) { + this.message = message; + return this; + } + + /** + * Get message + * + * @return message The message of this {@link CreateChatCompletionResponseChoicesInner} instance. + */ + @Nonnull + public ChatCompletionResponseMessage getMessage() { + return message; + } + + /** + * Set the message of this {@link CreateChatCompletionResponseChoicesInner} instance. + * + * @param message The message of this {@link CreateChatCompletionResponseChoicesInner} + */ + public void setMessage(@Nonnull final ChatCompletionResponseMessage message) { + this.message = message; + } + + /** + * Set the contentFilterResults of this {@link CreateChatCompletionResponseChoicesInner} instance + * and return the same instance. + * + * @param contentFilterResults The contentFilterResults of this {@link + * CreateChatCompletionResponseChoicesInner} + * @return The same instance of this {@link CreateChatCompletionResponseChoicesInner} class + */ + @Nonnull + public CreateChatCompletionResponseChoicesInner contentFilterResults( + @Nullable final ContentFilterChoiceResults contentFilterResults) { + this.contentFilterResults = contentFilterResults; + return this; + } + + /** + * Get contentFilterResults + * + * @return contentFilterResults The contentFilterResults of this {@link + * CreateChatCompletionResponseChoicesInner} instance. + */ + @Nonnull + public ContentFilterChoiceResults getContentFilterResults() { + return contentFilterResults; + } + + /** + * Set the contentFilterResults of this {@link CreateChatCompletionResponseChoicesInner} instance. + * + * @param contentFilterResults The contentFilterResults of this {@link + * CreateChatCompletionResponseChoicesInner} + */ + public void setContentFilterResults( + @Nullable final ContentFilterChoiceResults contentFilterResults) { + this.contentFilterResults = contentFilterResults; + } + + /** + * Set the logprobs of this {@link CreateChatCompletionResponseChoicesInner} instance and return + * the same instance. + * + * @param logprobs The logprobs of this {@link CreateChatCompletionResponseChoicesInner} + * @return The same instance of this {@link CreateChatCompletionResponseChoicesInner} class + */ + @Nonnull + public CreateChatCompletionResponseChoicesInner logprobs( + @Nullable final CreateChatCompletionResponseChoicesInnerLogprobs logprobs) { + this.logprobs = logprobs; + return this; + } + + /** + * Get logprobs + * + * @return logprobs The logprobs of this {@link CreateChatCompletionResponseChoicesInner} + * instance. + */ + @Nullable + public CreateChatCompletionResponseChoicesInnerLogprobs getLogprobs() { + return logprobs; + } + + /** + * Set the logprobs of this {@link CreateChatCompletionResponseChoicesInner} instance. + * + * @param logprobs The logprobs of this {@link CreateChatCompletionResponseChoicesInner} + */ + public void setLogprobs( + @Nullable final CreateChatCompletionResponseChoicesInnerLogprobs logprobs) { + this.logprobs = logprobs; + } + + /** + * Get the names of the unrecognizable properties of the {@link + * CreateChatCompletionResponseChoicesInner}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link + * CreateChatCompletionResponseChoicesInner} instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "CreateChatCompletionResponseChoicesInner has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link CreateChatCompletionResponseChoicesInner} + * 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final CreateChatCompletionResponseChoicesInner createChatCompletionResponseChoicesInner = + (CreateChatCompletionResponseChoicesInner) o; + return Objects.equals( + this.cloudSdkCustomFields, + createChatCompletionResponseChoicesInner.cloudSdkCustomFields) + && Objects.equals(this.finishReason, createChatCompletionResponseChoicesInner.finishReason) + && Objects.equals(this.index, createChatCompletionResponseChoicesInner.index) + && Objects.equals(this.message, createChatCompletionResponseChoicesInner.message) + && Objects.equals( + this.contentFilterResults, + createChatCompletionResponseChoicesInner.contentFilterResults) + && Objects.equals(this.logprobs, createChatCompletionResponseChoicesInner.logprobs); + } + + @Override + public int hashCode() { + return Objects.hash( + finishReason, index, message, contentFilterResults, logprobs, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class CreateChatCompletionResponseChoicesInner {\n"); + sb.append(" finishReason: ").append(toIndentedString(finishReason)).append("\n"); + sb.append(" index: ").append(toIndentedString(index)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" contentFilterResults: ") + .append(toIndentedString(contentFilterResults)) + .append("\n"); + sb.append(" logprobs: ").append(toIndentedString(logprobs)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/CreateChatCompletionResponseChoicesInnerLogprobs.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/CreateChatCompletionResponseChoicesInnerLogprobs.java new file mode 100644 index 000000000..e926ce0d4 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/CreateChatCompletionResponseChoicesInnerLogprobs.java @@ -0,0 +1,239 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** Log probability information for the choice. */ +// CHECKSTYLE:OFF +public class CreateChatCompletionResponseChoicesInnerLogprobs +// CHECKSTYLE:ON +{ + @JsonProperty("content") + private List content; + + @JsonProperty("refusal") + private List refusal; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the content of this {@link CreateChatCompletionResponseChoicesInnerLogprobs} instance and + * return the same instance. + * + * @param content A list of message content tokens with log probability information. + * @return The same instance of this {@link CreateChatCompletionResponseChoicesInnerLogprobs} + * class + */ + @Nonnull + public CreateChatCompletionResponseChoicesInnerLogprobs content( + @Nullable final List content) { + this.content = content; + return this; + } + + /** + * Add one content instance to this {@link CreateChatCompletionResponseChoicesInnerLogprobs}. + * + * @param contentItem The content that should be added + * @return The same instance of type {@link CreateChatCompletionResponseChoicesInnerLogprobs} + */ + @Nonnull + public CreateChatCompletionResponseChoicesInnerLogprobs addContentItem( + @Nonnull final ChatCompletionTokenLogprob contentItem) { + if (this.content == null) { + this.content = new ArrayList<>(); + } + this.content.add(contentItem); + return this; + } + + /** + * A list of message content tokens with log probability information. + * + * @return content The content of this {@link CreateChatCompletionResponseChoicesInnerLogprobs} + * instance. + */ + @Nullable + public List getContent() { + return content; + } + + /** + * Set the content of this {@link CreateChatCompletionResponseChoicesInnerLogprobs} instance. + * + * @param content A list of message content tokens with log probability information. + */ + public void setContent(@Nullable final List content) { + this.content = content; + } + + /** + * Set the refusal of this {@link CreateChatCompletionResponseChoicesInnerLogprobs} instance and + * return the same instance. + * + * @param refusal A list of message refusal tokens with log probability information. + * @return The same instance of this {@link CreateChatCompletionResponseChoicesInnerLogprobs} + * class + */ + @Nonnull + public CreateChatCompletionResponseChoicesInnerLogprobs refusal( + @Nullable final List refusal) { + this.refusal = refusal; + return this; + } + + /** + * Add one refusal instance to this {@link CreateChatCompletionResponseChoicesInnerLogprobs}. + * + * @param refusalItem The refusal that should be added + * @return The same instance of type {@link CreateChatCompletionResponseChoicesInnerLogprobs} + */ + @Nonnull + public CreateChatCompletionResponseChoicesInnerLogprobs addRefusalItem( + @Nonnull final ChatCompletionTokenLogprob refusalItem) { + if (this.refusal == null) { + this.refusal = new ArrayList<>(); + } + this.refusal.add(refusalItem); + return this; + } + + /** + * A list of message refusal tokens with log probability information. + * + * @return refusal The refusal of this {@link CreateChatCompletionResponseChoicesInnerLogprobs} + * instance. + */ + @Nullable + public List getRefusal() { + return refusal; + } + + /** + * Set the refusal of this {@link CreateChatCompletionResponseChoicesInnerLogprobs} instance. + * + * @param refusal A list of message refusal tokens with log probability information. + */ + public void setRefusal(@Nullable final List refusal) { + this.refusal = refusal; + } + + /** + * Get the names of the unrecognizable properties of the {@link + * CreateChatCompletionResponseChoicesInnerLogprobs}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link + * CreateChatCompletionResponseChoicesInnerLogprobs} instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "CreateChatCompletionResponseChoicesInnerLogprobs has no field with name '" + + name + + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link CreateChatCompletionResponseChoicesInnerLogprobs} + * 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final CreateChatCompletionResponseChoicesInnerLogprobs + createChatCompletionResponseChoicesInnerLogprobs = + (CreateChatCompletionResponseChoicesInnerLogprobs) o; + return Objects.equals( + this.cloudSdkCustomFields, + createChatCompletionResponseChoicesInnerLogprobs.cloudSdkCustomFields) + && Objects.equals(this.content, createChatCompletionResponseChoicesInnerLogprobs.content) + && Objects.equals(this.refusal, createChatCompletionResponseChoicesInnerLogprobs.refusal); + } + + @Override + public int hashCode() { + return Objects.hash(content, refusal, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class CreateChatCompletionResponseChoicesInnerLogprobs {\n"); + sb.append(" content: ").append(toIndentedString(content)).append("\n"); + sb.append(" refusal: ").append(toIndentedString(refusal)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/CreateChatCompletionStreamResponse.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/CreateChatCompletionStreamResponse.java new file mode 100644 index 000000000..dab34395d --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/CreateChatCompletionStreamResponse.java @@ -0,0 +1,435 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * Represents a streamed chunk of a chat completion response returned by model, based on the + * provided input. + */ +// CHECKSTYLE:OFF +public class CreateChatCompletionStreamResponse implements ChatCompletionsCreate200Response +// CHECKSTYLE:ON +{ + @JsonProperty("id") + private String id; + + @JsonProperty("choices") + private List choices = new ArrayList<>(); + + @JsonProperty("created") + private Integer created; + + @JsonProperty("model") + private String model; + + @JsonProperty("system_fingerprint") + private String systemFingerprint; + + /** The object type, which is always `chat.completion.chunk`. */ + public enum ObjectEnum { + /** The CHAT_COMPLETION_CHUNK option of this CreateChatCompletionStreamResponse */ + CHAT_COMPLETION_CHUNK("chat.completion.chunk"); + + private String value; + + ObjectEnum(String value) { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value The String value + * @return The enum value of type CreateChatCompletionStreamResponse + */ + @JsonCreator + @Nonnull + public static ObjectEnum fromValue(@Nonnull final String value) { + for (ObjectEnum b : ObjectEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("object") + private ObjectEnum _object; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the id of this {@link CreateChatCompletionStreamResponse} instance and return the same + * instance. + * + * @param id A unique identifier for the chat completion. Each chunk has the same ID. + * @return The same instance of this {@link CreateChatCompletionStreamResponse} class + */ + @Nonnull + public CreateChatCompletionStreamResponse id(@Nonnull final String id) { + this.id = id; + return this; + } + + /** + * A unique identifier for the chat completion. Each chunk has the same ID. + * + * @return id The id of this {@link CreateChatCompletionStreamResponse} instance. + */ + @Nonnull + public String getId() { + return id; + } + + /** + * Set the id of this {@link CreateChatCompletionStreamResponse} instance. + * + * @param id A unique identifier for the chat completion. Each chunk has the same ID. + */ + public void setId(@Nonnull final String id) { + this.id = id; + } + + /** + * Set the choices of this {@link CreateChatCompletionStreamResponse} instance and return the same + * instance. + * + * @param choices A list of chat completion choices. Can contain more than one elements if + * `n` is greater than 1. + * @return The same instance of this {@link CreateChatCompletionStreamResponse} class + */ + @Nonnull + public CreateChatCompletionStreamResponse choices( + @Nonnull final List choices) { + this.choices = choices; + return this; + } + + /** + * Add one choices instance to this {@link CreateChatCompletionStreamResponse}. + * + * @param choicesItem The choices that should be added + * @return The same instance of type {@link CreateChatCompletionStreamResponse} + */ + @Nonnull + public CreateChatCompletionStreamResponse addChoicesItem( + @Nonnull final CreateChatCompletionStreamResponseChoicesInner choicesItem) { + if (this.choices == null) { + this.choices = new ArrayList<>(); + } + this.choices.add(choicesItem); + return this; + } + + /** + * A list of chat completion choices. Can contain more than one elements if `n` is + * greater than 1. + * + * @return choices The choices of this {@link CreateChatCompletionStreamResponse} instance. + */ + @Nonnull + public List getChoices() { + return choices; + } + + /** + * Set the choices of this {@link CreateChatCompletionStreamResponse} instance. + * + * @param choices A list of chat completion choices. Can contain more than one elements if + * `n` is greater than 1. + */ + public void setChoices( + @Nonnull final List choices) { + this.choices = choices; + } + + /** + * Set the created of this {@link CreateChatCompletionStreamResponse} instance and return the same + * instance. + * + * @param created The Unix timestamp (in seconds) of when the chat completion was created. Each + * chunk has the same timestamp. + * @return The same instance of this {@link CreateChatCompletionStreamResponse} class + */ + @Nonnull + public CreateChatCompletionStreamResponse created(@Nonnull final Integer created) { + this.created = created; + return this; + } + + /** + * The Unix timestamp (in seconds) of when the chat completion was created. Each chunk has the + * same timestamp. + * + * @return created The created of this {@link CreateChatCompletionStreamResponse} instance. + */ + @Nonnull + public Integer getCreated() { + return created; + } + + /** + * Set the created of this {@link CreateChatCompletionStreamResponse} instance. + * + * @param created The Unix timestamp (in seconds) of when the chat completion was created. Each + * chunk has the same timestamp. + */ + public void setCreated(@Nonnull final Integer created) { + this.created = created; + } + + /** + * Set the model of this {@link CreateChatCompletionStreamResponse} instance and return the same + * instance. + * + * @param model The model to generate the completion. + * @return The same instance of this {@link CreateChatCompletionStreamResponse} class + */ + @Nonnull + public CreateChatCompletionStreamResponse model(@Nonnull final String model) { + this.model = model; + return this; + } + + /** + * The model to generate the completion. + * + * @return model The model of this {@link CreateChatCompletionStreamResponse} instance. + */ + @Nonnull + public String getModel() { + return model; + } + + /** + * Set the model of this {@link CreateChatCompletionStreamResponse} instance. + * + * @param model The model to generate the completion. + */ + public void setModel(@Nonnull final String model) { + this.model = model; + } + + /** + * Set the systemFingerprint of this {@link CreateChatCompletionStreamResponse} instance and + * return the same instance. + * + * @param systemFingerprint This fingerprint represents the backend configuration that the model + * runs with. Can be used in conjunction with the `seed` request parameter to + * understand when backend changes have been made that might impact determinism. + * @return The same instance of this {@link CreateChatCompletionStreamResponse} class + */ + @Nonnull + public CreateChatCompletionStreamResponse systemFingerprint( + @Nullable final String systemFingerprint) { + this.systemFingerprint = systemFingerprint; + return this; + } + + /** + * This fingerprint represents the backend configuration that the model runs with. Can be used in + * conjunction with the `seed` request parameter to understand when backend changes have + * been made that might impact determinism. + * + * @return systemFingerprint The systemFingerprint of this {@link + * CreateChatCompletionStreamResponse} instance. + */ + @Nonnull + public String getSystemFingerprint() { + return systemFingerprint; + } + + /** + * Set the systemFingerprint of this {@link CreateChatCompletionStreamResponse} instance. + * + * @param systemFingerprint This fingerprint represents the backend configuration that the model + * runs with. Can be used in conjunction with the `seed` request parameter to + * understand when backend changes have been made that might impact determinism. + */ + public void setSystemFingerprint(@Nullable final String systemFingerprint) { + this.systemFingerprint = systemFingerprint; + } + + /** + * Set the _object of this {@link CreateChatCompletionStreamResponse} instance and return the same + * instance. + * + * @param _object The object type, which is always `chat.completion.chunk`. + * @return The same instance of this {@link CreateChatCompletionStreamResponse} class + */ + @Nonnull + public CreateChatCompletionStreamResponse _object(@Nonnull final ObjectEnum _object) { + this._object = _object; + return this; + } + + /** + * The object type, which is always `chat.completion.chunk`. + * + * @return _object The _object of this {@link CreateChatCompletionStreamResponse} instance. + */ + @Nonnull + public ObjectEnum getObject() { + return _object; + } + + /** + * Set the _object of this {@link CreateChatCompletionStreamResponse} instance. + * + * @param _object The object type, which is always `chat.completion.chunk`. + */ + public void setObject(@Nonnull final ObjectEnum _object) { + this._object = _object; + } + + /** + * Get the names of the unrecognizable properties of the {@link + * CreateChatCompletionStreamResponse}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link CreateChatCompletionStreamResponse} + * instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "CreateChatCompletionStreamResponse has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link CreateChatCompletionStreamResponse} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final CreateChatCompletionStreamResponse createChatCompletionStreamResponse = + (CreateChatCompletionStreamResponse) o; + return Objects.equals( + this.cloudSdkCustomFields, createChatCompletionStreamResponse.cloudSdkCustomFields) + && Objects.equals(this.id, createChatCompletionStreamResponse.id) + && Objects.equals(this.choices, createChatCompletionStreamResponse.choices) + && Objects.equals(this.created, createChatCompletionStreamResponse.created) + && Objects.equals(this.model, createChatCompletionStreamResponse.model) + && Objects.equals( + this.systemFingerprint, createChatCompletionStreamResponse.systemFingerprint) + && Objects.equals(this._object, createChatCompletionStreamResponse._object); + } + + @Override + public int hashCode() { + return Objects.hash( + id, choices, created, model, systemFingerprint, _object, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class CreateChatCompletionStreamResponse {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" choices: ").append(toIndentedString(choices)).append("\n"); + sb.append(" created: ").append(toIndentedString(created)).append("\n"); + sb.append(" model: ").append(toIndentedString(model)).append("\n"); + sb.append(" systemFingerprint: ").append(toIndentedString(systemFingerprint)).append("\n"); + sb.append(" _object: ").append(toIndentedString(_object)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/CreateChatCompletionStreamResponseChoicesInner.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/CreateChatCompletionStreamResponseChoicesInner.java new file mode 100644 index 000000000..9cbc6f03b --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/CreateChatCompletionStreamResponseChoicesInner.java @@ -0,0 +1,365 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +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; + +/** CreateChatCompletionStreamResponseChoicesInner */ +// CHECKSTYLE:OFF +public class CreateChatCompletionStreamResponseChoicesInner +// CHECKSTYLE:ON +{ + @JsonProperty("delta") + private ChatCompletionStreamResponseDelta delta; + + @JsonProperty("logprobs") + private CreateChatCompletionResponseChoicesInnerLogprobs logprobs; + + /** + * The reason the model stopped generating tokens. This will be `stop` if the model hit + * a natural stop point or a provided stop sequence, `length` if the maximum number of + * tokens specified in the request was reached, `content_filter` if content was omitted + * due to a flag from our content filters, `tool_calls` if the model called a tool, or + * `function_call` (deprecated) if the model called a function. + */ + public enum FinishReasonEnum { + /** The STOP option of this CreateChatCompletionStreamResponseChoicesInner */ + STOP("stop"), + + /** The LENGTH option of this CreateChatCompletionStreamResponseChoicesInner */ + LENGTH("length"), + + /** The TOOL_CALLS option of this CreateChatCompletionStreamResponseChoicesInner */ + TOOL_CALLS("tool_calls"), + + /** The CONTENT_FILTER option of this CreateChatCompletionStreamResponseChoicesInner */ + CONTENT_FILTER("content_filter"), + + /** The FUNCTION_CALL option of this CreateChatCompletionStreamResponseChoicesInner */ + FUNCTION_CALL("function_call"); + + private String value; + + FinishReasonEnum(String value) { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value The String value + * @return The enum value of type CreateChatCompletionStreamResponseChoicesInner + */ + @JsonCreator + @Nonnull + public static FinishReasonEnum fromValue(@Nonnull final String value) { + for (FinishReasonEnum b : FinishReasonEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("finish_reason") + private FinishReasonEnum finishReason; + + @JsonProperty("index") + private Integer index; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the delta of this {@link CreateChatCompletionStreamResponseChoicesInner} instance and + * return the same instance. + * + * @param delta The delta of this {@link CreateChatCompletionStreamResponseChoicesInner} + * @return The same instance of this {@link CreateChatCompletionStreamResponseChoicesInner} class + */ + @Nonnull + public CreateChatCompletionStreamResponseChoicesInner delta( + @Nonnull final ChatCompletionStreamResponseDelta delta) { + this.delta = delta; + return this; + } + + /** + * Get delta + * + * @return delta The delta of this {@link CreateChatCompletionStreamResponseChoicesInner} + * instance. + */ + @Nonnull + public ChatCompletionStreamResponseDelta getDelta() { + return delta; + } + + /** + * Set the delta of this {@link CreateChatCompletionStreamResponseChoicesInner} instance. + * + * @param delta The delta of this {@link CreateChatCompletionStreamResponseChoicesInner} + */ + public void setDelta(@Nonnull final ChatCompletionStreamResponseDelta delta) { + this.delta = delta; + } + + /** + * Set the logprobs of this {@link CreateChatCompletionStreamResponseChoicesInner} instance and + * return the same instance. + * + * @param logprobs The logprobs of this {@link CreateChatCompletionStreamResponseChoicesInner} + * @return The same instance of this {@link CreateChatCompletionStreamResponseChoicesInner} class + */ + @Nonnull + public CreateChatCompletionStreamResponseChoicesInner logprobs( + @Nullable final CreateChatCompletionResponseChoicesInnerLogprobs logprobs) { + this.logprobs = logprobs; + return this; + } + + /** + * Get logprobs + * + * @return logprobs The logprobs of this {@link CreateChatCompletionStreamResponseChoicesInner} + * instance. + */ + @Nullable + public CreateChatCompletionResponseChoicesInnerLogprobs getLogprobs() { + return logprobs; + } + + /** + * Set the logprobs of this {@link CreateChatCompletionStreamResponseChoicesInner} instance. + * + * @param logprobs The logprobs of this {@link CreateChatCompletionStreamResponseChoicesInner} + */ + public void setLogprobs( + @Nullable final CreateChatCompletionResponseChoicesInnerLogprobs logprobs) { + this.logprobs = logprobs; + } + + /** + * Set the finishReason of this {@link CreateChatCompletionStreamResponseChoicesInner} instance + * and return the same instance. + * + * @param finishReason The reason the model stopped generating tokens. This will be + * `stop` if the model hit a natural stop point or a provided stop sequence, + * `length` if the maximum number of tokens specified in the request was reached, + * `content_filter` if content was omitted due to a flag from our content filters, + * `tool_calls` if the model called a tool, or `function_call` + * (deprecated) if the model called a function. + * @return The same instance of this {@link CreateChatCompletionStreamResponseChoicesInner} class + */ + @Nonnull + public CreateChatCompletionStreamResponseChoicesInner finishReason( + @Nullable final FinishReasonEnum finishReason) { + this.finishReason = finishReason; + return this; + } + + /** + * The reason the model stopped generating tokens. This will be `stop` if the model hit + * a natural stop point or a provided stop sequence, `length` if the maximum number of + * tokens specified in the request was reached, `content_filter` if content was omitted + * due to a flag from our content filters, `tool_calls` if the model called a tool, or + * `function_call` (deprecated) if the model called a function. + * + * @return finishReason The finishReason of this {@link + * CreateChatCompletionStreamResponseChoicesInner} instance. + */ + @Nullable + public FinishReasonEnum getFinishReason() { + return finishReason; + } + + /** + * Set the finishReason of this {@link CreateChatCompletionStreamResponseChoicesInner} instance. + * + * @param finishReason The reason the model stopped generating tokens. This will be + * `stop` if the model hit a natural stop point or a provided stop sequence, + * `length` if the maximum number of tokens specified in the request was reached, + * `content_filter` if content was omitted due to a flag from our content filters, + * `tool_calls` if the model called a tool, or `function_call` + * (deprecated) if the model called a function. + */ + public void setFinishReason(@Nullable final FinishReasonEnum finishReason) { + this.finishReason = finishReason; + } + + /** + * Set the index of this {@link CreateChatCompletionStreamResponseChoicesInner} instance and + * return the same instance. + * + * @param index The index of the choice in the list of choices. + * @return The same instance of this {@link CreateChatCompletionStreamResponseChoicesInner} class + */ + @Nonnull + public CreateChatCompletionStreamResponseChoicesInner index(@Nonnull final Integer index) { + this.index = index; + return this; + } + + /** + * The index of the choice in the list of choices. + * + * @return index The index of this {@link CreateChatCompletionStreamResponseChoicesInner} + * instance. + */ + @Nonnull + public Integer getIndex() { + return index; + } + + /** + * Set the index of this {@link CreateChatCompletionStreamResponseChoicesInner} instance. + * + * @param index The index of the choice in the list of choices. + */ + public void setIndex(@Nonnull final Integer index) { + this.index = index; + } + + /** + * Get the names of the unrecognizable properties of the {@link + * CreateChatCompletionStreamResponseChoicesInner}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link + * CreateChatCompletionStreamResponseChoicesInner} instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "CreateChatCompletionStreamResponseChoicesInner has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link CreateChatCompletionStreamResponseChoicesInner} + * 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final CreateChatCompletionStreamResponseChoicesInner + createChatCompletionStreamResponseChoicesInner = + (CreateChatCompletionStreamResponseChoicesInner) o; + return Objects.equals( + this.cloudSdkCustomFields, + createChatCompletionStreamResponseChoicesInner.cloudSdkCustomFields) + && Objects.equals(this.delta, createChatCompletionStreamResponseChoicesInner.delta) + && Objects.equals(this.logprobs, createChatCompletionStreamResponseChoicesInner.logprobs) + && Objects.equals( + this.finishReason, createChatCompletionStreamResponseChoicesInner.finishReason) + && Objects.equals(this.index, createChatCompletionStreamResponseChoicesInner.index); + } + + @Override + public int hashCode() { + return Objects.hash(delta, logprobs, finishReason, index, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class CreateChatCompletionStreamResponseChoicesInner {\n"); + sb.append(" delta: ").append(toIndentedString(delta)).append("\n"); + sb.append(" logprobs: ").append(toIndentedString(logprobs)).append("\n"); + sb.append(" finishReason: ").append(toIndentedString(finishReason)).append("\n"); + sb.append(" index: ").append(toIndentedString(index)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/EmbeddingsCreate200Response.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/EmbeddingsCreate200Response.java new file mode 100644 index 000000000..56653c56a --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/EmbeddingsCreate200Response.java @@ -0,0 +1,284 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** EmbeddingsCreate200Response */ +// CHECKSTYLE:OFF +public class EmbeddingsCreate200Response +// CHECKSTYLE:ON +{ + @JsonProperty("object") + private String _object; + + @JsonProperty("model") + private String model; + + @JsonProperty("data") + private List data = new ArrayList<>(); + + @JsonProperty("usage") + private EmbeddingsCreate200ResponseUsage usage; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the _object of this {@link EmbeddingsCreate200Response} instance and return the same + * instance. + * + * @param _object The _object of this {@link EmbeddingsCreate200Response} + * @return The same instance of this {@link EmbeddingsCreate200Response} class + */ + @Nonnull + public EmbeddingsCreate200Response _object(@Nonnull final String _object) { + this._object = _object; + return this; + } + + /** + * Get _object + * + * @return _object The _object of this {@link EmbeddingsCreate200Response} instance. + */ + @Nonnull + public String getObject() { + return _object; + } + + /** + * Set the _object of this {@link EmbeddingsCreate200Response} instance. + * + * @param _object The _object of this {@link EmbeddingsCreate200Response} + */ + public void setObject(@Nonnull final String _object) { + this._object = _object; + } + + /** + * Set the model of this {@link EmbeddingsCreate200Response} instance and return the same + * instance. + * + * @param model The model of this {@link EmbeddingsCreate200Response} + * @return The same instance of this {@link EmbeddingsCreate200Response} class + */ + @Nonnull + public EmbeddingsCreate200Response model(@Nonnull final String model) { + this.model = model; + return this; + } + + /** + * Get model + * + * @return model The model of this {@link EmbeddingsCreate200Response} instance. + */ + @Nonnull + public String getModel() { + return model; + } + + /** + * Set the model of this {@link EmbeddingsCreate200Response} instance. + * + * @param model The model of this {@link EmbeddingsCreate200Response} + */ + public void setModel(@Nonnull final String model) { + this.model = model; + } + + /** + * Set the data of this {@link EmbeddingsCreate200Response} instance and return the same instance. + * + * @param data The data of this {@link EmbeddingsCreate200Response} + * @return The same instance of this {@link EmbeddingsCreate200Response} class + */ + @Nonnull + public EmbeddingsCreate200Response data( + @Nonnull final List data) { + this.data = data; + return this; + } + + /** + * Add one data instance to this {@link EmbeddingsCreate200Response}. + * + * @param dataItem The data that should be added + * @return The same instance of type {@link EmbeddingsCreate200Response} + */ + @Nonnull + public EmbeddingsCreate200Response addDataItem( + @Nonnull final EmbeddingsCreate200ResponseDataInner dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + return this; + } + + /** + * Get data + * + * @return data The data of this {@link EmbeddingsCreate200Response} instance. + */ + @Nonnull + public List getData() { + return data; + } + + /** + * Set the data of this {@link EmbeddingsCreate200Response} instance. + * + * @param data The data of this {@link EmbeddingsCreate200Response} + */ + public void setData(@Nonnull final List data) { + this.data = data; + } + + /** + * Set the usage of this {@link EmbeddingsCreate200Response} instance and return the same + * instance. + * + * @param usage The usage of this {@link EmbeddingsCreate200Response} + * @return The same instance of this {@link EmbeddingsCreate200Response} class + */ + @Nonnull + public EmbeddingsCreate200Response usage(@Nonnull final EmbeddingsCreate200ResponseUsage usage) { + this.usage = usage; + return this; + } + + /** + * Get usage + * + * @return usage The usage of this {@link EmbeddingsCreate200Response} instance. + */ + @Nonnull + public EmbeddingsCreate200ResponseUsage getUsage() { + return usage; + } + + /** + * Set the usage of this {@link EmbeddingsCreate200Response} instance. + * + * @param usage The usage of this {@link EmbeddingsCreate200Response} + */ + public void setUsage(@Nonnull final EmbeddingsCreate200ResponseUsage usage) { + this.usage = usage; + } + + /** + * Get the names of the unrecognizable properties of the {@link EmbeddingsCreate200Response}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link EmbeddingsCreate200Response} + * instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "EmbeddingsCreate200Response has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link EmbeddingsCreate200Response} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final EmbeddingsCreate200Response embeddingsCreate200Response = (EmbeddingsCreate200Response) o; + return Objects.equals( + this.cloudSdkCustomFields, embeddingsCreate200Response.cloudSdkCustomFields) + && Objects.equals(this._object, embeddingsCreate200Response._object) + && Objects.equals(this.model, embeddingsCreate200Response.model) + && Objects.equals(this.data, embeddingsCreate200Response.data) + && Objects.equals(this.usage, embeddingsCreate200Response.usage); + } + + @Override + public int hashCode() { + return Objects.hash(_object, model, data, usage, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class EmbeddingsCreate200Response {\n"); + sb.append(" _object: ").append(toIndentedString(_object)).append("\n"); + sb.append(" model: ").append(toIndentedString(model)).append("\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" usage: ").append(toIndentedString(usage)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/EmbeddingsCreate200ResponseDataInner.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/EmbeddingsCreate200ResponseDataInner.java new file mode 100644 index 000000000..ca6348ea4 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/EmbeddingsCreate200ResponseDataInner.java @@ -0,0 +1,251 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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.math.BigDecimal; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** EmbeddingsCreate200ResponseDataInner */ +// CHECKSTYLE:OFF +public class EmbeddingsCreate200ResponseDataInner +// CHECKSTYLE:ON +{ + @JsonProperty("index") + private Integer index; + + @JsonProperty("object") + private String _object; + + @JsonProperty("embedding") + private List embedding = new ArrayList<>(); // + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the index of this {@link EmbeddingsCreate200ResponseDataInner} instance and return the same + * instance. + * + * @param index The index of this {@link EmbeddingsCreate200ResponseDataInner} + * @return The same instance of this {@link EmbeddingsCreate200ResponseDataInner} class + */ + @Nonnull + public EmbeddingsCreate200ResponseDataInner index(@Nonnull final Integer index) { + this.index = index; + return this; + } + + /** + * Get index + * + * @return index The index of this {@link EmbeddingsCreate200ResponseDataInner} instance. + */ + @Nonnull + public Integer getIndex() { + return index; + } + + /** + * Set the index of this {@link EmbeddingsCreate200ResponseDataInner} instance. + * + * @param index The index of this {@link EmbeddingsCreate200ResponseDataInner} + */ + public void setIndex(@Nonnull final Integer index) { + this.index = index; + } + + /** + * Set the _object of this {@link EmbeddingsCreate200ResponseDataInner} instance and return the + * same instance. + * + * @param _object The _object of this {@link EmbeddingsCreate200ResponseDataInner} + * @return The same instance of this {@link EmbeddingsCreate200ResponseDataInner} class + */ + @Nonnull + public EmbeddingsCreate200ResponseDataInner _object(@Nonnull final String _object) { + this._object = _object; + return this; + } + + /** + * Get _object + * + * @return _object The _object of this {@link EmbeddingsCreate200ResponseDataInner} instance. + */ + @Nonnull + public String getObject() { + return _object; + } + + /** + * Set the _object of this {@link EmbeddingsCreate200ResponseDataInner} instance. + * + * @param _object The _object of this {@link EmbeddingsCreate200ResponseDataInner} + */ + public void setObject(@Nonnull final String _object) { + this._object = _object; + } + + /** + * Set the embedding of this {@link EmbeddingsCreate200ResponseDataInner} instance and return the + * same instance. + * + * @param embedding The embedding of this {@link EmbeddingsCreate200ResponseDataInner} + * @return The same instance of this {@link EmbeddingsCreate200ResponseDataInner} class + */ + @Nonnull + public EmbeddingsCreate200ResponseDataInner embedding(@Nonnull final List embedding) { + this.embedding = embedding; + return this; + } + + /** + * Add one embedding instance to this {@link EmbeddingsCreate200ResponseDataInner}. + * + * @param embeddingItem The embedding that should be added + * @return The same instance of type {@link EmbeddingsCreate200ResponseDataInner} + */ + @Nonnull + public EmbeddingsCreate200ResponseDataInner addEmbeddingItem( + @Nonnull final BigDecimal embeddingItem) { + if (this.embedding == null) { + this.embedding = new ArrayList<>(); + } + this.embedding.add(embeddingItem); + return this; + } + + /** + * Get embedding + * + * @return embedding The embedding of this {@link EmbeddingsCreate200ResponseDataInner} instance. + */ + @Nonnull + public List getEmbedding() { + return embedding; + } + + /** + * Set the embedding of this {@link EmbeddingsCreate200ResponseDataInner} instance. + * + * @param embedding The embedding of this {@link EmbeddingsCreate200ResponseDataInner} + */ + public void setEmbedding(@Nonnull final List embedding) { + this.embedding = embedding; + } + + /** + * Get the names of the unrecognizable properties of the {@link + * EmbeddingsCreate200ResponseDataInner}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link + * EmbeddingsCreate200ResponseDataInner} instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "EmbeddingsCreate200ResponseDataInner has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link EmbeddingsCreate200ResponseDataInner} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final EmbeddingsCreate200ResponseDataInner embeddingsCreate200ResponseDataInner = + (EmbeddingsCreate200ResponseDataInner) o; + return Objects.equals( + this.cloudSdkCustomFields, embeddingsCreate200ResponseDataInner.cloudSdkCustomFields) + && Objects.equals(this.index, embeddingsCreate200ResponseDataInner.index) + && Objects.equals(this._object, embeddingsCreate200ResponseDataInner._object) + && Objects.equals(this.embedding, embeddingsCreate200ResponseDataInner.embedding); + } + + @Override + public int hashCode() { + return Objects.hash(index, _object, embedding, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class EmbeddingsCreate200ResponseDataInner {\n"); + sb.append(" index: ").append(toIndentedString(index)).append("\n"); + sb.append(" _object: ").append(toIndentedString(_object)).append("\n"); + sb.append(" embedding: ").append(toIndentedString(embedding)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/EmbeddingsCreate200ResponseUsage.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/EmbeddingsCreate200ResponseUsage.java new file mode 100644 index 000000000..3a4e9d91f --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/EmbeddingsCreate200ResponseUsage.java @@ -0,0 +1,195 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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; + +/** EmbeddingsCreate200ResponseUsage */ +// CHECKSTYLE:OFF +public class EmbeddingsCreate200ResponseUsage +// CHECKSTYLE:ON +{ + @JsonProperty("prompt_tokens") + private Integer promptTokens; + + @JsonProperty("total_tokens") + private Integer totalTokens; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the promptTokens of this {@link EmbeddingsCreate200ResponseUsage} instance and return the + * same instance. + * + * @param promptTokens The promptTokens of this {@link EmbeddingsCreate200ResponseUsage} + * @return The same instance of this {@link EmbeddingsCreate200ResponseUsage} class + */ + @Nonnull + public EmbeddingsCreate200ResponseUsage promptTokens(@Nonnull final Integer promptTokens) { + this.promptTokens = promptTokens; + return this; + } + + /** + * Get promptTokens + * + * @return promptTokens The promptTokens of this {@link EmbeddingsCreate200ResponseUsage} + * instance. + */ + @Nonnull + public Integer getPromptTokens() { + return promptTokens; + } + + /** + * Set the promptTokens of this {@link EmbeddingsCreate200ResponseUsage} instance. + * + * @param promptTokens The promptTokens of this {@link EmbeddingsCreate200ResponseUsage} + */ + public void setPromptTokens(@Nonnull final Integer promptTokens) { + this.promptTokens = promptTokens; + } + + /** + * Set the totalTokens of this {@link EmbeddingsCreate200ResponseUsage} instance and return the + * same instance. + * + * @param totalTokens The totalTokens of this {@link EmbeddingsCreate200ResponseUsage} + * @return The same instance of this {@link EmbeddingsCreate200ResponseUsage} class + */ + @Nonnull + public EmbeddingsCreate200ResponseUsage totalTokens(@Nonnull final Integer totalTokens) { + this.totalTokens = totalTokens; + return this; + } + + /** + * Get totalTokens + * + * @return totalTokens The totalTokens of this {@link EmbeddingsCreate200ResponseUsage} instance. + */ + @Nonnull + public Integer getTotalTokens() { + return totalTokens; + } + + /** + * Set the totalTokens of this {@link EmbeddingsCreate200ResponseUsage} instance. + * + * @param totalTokens The totalTokens of this {@link EmbeddingsCreate200ResponseUsage} + */ + public void setTotalTokens(@Nonnull final Integer totalTokens) { + this.totalTokens = totalTokens; + } + + /** + * Get the names of the unrecognizable properties of the {@link EmbeddingsCreate200ResponseUsage}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link EmbeddingsCreate200ResponseUsage} + * instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "EmbeddingsCreate200ResponseUsage has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link EmbeddingsCreate200ResponseUsage} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final EmbeddingsCreate200ResponseUsage embeddingsCreate200ResponseUsage = + (EmbeddingsCreate200ResponseUsage) o; + return Objects.equals( + this.cloudSdkCustomFields, embeddingsCreate200ResponseUsage.cloudSdkCustomFields) + && Objects.equals(this.promptTokens, embeddingsCreate200ResponseUsage.promptTokens) + && Objects.equals(this.totalTokens, embeddingsCreate200ResponseUsage.totalTokens); + } + + @Override + public int hashCode() { + return Objects.hash(promptTokens, totalTokens, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class EmbeddingsCreate200ResponseUsage {\n"); + sb.append(" promptTokens: ").append(toIndentedString(promptTokens)).append("\n"); + sb.append(" totalTokens: ").append(toIndentedString(totalTokens)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/EmbeddingsCreateRequest.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/EmbeddingsCreateRequest.java new file mode 100644 index 000000000..a0cc46c9d --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/EmbeddingsCreateRequest.java @@ -0,0 +1,310 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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; + +/** EmbeddingsCreateRequest */ +// CHECKSTYLE:OFF +public class EmbeddingsCreateRequest +// CHECKSTYLE:ON +{ + @JsonProperty("input") + private EmbeddingsCreateRequestInput input; + + @JsonProperty("user") + private String user; + + @JsonProperty("input_type") + private String inputType; + + @JsonProperty("encoding_format") + private String encodingFormat; + + @JsonProperty("dimensions") + private Integer dimensions; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the input of this {@link EmbeddingsCreateRequest} instance and return the same instance. + * + * @param input The input of this {@link EmbeddingsCreateRequest} + * @return The same instance of this {@link EmbeddingsCreateRequest} class + */ + @Nonnull + public EmbeddingsCreateRequest input(@Nonnull final EmbeddingsCreateRequestInput input) { + this.input = input; + return this; + } + + /** + * Get input + * + * @return input The input of this {@link EmbeddingsCreateRequest} instance. + */ + @Nonnull + public EmbeddingsCreateRequestInput getInput() { + return input; + } + + /** + * Set the input of this {@link EmbeddingsCreateRequest} instance. + * + * @param input The input of this {@link EmbeddingsCreateRequest} + */ + public void setInput(@Nonnull final EmbeddingsCreateRequestInput input) { + this.input = input; + } + + /** + * Set the user of this {@link EmbeddingsCreateRequest} instance and return the same instance. + * + * @param user A unique identifier representing your end-user, which can help monitoring and + * detecting abuse. + * @return The same instance of this {@link EmbeddingsCreateRequest} class + */ + @Nonnull + public EmbeddingsCreateRequest user(@Nullable final String user) { + this.user = user; + return this; + } + + /** + * A unique identifier representing your end-user, which can help monitoring and detecting abuse. + * + * @return user The user of this {@link EmbeddingsCreateRequest} instance. + */ + @Nonnull + public String getUser() { + return user; + } + + /** + * Set the user of this {@link EmbeddingsCreateRequest} instance. + * + * @param user A unique identifier representing your end-user, which can help monitoring and + * detecting abuse. + */ + public void setUser(@Nullable final String user) { + this.user = user; + } + + /** + * Set the inputType of this {@link EmbeddingsCreateRequest} instance and return the same + * instance. + * + * @param inputType input type of embedding search to use + * @return The same instance of this {@link EmbeddingsCreateRequest} class + */ + @Nonnull + public EmbeddingsCreateRequest inputType(@Nullable final String inputType) { + this.inputType = inputType; + return this; + } + + /** + * input type of embedding search to use + * + * @return inputType The inputType of this {@link EmbeddingsCreateRequest} instance. + */ + @Nonnull + public String getInputType() { + return inputType; + } + + /** + * Set the inputType of this {@link EmbeddingsCreateRequest} instance. + * + * @param inputType input type of embedding search to use + */ + public void setInputType(@Nullable final String inputType) { + this.inputType = inputType; + } + + /** + * Set the encodingFormat of this {@link EmbeddingsCreateRequest} instance and return the same + * instance. + * + * @param encodingFormat The format to return the embeddings in. Can be either `float` + * or `base64`. Defaults to `float`. + * @return The same instance of this {@link EmbeddingsCreateRequest} class + */ + @Nonnull + public EmbeddingsCreateRequest encodingFormat(@Nullable final String encodingFormat) { + this.encodingFormat = encodingFormat; + return this; + } + + /** + * The format to return the embeddings in. Can be either `float` or `base64`. + * Defaults to `float`. + * + * @return encodingFormat The encodingFormat of this {@link EmbeddingsCreateRequest} instance. + */ + @Nullable + public String getEncodingFormat() { + return encodingFormat; + } + + /** + * Set the encodingFormat of this {@link EmbeddingsCreateRequest} instance. + * + * @param encodingFormat The format to return the embeddings in. Can be either `float` + * or `base64`. Defaults to `float`. + */ + public void setEncodingFormat(@Nullable final String encodingFormat) { + this.encodingFormat = encodingFormat; + } + + /** + * Set the dimensions of this {@link EmbeddingsCreateRequest} instance and return the same + * instance. + * + * @param dimensions The number of dimensions the resulting output embeddings should have. Only + * supported in `text-embedding-3` and later models. + * @return The same instance of this {@link EmbeddingsCreateRequest} class + */ + @Nonnull + public EmbeddingsCreateRequest dimensions(@Nullable final Integer dimensions) { + this.dimensions = dimensions; + return this; + } + + /** + * The number of dimensions the resulting output embeddings should have. Only supported in + * `text-embedding-3` and later models. + * + * @return dimensions The dimensions of this {@link EmbeddingsCreateRequest} instance. + */ + @Nullable + public Integer getDimensions() { + return dimensions; + } + + /** + * Set the dimensions of this {@link EmbeddingsCreateRequest} instance. + * + * @param dimensions The number of dimensions the resulting output embeddings should have. Only + * supported in `text-embedding-3` and later models. + */ + public void setDimensions(@Nullable final Integer dimensions) { + this.dimensions = dimensions; + } + + /** + * Get the names of the unrecognizable properties of the {@link EmbeddingsCreateRequest}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link EmbeddingsCreateRequest} instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "EmbeddingsCreateRequest has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link EmbeddingsCreateRequest} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final EmbeddingsCreateRequest embeddingsCreateRequest = (EmbeddingsCreateRequest) o; + return Objects.equals(this.cloudSdkCustomFields, embeddingsCreateRequest.cloudSdkCustomFields) + && Objects.equals(this.input, embeddingsCreateRequest.input) + && Objects.equals(this.user, embeddingsCreateRequest.user) + && Objects.equals(this.inputType, embeddingsCreateRequest.inputType) + && Objects.equals(this.encodingFormat, embeddingsCreateRequest.encodingFormat) + && Objects.equals(this.dimensions, embeddingsCreateRequest.dimensions) + && super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash( + input, user, inputType, encodingFormat, dimensions, cloudSdkCustomFields, super.hashCode()); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class EmbeddingsCreateRequest {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" input: ").append(toIndentedString(input)).append("\n"); + sb.append(" user: ").append(toIndentedString(user)).append("\n"); + sb.append(" inputType: ").append(toIndentedString(inputType)).append("\n"); + sb.append(" encodingFormat: ").append(toIndentedString(encodingFormat)).append("\n"); + sb.append(" dimensions: ").append(toIndentedString(dimensions)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/EmbeddingsCreateRequestInput.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/EmbeddingsCreateRequestInput.java new file mode 100644 index 000000000..8982c2c90 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/EmbeddingsCreateRequestInput.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import java.util.List; + +/** + * Input text to get embeddings for, encoded as a string. To get embeddings for multiple inputs in a + * single request, pass an array of strings. Each input must not exceed 2048 tokens in length. + * Unless you are embedding code, we suggest replacing newlines (\\n) in your input with a single + * space, as we have observed inferior results when newlines are present. + */ +public interface EmbeddingsCreateRequestInput { + /** Helper class to create a String that implements {@link EmbeddingsCreateRequestInput}. */ + class InnerString implements EmbeddingsCreateRequestInput { + @com.fasterxml.jackson.annotation.JsonValue String value; + + InnerString(String value) { + this.value = value; + } + } + + /** + * Creator to enable deserialization of a String. + * + * @param val the value to use + * @return a new instance of {@link InnerString}. + */ + @com.fasterxml.jackson.annotation.JsonCreator + static InnerString create(String val) { + return new InnerString(val); + } + + /** + * Helper class to create a list of String that implements {@link EmbeddingsCreateRequestInput}. + */ + record InnerStrings(@com.fasterxml.jackson.annotation.JsonValue List values) + implements EmbeddingsCreateRequestInput {} + + /** + * Creator to enable deserialization of a list of String. + * + * @param val the value to use + * @return a new instance of {@link InnerStrings}. + */ + @com.fasterxml.jackson.annotation.JsonCreator + static InnerStrings create(List val) { + return new InnerStrings(val); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/Error.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/Error.java new file mode 100644 index 000000000..a5d8216fd --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/Error.java @@ -0,0 +1,295 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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; + +/** Error */ +// CHECKSTYLE:OFF +public class Error +// CHECKSTYLE:ON +{ + @JsonProperty("param") + private String param; + + @JsonProperty("type") + private String type; + + @JsonProperty("inner_error") + private InnerError innerError; + + @JsonProperty("code") + private String code; + + @JsonProperty("message") + private String message; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the param of this {@link Error} instance and return the same instance. + * + * @param param The param of this {@link Error} + * @return The same instance of this {@link Error} class + */ + @Nonnull + public Error param(@Nullable final String param) { + this.param = param; + return this; + } + + /** + * Get param + * + * @return param The param of this {@link Error} instance. + */ + @Nonnull + public String getParam() { + return param; + } + + /** + * Set the param of this {@link Error} instance. + * + * @param param The param of this {@link Error} + */ + public void setParam(@Nullable final String param) { + this.param = param; + } + + /** + * Set the type of this {@link Error} instance and return the same instance. + * + * @param type The type of this {@link Error} + * @return The same instance of this {@link Error} class + */ + @Nonnull + public Error type(@Nullable final String type) { + this.type = type; + return this; + } + + /** + * Get type + * + * @return type The type of this {@link Error} instance. + */ + @Nonnull + public String getType() { + return type; + } + + /** + * Set the type of this {@link Error} instance. + * + * @param type The type of this {@link Error} + */ + public void setType(@Nullable final String type) { + this.type = type; + } + + /** + * Set the innerError of this {@link Error} instance and return the same instance. + * + * @param innerError The innerError of this {@link Error} + * @return The same instance of this {@link Error} class + */ + @Nonnull + public Error innerError(@Nullable final InnerError innerError) { + this.innerError = innerError; + return this; + } + + /** + * Get innerError + * + * @return innerError The innerError of this {@link Error} instance. + */ + @Nonnull + public InnerError getInnerError() { + return innerError; + } + + /** + * Set the innerError of this {@link Error} instance. + * + * @param innerError The innerError of this {@link Error} + */ + public void setInnerError(@Nullable final InnerError innerError) { + this.innerError = innerError; + } + + /** + * Set the code of this {@link Error} instance and return the same instance. + * + * @param code The code of this {@link Error} + * @return The same instance of this {@link Error} class + */ + @Nonnull + public Error code(@Nullable final String code) { + this.code = code; + return this; + } + + /** + * Get code + * + * @return code The code of this {@link Error} instance. + */ + @Nonnull + public String getCode() { + return code; + } + + /** + * Set the code of this {@link Error} instance. + * + * @param code The code of this {@link Error} + */ + public void setCode(@Nullable final String code) { + this.code = code; + } + + /** + * Set the message of this {@link Error} instance and return the same instance. + * + * @param message The message of this {@link Error} + * @return The same instance of this {@link Error} class + */ + @Nonnull + public Error message(@Nullable final String message) { + this.message = message; + return this; + } + + /** + * Get message + * + * @return message The message of this {@link Error} instance. + */ + @Nonnull + public String getMessage() { + return message; + } + + /** + * Set the message of this {@link Error} instance. + * + * @param message The message of this {@link Error} + */ + public void setMessage(@Nullable final String message) { + this.message = message; + } + + /** + * Get the names of the unrecognizable properties of the {@link Error}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link Error} instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException("Error has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link Error} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final Error error = (Error) o; + return Objects.equals(this.cloudSdkCustomFields, error.cloudSdkCustomFields) + && Objects.equals(this.param, error.param) + && Objects.equals(this.type, error.type) + && Objects.equals(this.innerError, error.innerError) + && Objects.equals(this.code, error.code) + && Objects.equals(this.message, error.message); + } + + @Override + public int hashCode() { + return Objects.hash(param, type, innerError, code, message, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class Error {\n"); + sb.append(" param: ").append(toIndentedString(param)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" innerError: ").append(toIndentedString(innerError)).append("\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ErrorBase.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ErrorBase.java new file mode 100644 index 000000000..04c71dc9c --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ErrorBase.java @@ -0,0 +1,187 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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; + +/** ErrorBase */ +// CHECKSTYLE:OFF +public class ErrorBase +// CHECKSTYLE:ON +{ + @JsonProperty("code") + private String code; + + @JsonProperty("message") + private String message; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the code of this {@link ErrorBase} instance and return the same instance. + * + * @param code The code of this {@link ErrorBase} + * @return The same instance of this {@link ErrorBase} class + */ + @Nonnull + public ErrorBase code(@Nullable final String code) { + this.code = code; + return this; + } + + /** + * Get code + * + * @return code The code of this {@link ErrorBase} instance. + */ + @Nonnull + public String getCode() { + return code; + } + + /** + * Set the code of this {@link ErrorBase} instance. + * + * @param code The code of this {@link ErrorBase} + */ + public void setCode(@Nullable final String code) { + this.code = code; + } + + /** + * Set the message of this {@link ErrorBase} instance and return the same instance. + * + * @param message The message of this {@link ErrorBase} + * @return The same instance of this {@link ErrorBase} class + */ + @Nonnull + public ErrorBase message(@Nullable final String message) { + this.message = message; + return this; + } + + /** + * Get message + * + * @return message The message of this {@link ErrorBase} instance. + */ + @Nonnull + public String getMessage() { + return message; + } + + /** + * Set the message of this {@link ErrorBase} instance. + * + * @param message The message of this {@link ErrorBase} + */ + public void setMessage(@Nullable final String message) { + this.message = message; + } + + /** + * Get the names of the unrecognizable properties of the {@link ErrorBase}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ErrorBase} instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException("ErrorBase has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ErrorBase} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ErrorBase errorBase = (ErrorBase) o; + return Objects.equals(this.cloudSdkCustomFields, errorBase.cloudSdkCustomFields) + && Objects.equals(this.code, errorBase.code) + && Objects.equals(this.message, errorBase.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, message, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ErrorBase {\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ErrorResponse.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ErrorResponse.java new file mode 100644 index 000000000..b63867090 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ErrorResponse.java @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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; + +/** ErrorResponse */ +// CHECKSTYLE:OFF +public class ErrorResponse +// CHECKSTYLE:ON +{ + @JsonProperty("error") + private Error error; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the error of this {@link ErrorResponse} instance and return the same instance. + * + * @param error The error of this {@link ErrorResponse} + * @return The same instance of this {@link ErrorResponse} class + */ + @Nonnull + public ErrorResponse error(@Nullable final Error error) { + this.error = error; + return this; + } + + /** + * Get error + * + * @return error The error of this {@link ErrorResponse} instance. + */ + @Nonnull + public Error getError() { + return error; + } + + /** + * Set the error of this {@link ErrorResponse} instance. + * + * @param error The error of this {@link ErrorResponse} + */ + public void setError(@Nullable final Error error) { + this.error = error; + } + + /** + * Get the names of the unrecognizable properties of the {@link ErrorResponse}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ErrorResponse} instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException("ErrorResponse has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ErrorResponse} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ErrorResponse errorResponse = (ErrorResponse) o; + return Objects.equals(this.cloudSdkCustomFields, errorResponse.cloudSdkCustomFields) + && Objects.equals(this.error, errorResponse.error); + } + + @Override + public int hashCode() { + return Objects.hash(error, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ErrorResponse {\n"); + sb.append(" error: ").append(toIndentedString(error)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/FunctionObject.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/FunctionObject.java new file mode 100644 index 000000000..8678fca59 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/FunctionObject.java @@ -0,0 +1,308 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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.HashMap; +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; + +/** FunctionObject */ +// CHECKSTYLE:OFF +public class FunctionObject +// CHECKSTYLE:ON +{ + @JsonProperty("description") + private String description; + + @JsonProperty("name") + private String name; + + @JsonProperty("parameters") + private Map parameters = new HashMap<>(); + + @JsonProperty("strict") + private Boolean strict = false; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the description of this {@link FunctionObject} instance and return the same instance. + * + * @param description A description of what the function does, used by the model to choose when + * and how to call the function. + * @return The same instance of this {@link FunctionObject} class + */ + @Nonnull + public FunctionObject description(@Nullable final String description) { + this.description = description; + return this; + } + + /** + * A description of what the function does, used by the model to choose when and how to call the + * function. + * + * @return description The description of this {@link FunctionObject} instance. + */ + @Nonnull + public String getDescription() { + return description; + } + + /** + * Set the description of this {@link FunctionObject} instance. + * + * @param description A description of what the function does, used by the model to choose when + * and how to call the function. + */ + public void setDescription(@Nullable final String description) { + this.description = description; + } + + /** + * Set the name of this {@link FunctionObject} instance and return the same instance. + * + * @param name The name of the function to be called. Must be a-z, A-Z, 0-9, or contain + * underscores and dashes, with a maximum length of 64. + * @return The same instance of this {@link FunctionObject} class + */ + @Nonnull + public FunctionObject name(@Nonnull final String name) { + this.name = name; + return this; + } + + /** + * The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and + * dashes, with a maximum length of 64. + * + * @return name The name of this {@link FunctionObject} instance. + */ + @Nonnull + public String getName() { + return name; + } + + /** + * Set the name of this {@link FunctionObject} instance. + * + * @param name The name of the function to be called. Must be a-z, A-Z, 0-9, or contain + * underscores and dashes, with a maximum length of 64. + */ + public void setName(@Nonnull final String name) { + this.name = name; + } + + /** + * Set the parameters of this {@link FunctionObject} instance and return the same instance. + * + * @param parameters The parameters the functions accepts, described as a JSON Schema object. See + * the + * guide](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/function-calling) + * for examples, and the [JSON Schema + * reference](https://json-schema.org/understanding-json-schema/) for documentation about the + * format. Omitting `parameters` defines a function with an empty parameter list. + * @return The same instance of this {@link FunctionObject} class + */ + @Nonnull + public FunctionObject parameters(@Nullable final Map parameters) { + this.parameters = parameters; + return this; + } + + /** + * Put one parameters instance to this {@link FunctionObject} instance. + * + * @param key The String key of this parameters instance + * @param parametersItem The parameters that should be added under the given key + * @return The same instance of type {@link FunctionObject} + */ + @Nonnull + public FunctionObject putparametersItem( + @Nonnull final String key, @Nullable final Object parametersItem) { + if (this.parameters == null) { + this.parameters = new HashMap<>(); + } + this.parameters.put(key, parametersItem); + return this; + } + + /** + * The parameters the functions accepts, described as a JSON Schema object. See the + * guide](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/function-calling) for + * examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) + * for documentation about the format. Omitting `parameters` defines a function with an + * empty parameter list. + * + * @return parameters The parameters of this {@link FunctionObject} instance. + */ + @Nonnull + public Map getParameters() { + return parameters; + } + + /** + * Set the parameters of this {@link FunctionObject} instance. + * + * @param parameters The parameters the functions accepts, described as a JSON Schema object. See + * the + * guide](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/function-calling) + * for examples, and the [JSON Schema + * reference](https://json-schema.org/understanding-json-schema/) for documentation about the + * format. Omitting `parameters` defines a function with an empty parameter list. + */ + public void setParameters(@Nullable final Map parameters) { + this.parameters = parameters; + } + + /** + * Set the strict of this {@link FunctionObject} instance and return the same instance. + * + * @param strict Whether to enable strict schema adherence when generating the function call. If + * set to true, the model will follow the exact schema defined in the `parameters` + * field. Only a subset of JSON Schema is supported when `strict` is + * `true`. Learn more about Structured Outputs in the [function calling + * guide](docs/guides/function-calling). + * @return The same instance of this {@link FunctionObject} class + */ + @Nonnull + public FunctionObject strict(@Nullable final Boolean strict) { + this.strict = strict; + return this; + } + + /** + * Whether to enable strict schema adherence when generating the function call. If set to true, + * the model will follow the exact schema defined in the `parameters` field. Only a + * subset of JSON Schema is supported when `strict` is `true`. Learn more + * about Structured Outputs in the [function calling guide](docs/guides/function-calling). + * + * @return strict The strict of this {@link FunctionObject} instance. + */ + @Nullable + public Boolean isStrict() { + return strict; + } + + /** + * Set the strict of this {@link FunctionObject} instance. + * + * @param strict Whether to enable strict schema adherence when generating the function call. If + * set to true, the model will follow the exact schema defined in the `parameters` + * field. Only a subset of JSON Schema is supported when `strict` is + * `true`. Learn more about Structured Outputs in the [function calling + * guide](docs/guides/function-calling). + */ + public void setStrict(@Nullable final Boolean strict) { + this.strict = strict; + } + + /** + * Get the names of the unrecognizable properties of the {@link FunctionObject}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link FunctionObject} instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException("FunctionObject has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link FunctionObject} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final FunctionObject functionObject = (FunctionObject) o; + return Objects.equals(this.cloudSdkCustomFields, functionObject.cloudSdkCustomFields) + && Objects.equals(this.description, functionObject.description) + && Objects.equals(this.name, functionObject.name) + && Objects.equals(this.parameters, functionObject.parameters) + && Objects.equals(this.strict, functionObject.strict); + } + + @Override + public int hashCode() { + return Objects.hash(description, name, parameters, strict, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class FunctionObject {\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" parameters: ").append(toIndentedString(parameters)).append("\n"); + sb.append(" strict: ").append(toIndentedString(strict)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/InnerError.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/InnerError.java new file mode 100644 index 000000000..81fad3781 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/InnerError.java @@ -0,0 +1,191 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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; + +/** Inner error with additional details. */ +// CHECKSTYLE:OFF +public class InnerError +// CHECKSTYLE:ON +{ + @JsonProperty("code") + private InnerErrorCode code; + + @JsonProperty("content_filter_results") + private ContentFilterPromptResults contentFilterResults; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the code of this {@link InnerError} instance and return the same instance. + * + * @param code The code of this {@link InnerError} + * @return The same instance of this {@link InnerError} class + */ + @Nonnull + public InnerError code(@Nullable final InnerErrorCode code) { + this.code = code; + return this; + } + + /** + * Get code + * + * @return code The code of this {@link InnerError} instance. + */ + @Nonnull + public InnerErrorCode getCode() { + return code; + } + + /** + * Set the code of this {@link InnerError} instance. + * + * @param code The code of this {@link InnerError} + */ + public void setCode(@Nullable final InnerErrorCode code) { + this.code = code; + } + + /** + * Set the contentFilterResults of this {@link InnerError} instance and return the same instance. + * + * @param contentFilterResults The contentFilterResults of this {@link InnerError} + * @return The same instance of this {@link InnerError} class + */ + @Nonnull + public InnerError contentFilterResults( + @Nullable final ContentFilterPromptResults contentFilterResults) { + this.contentFilterResults = contentFilterResults; + return this; + } + + /** + * Get contentFilterResults + * + * @return contentFilterResults The contentFilterResults of this {@link InnerError} instance. + */ + @Nonnull + public ContentFilterPromptResults getContentFilterResults() { + return contentFilterResults; + } + + /** + * Set the contentFilterResults of this {@link InnerError} instance. + * + * @param contentFilterResults The contentFilterResults of this {@link InnerError} + */ + public void setContentFilterResults( + @Nullable final ContentFilterPromptResults contentFilterResults) { + this.contentFilterResults = contentFilterResults; + } + + /** + * Get the names of the unrecognizable properties of the {@link InnerError}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link InnerError} instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException("InnerError has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link InnerError} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final InnerError innerError = (InnerError) o; + return Objects.equals(this.cloudSdkCustomFields, innerError.cloudSdkCustomFields) + && Objects.equals(this.code, innerError.code) + && Objects.equals(this.contentFilterResults, innerError.contentFilterResults); + } + + @Override + public int hashCode() { + return Objects.hash(code, contentFilterResults, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class InnerError {\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" contentFilterResults: ") + .append(toIndentedString(contentFilterResults)) + .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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/InnerErrorCode.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/InnerErrorCode.java new file mode 100644 index 000000000..cd97a9b9a --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/InnerErrorCode.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import javax.annotation.Nonnull; + +/** Error codes for the inner error object. */ +public enum InnerErrorCode { + RESPONSIBLE_AI_POLICY_VIOLATION("ResponsibleAIPolicyViolation"); + + private final String value; + + InnerErrorCode(String value) { + this.value = value; + } + + /** + * @return The enum value. + */ + @JsonValue + public String getValue() { + return value; + } + + /** + * @return The String representation of the enum value. + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Converts the given value to its enum representation. + * + * @param value The input value. + * @return The enum representation of the given value. + */ + @JsonCreator + public static InnerErrorCode fromValue(@Nonnull final String value) { + for (final InnerErrorCode b : InnerErrorCode.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/PromptFilterResult.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/PromptFilterResult.java new file mode 100644 index 000000000..d7fd71917 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/PromptFilterResult.java @@ -0,0 +1,193 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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; + +/** Content filtering results for a single prompt in the request. */ +// CHECKSTYLE:OFF +public class PromptFilterResult +// CHECKSTYLE:ON +{ + @JsonProperty("prompt_index") + private Integer promptIndex; + + @JsonProperty("content_filter_results") + private ContentFilterPromptResults contentFilterResults; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the promptIndex of this {@link PromptFilterResult} instance and return the same instance. + * + * @param promptIndex The promptIndex of this {@link PromptFilterResult} + * @return The same instance of this {@link PromptFilterResult} class + */ + @Nonnull + public PromptFilterResult promptIndex(@Nullable final Integer promptIndex) { + this.promptIndex = promptIndex; + return this; + } + + /** + * Get promptIndex + * + * @return promptIndex The promptIndex of this {@link PromptFilterResult} instance. + */ + @Nonnull + public Integer getPromptIndex() { + return promptIndex; + } + + /** + * Set the promptIndex of this {@link PromptFilterResult} instance. + * + * @param promptIndex The promptIndex of this {@link PromptFilterResult} + */ + public void setPromptIndex(@Nullable final Integer promptIndex) { + this.promptIndex = promptIndex; + } + + /** + * Set the contentFilterResults of this {@link PromptFilterResult} instance and return the same + * instance. + * + * @param contentFilterResults The contentFilterResults of this {@link PromptFilterResult} + * @return The same instance of this {@link PromptFilterResult} class + */ + @Nonnull + public PromptFilterResult contentFilterResults( + @Nullable final ContentFilterPromptResults contentFilterResults) { + this.contentFilterResults = contentFilterResults; + return this; + } + + /** + * Get contentFilterResults + * + * @return contentFilterResults The contentFilterResults of this {@link PromptFilterResult} + * instance. + */ + @Nonnull + public ContentFilterPromptResults getContentFilterResults() { + return contentFilterResults; + } + + /** + * Set the contentFilterResults of this {@link PromptFilterResult} instance. + * + * @param contentFilterResults The contentFilterResults of this {@link PromptFilterResult} + */ + public void setContentFilterResults( + @Nullable final ContentFilterPromptResults contentFilterResults) { + this.contentFilterResults = contentFilterResults; + } + + /** + * Get the names of the unrecognizable properties of the {@link PromptFilterResult}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link PromptFilterResult} instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException("PromptFilterResult has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link PromptFilterResult} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final PromptFilterResult promptFilterResult = (PromptFilterResult) o; + return Objects.equals(this.cloudSdkCustomFields, promptFilterResult.cloudSdkCustomFields) + && Objects.equals(this.promptIndex, promptFilterResult.promptIndex) + && Objects.equals(this.contentFilterResults, promptFilterResult.contentFilterResults); + } + + @Override + public int hashCode() { + return Objects.hash(promptIndex, contentFilterResults, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class PromptFilterResult {\n"); + sb.append(" promptIndex: ").append(toIndentedString(promptIndex)).append("\n"); + sb.append(" contentFilterResults: ") + .append(toIndentedString(contentFilterResults)) + .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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ResponseFormatJsonObject.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ResponseFormatJsonObject.java new file mode 100644 index 000000000..254aa84fc --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ResponseFormatJsonObject.java @@ -0,0 +1,205 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +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; + +/** ResponseFormatJsonObject */ +// CHECKSTYLE:OFF +public class ResponseFormatJsonObject implements CreateChatCompletionRequestAllOfResponseFormat +// CHECKSTYLE:ON +{ + /** The type of response format being defined: `json_object` */ + public enum TypeEnum { + /** The JSON_OBJECT option of this ResponseFormatJsonObject */ + JSON_OBJECT("json_object"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value The String value + * @return The enum value of type ResponseFormatJsonObject + */ + @JsonCreator + @Nonnull + public static TypeEnum fromValue(@Nonnull final String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("type") + private TypeEnum type; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the type of this {@link ResponseFormatJsonObject} instance and return the same instance. + * + * @param type The type of response format being defined: `json_object` + * @return The same instance of this {@link ResponseFormatJsonObject} class + */ + @Nonnull + public ResponseFormatJsonObject type(@Nonnull final TypeEnum type) { + this.type = type; + return this; + } + + /** + * The type of response format being defined: `json_object` + * + * @return type The type of this {@link ResponseFormatJsonObject} instance. + */ + @Nonnull + public TypeEnum getType() { + return type; + } + + /** + * Set the type of this {@link ResponseFormatJsonObject} instance. + * + * @param type The type of response format being defined: `json_object` + */ + public void setType(@Nonnull final TypeEnum type) { + this.type = type; + } + + /** + * Get the names of the unrecognizable properties of the {@link ResponseFormatJsonObject}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ResponseFormatJsonObject} instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ResponseFormatJsonObject has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ResponseFormatJsonObject} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ResponseFormatJsonObject responseFormatJsonObject = (ResponseFormatJsonObject) o; + return Objects.equals(this.cloudSdkCustomFields, responseFormatJsonObject.cloudSdkCustomFields) + && Objects.equals(this.type, responseFormatJsonObject.type); + } + + @Override + public int hashCode() { + return Objects.hash(type, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ResponseFormatJsonObject {\n"); + sb.append(" type: ").append(toIndentedString(type)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ResponseFormatJsonSchema.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ResponseFormatJsonSchema.java new file mode 100644 index 000000000..c39c63a53 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ResponseFormatJsonSchema.java @@ -0,0 +1,243 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +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; + +/** ResponseFormatJsonSchema */ +// CHECKSTYLE:OFF +public class ResponseFormatJsonSchema implements CreateChatCompletionRequestAllOfResponseFormat +// CHECKSTYLE:ON +{ + /** The type of response format being defined: `json_schema` */ + public enum TypeEnum { + /** The JSON_SCHEMA option of this ResponseFormatJsonSchema */ + JSON_SCHEMA("json_schema"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value The String value + * @return The enum value of type ResponseFormatJsonSchema + */ + @JsonCreator + @Nonnull + public static TypeEnum fromValue(@Nonnull final String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("type") + private TypeEnum type; + + @JsonProperty("json_schema") + private ResponseFormatJsonSchemaJsonSchema jsonSchema; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the type of this {@link ResponseFormatJsonSchema} instance and return the same instance. + * + * @param type The type of response format being defined: `json_schema` + * @return The same instance of this {@link ResponseFormatJsonSchema} class + */ + @Nonnull + public ResponseFormatJsonSchema type(@Nonnull final TypeEnum type) { + this.type = type; + return this; + } + + /** + * The type of response format being defined: `json_schema` + * + * @return type The type of this {@link ResponseFormatJsonSchema} instance. + */ + @Nonnull + public TypeEnum getType() { + return type; + } + + /** + * Set the type of this {@link ResponseFormatJsonSchema} instance. + * + * @param type The type of response format being defined: `json_schema` + */ + public void setType(@Nonnull final TypeEnum type) { + this.type = type; + } + + /** + * Set the jsonSchema of this {@link ResponseFormatJsonSchema} instance and return the same + * instance. + * + * @param jsonSchema The jsonSchema of this {@link ResponseFormatJsonSchema} + * @return The same instance of this {@link ResponseFormatJsonSchema} class + */ + @Nonnull + public ResponseFormatJsonSchema jsonSchema( + @Nonnull final ResponseFormatJsonSchemaJsonSchema jsonSchema) { + this.jsonSchema = jsonSchema; + return this; + } + + /** + * Get jsonSchema + * + * @return jsonSchema The jsonSchema of this {@link ResponseFormatJsonSchema} instance. + */ + @Nonnull + public ResponseFormatJsonSchemaJsonSchema getJsonSchema() { + return jsonSchema; + } + + /** + * Set the jsonSchema of this {@link ResponseFormatJsonSchema} instance. + * + * @param jsonSchema The jsonSchema of this {@link ResponseFormatJsonSchema} + */ + public void setJsonSchema(@Nonnull final ResponseFormatJsonSchemaJsonSchema jsonSchema) { + this.jsonSchema = jsonSchema; + } + + /** + * Get the names of the unrecognizable properties of the {@link ResponseFormatJsonSchema}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ResponseFormatJsonSchema} instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ResponseFormatJsonSchema has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ResponseFormatJsonSchema} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ResponseFormatJsonSchema responseFormatJsonSchema = (ResponseFormatJsonSchema) o; + return Objects.equals(this.cloudSdkCustomFields, responseFormatJsonSchema.cloudSdkCustomFields) + && Objects.equals(this.type, responseFormatJsonSchema.type) + && Objects.equals(this.jsonSchema, responseFormatJsonSchema.jsonSchema); + } + + @Override + public int hashCode() { + return Objects.hash(type, jsonSchema, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ResponseFormatJsonSchema {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" jsonSchema: ").append(toIndentedString(jsonSchema)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ResponseFormatJsonSchemaJsonSchema.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ResponseFormatJsonSchemaJsonSchema.java new file mode 100644 index 000000000..084c9e7c7 --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ResponseFormatJsonSchemaJsonSchema.java @@ -0,0 +1,302 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +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.HashMap; +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; + +/** ResponseFormatJsonSchemaJsonSchema */ +// CHECKSTYLE:OFF +public class ResponseFormatJsonSchemaJsonSchema +// CHECKSTYLE:ON +{ + @JsonProperty("description") + private String description; + + @JsonProperty("name") + private String name; + + @JsonProperty("schema") + private Map schema = new HashMap<>(); + + @JsonProperty("strict") + private Boolean strict = false; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the description of this {@link ResponseFormatJsonSchemaJsonSchema} instance and return the + * same instance. + * + * @param description A description of what the response format is for, used by the model to + * determine how to respond in the format. + * @return The same instance of this {@link ResponseFormatJsonSchemaJsonSchema} class + */ + @Nonnull + public ResponseFormatJsonSchemaJsonSchema description(@Nullable final String description) { + this.description = description; + return this; + } + + /** + * A description of what the response format is for, used by the model to determine how to respond + * in the format. + * + * @return description The description of this {@link ResponseFormatJsonSchemaJsonSchema} + * instance. + */ + @Nonnull + public String getDescription() { + return description; + } + + /** + * Set the description of this {@link ResponseFormatJsonSchemaJsonSchema} instance. + * + * @param description A description of what the response format is for, used by the model to + * determine how to respond in the format. + */ + public void setDescription(@Nullable final String description) { + this.description = description; + } + + /** + * Set the name of this {@link ResponseFormatJsonSchemaJsonSchema} instance and return the same + * instance. + * + * @param name The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and + * dashes, with a maximum length of 64. + * @return The same instance of this {@link ResponseFormatJsonSchemaJsonSchema} class + */ + @Nonnull + public ResponseFormatJsonSchemaJsonSchema name(@Nonnull final String name) { + this.name = name; + return this; + } + + /** + * The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with + * a maximum length of 64. + * + * @return name The name of this {@link ResponseFormatJsonSchemaJsonSchema} instance. + */ + @Nonnull + public String getName() { + return name; + } + + /** + * Set the name of this {@link ResponseFormatJsonSchemaJsonSchema} instance. + * + * @param name The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and + * dashes, with a maximum length of 64. + */ + public void setName(@Nonnull final String name) { + this.name = name; + } + + /** + * Set the schema of this {@link ResponseFormatJsonSchemaJsonSchema} instance and return the same + * instance. + * + * @param schema The schema for the response format, described as a JSON Schema object. + * @return The same instance of this {@link ResponseFormatJsonSchemaJsonSchema} class + */ + @Nonnull + public ResponseFormatJsonSchemaJsonSchema schema(@Nullable final Map schema) { + this.schema = schema; + return this; + } + + /** + * Put one schema instance to this {@link ResponseFormatJsonSchemaJsonSchema} instance. + * + * @param key The String key of this schema instance + * @param schemaItem The schema that should be added under the given key + * @return The same instance of type {@link ResponseFormatJsonSchemaJsonSchema} + */ + @Nonnull + public ResponseFormatJsonSchemaJsonSchema putschemaItem( + @Nonnull final String key, @Nullable final Object schemaItem) { + if (this.schema == null) { + this.schema = new HashMap<>(); + } + this.schema.put(key, schemaItem); + return this; + } + + /** + * The schema for the response format, described as a JSON Schema object. + * + * @return schema The schema of this {@link ResponseFormatJsonSchemaJsonSchema} instance. + */ + @Nonnull + public Map getSchema() { + return schema; + } + + /** + * Set the schema of this {@link ResponseFormatJsonSchemaJsonSchema} instance. + * + * @param schema The schema for the response format, described as a JSON Schema object. + */ + public void setSchema(@Nullable final Map schema) { + this.schema = schema; + } + + /** + * Set the strict of this {@link ResponseFormatJsonSchemaJsonSchema} instance and return the same + * instance. + * + * @param strict Whether to enable strict schema adherence when generating the output. If set to + * true, the model will always follow the exact schema defined in the `schema` + * field. Only a subset of JSON Schema is supported when `strict` is + * `true`. + * @return The same instance of this {@link ResponseFormatJsonSchemaJsonSchema} class + */ + @Nonnull + public ResponseFormatJsonSchemaJsonSchema strict(@Nullable final Boolean strict) { + this.strict = strict; + return this; + } + + /** + * Whether to enable strict schema adherence when generating the output. If set to true, the model + * will always follow the exact schema defined in the `schema` field. Only a subset of + * JSON Schema is supported when `strict` is `true`. + * + * @return strict The strict of this {@link ResponseFormatJsonSchemaJsonSchema} instance. + */ + @Nullable + public Boolean isStrict() { + return strict; + } + + /** + * Set the strict of this {@link ResponseFormatJsonSchemaJsonSchema} instance. + * + * @param strict Whether to enable strict schema adherence when generating the output. If set to + * true, the model will always follow the exact schema defined in the `schema` + * field. Only a subset of JSON Schema is supported when `strict` is + * `true`. + */ + public void setStrict(@Nullable final Boolean strict) { + this.strict = strict; + } + + /** + * Get the names of the unrecognizable properties of the {@link + * ResponseFormatJsonSchemaJsonSchema}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ResponseFormatJsonSchemaJsonSchema} + * instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException( + "ResponseFormatJsonSchemaJsonSchema has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ResponseFormatJsonSchemaJsonSchema} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ResponseFormatJsonSchemaJsonSchema responseFormatJsonSchemaJsonSchema = + (ResponseFormatJsonSchemaJsonSchema) o; + return Objects.equals( + this.cloudSdkCustomFields, responseFormatJsonSchemaJsonSchema.cloudSdkCustomFields) + && Objects.equals(this.description, responseFormatJsonSchemaJsonSchema.description) + && Objects.equals(this.name, responseFormatJsonSchemaJsonSchema.name) + && Objects.equals(this.schema, responseFormatJsonSchemaJsonSchema.schema) + && Objects.equals(this.strict, responseFormatJsonSchemaJsonSchema.strict); + } + + @Override + public int hashCode() { + return Objects.hash(description, name, schema, strict, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ResponseFormatJsonSchemaJsonSchema {\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" schema: ").append(toIndentedString(schema)).append("\n"); + sb.append(" strict: ").append(toIndentedString(strict)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ResponseFormatText.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ResponseFormatText.java new file mode 100644 index 000000000..ed22f57ea --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ResponseFormatText.java @@ -0,0 +1,204 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +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; + +/** ResponseFormatText */ +// CHECKSTYLE:OFF +public class ResponseFormatText implements CreateChatCompletionRequestAllOfResponseFormat +// CHECKSTYLE:ON +{ + /** The type of response format being defined: `text` */ + public enum TypeEnum { + /** The TEXT option of this ResponseFormatText */ + TEXT("text"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + /** + * Get the value of the enum + * + * @return The enum value + */ + @JsonValue + @Nonnull + public String getValue() { + return value; + } + + /** + * Get the String value of the enum value. + * + * @return The enum value as String + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * + * @param value The String value + * @return The enum value of type ResponseFormatText + */ + @JsonCreator + @Nonnull + public static TypeEnum fromValue(@Nonnull final String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("type") + private TypeEnum type; + + @JsonAnySetter @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the type of this {@link ResponseFormatText} instance and return the same instance. + * + * @param type The type of response format being defined: `text` + * @return The same instance of this {@link ResponseFormatText} class + */ + @Nonnull + public ResponseFormatText type(@Nonnull final TypeEnum type) { + this.type = type; + return this; + } + + /** + * The type of response format being defined: `text` + * + * @return type The type of this {@link ResponseFormatText} instance. + */ + @Nonnull + public TypeEnum getType() { + return type; + } + + /** + * Set the type of this {@link ResponseFormatText} instance. + * + * @param type The type of response format being defined: `text` + */ + public void setType(@Nonnull final TypeEnum type) { + this.type = type; + } + + /** + * Get the names of the unrecognizable properties of the {@link ResponseFormatText}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link ResponseFormatText} instance. + * + * @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 + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { + if (!cloudSdkCustomFields.containsKey(name)) { + throw new NoSuchElementException("ResponseFormatText has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link ResponseFormatText} 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 Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final ResponseFormatText responseFormatText = (ResponseFormatText) o; + return Objects.equals(this.cloudSdkCustomFields, responseFormatText.cloudSdkCustomFields) + && Objects.equals(this.type, responseFormatText.type); + } + + @Override + public int hashCode() { + return Objects.hash(type, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ResponseFormatText {\n"); + sb.append(" type: ").append(toIndentedString(type)).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 Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ToolCallType.java b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ToolCallType.java new file mode 100644 index 000000000..8a8b6b35d --- /dev/null +++ b/foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/model2/ToolCallType.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Azure OpenAI Service API + * Azure OpenAI APIs for completions and search + * + * The version of the OpenAPI document: 2024-10-21 + * + * + * 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.foundationmodels.openai.model2; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import javax.annotation.Nonnull; + +/** The type of the tool call, in this case `function`. */ +public enum ToolCallType { + FUNCTION("function"); + + private final String value; + + ToolCallType(String value) { + this.value = value; + } + + /** + * @return The enum value. + */ + @JsonValue + public String getValue() { + return value; + } + + /** + * @return The String representation of the enum value. + */ + @Override + @Nonnull + public String toString() { + return String.valueOf(value); + } + + /** + * Converts the given value to its enum representation. + * + * @param value The input value. + * @return The enum representation of the given value. + */ + @JsonCreator + public static ToolCallType fromValue(@Nonnull final String value) { + for (final ToolCallType b : ToolCallType.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} diff --git a/foundation-models/openai/src/test/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiClientTest.java b/foundation-models/openai/src/test/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiClientTest.java index 67c1c8a24..94cb25252 100644 --- a/foundation-models/openai/src/test/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiClientTest.java +++ b/foundation-models/openai/src/test/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiClientTest.java @@ -1,9 +1,14 @@ package com.sap.ai.sdk.foundationmodels.openai; import static com.github.tomakehurst.wiremock.client.WireMock.*; -import static com.sap.ai.sdk.foundationmodels.openai.model.OpenAiContentFilterSeverityResult.Severity.SAFE; +import static com.sap.ai.sdk.foundationmodels.openai.model2.ChatCompletionResponseMessageRole.ASSISTANT; +import static com.sap.ai.sdk.foundationmodels.openai.model2.ContentFilterSeverityResult.SeverityEnum.SAFE; +import static com.sap.ai.sdk.foundationmodels.openai.model2.CreateChatCompletionResponse.ObjectEnum.UNKNOWN_DEFAULT_OPEN_API; +import static com.sap.ai.sdk.foundationmodels.openai.model2.CreateChatCompletionResponseChoicesInner.FinishReasonEnum.STOP; +import static com.sap.ai.sdk.foundationmodels.openai.model2.CreateChatCompletionStreamResponse.ObjectEnum.CHAT_COMPLETION_CHUNK; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.assertj.core.api.InstanceOfAssertFactories.MAP; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; @@ -12,24 +17,33 @@ import static org.mockito.Mockito.when; import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.ObjectMapper; import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo; import com.github.tomakehurst.wiremock.junit5.WireMockTest; import com.github.tomakehurst.wiremock.stubbing.Scenario; -import com.sap.ai.sdk.foundationmodels.openai.model.OpenAiChatCompletionChoice; -import com.sap.ai.sdk.foundationmodels.openai.model.OpenAiChatCompletionDelta; -import com.sap.ai.sdk.foundationmodels.openai.model.OpenAiChatCompletionOutput; -import com.sap.ai.sdk.foundationmodels.openai.model.OpenAiChatCompletionParameters; -import com.sap.ai.sdk.foundationmodels.openai.model.OpenAiChatMessage.OpenAiChatSystemMessage; -import com.sap.ai.sdk.foundationmodels.openai.model.OpenAiChatMessage.OpenAiChatUserMessage; -import com.sap.ai.sdk.foundationmodels.openai.model.OpenAiContentFilterPromptResults; -import com.sap.ai.sdk.foundationmodels.openai.model.OpenAiEmbeddingParameters; +import com.sap.ai.sdk.foundationmodels.openai.model2.ChatCompletionRequestSystemMessage; +import com.sap.ai.sdk.foundationmodels.openai.model2.ChatCompletionRequestSystemMessageContent; +import com.sap.ai.sdk.foundationmodels.openai.model2.ChatCompletionRequestUserMessage; +import com.sap.ai.sdk.foundationmodels.openai.model2.ChatCompletionRequestUserMessageContent; +import com.sap.ai.sdk.foundationmodels.openai.model2.CompletionUsage; +import com.sap.ai.sdk.foundationmodels.openai.model2.ContentFilterChoiceResults; +import com.sap.ai.sdk.foundationmodels.openai.model2.ContentFilterPromptResults; +import com.sap.ai.sdk.foundationmodels.openai.model2.CreateChatCompletionRequest; +import com.sap.ai.sdk.foundationmodels.openai.model2.CreateChatCompletionResponse; +import com.sap.ai.sdk.foundationmodels.openai.model2.CreateChatCompletionResponseChoicesInner; +import com.sap.ai.sdk.foundationmodels.openai.model2.CreateChatCompletionStreamResponse; +import com.sap.ai.sdk.foundationmodels.openai.model2.CreateChatCompletionStreamResponseChoicesInner; +import com.sap.ai.sdk.foundationmodels.openai.model2.EmbeddingsCreateRequest; +import com.sap.ai.sdk.foundationmodels.openai.model2.EmbeddingsCreateRequestInput; import com.sap.cloud.sdk.cloudplatform.connectivity.ApacheHttpClient5Accessor; import com.sap.cloud.sdk.cloudplatform.connectivity.ApacheHttpClient5Cache; import com.sap.cloud.sdk.cloudplatform.connectivity.DefaultHttpDestination; import io.vavr.control.Try; import java.io.IOException; import java.io.InputStream; +import java.math.BigDecimal; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.concurrent.Callable; import java.util.function.Function; @@ -51,6 +65,7 @@ @WireMockTest class OpenAiClientTest { + private static final ObjectMapper MAPPER = new ObjectMapper(); private static OpenAiClient client; private final Function fileLoader = filename -> Objects.requireNonNull(getClass().getClassLoader().getResourceAsStream(filename)); @@ -72,21 +87,20 @@ void reset() { @Test void apiVersion() { stubFor(post(anyUrl()).willReturn(okJson("{}"))); - Try.of(() -> client.chatCompletion(new OpenAiChatCompletionParameters())); + Try.of(() -> client.chatCompletion(new CreateChatCompletionRequest())); verify( exactly(1), postRequestedFor(anyUrl()).withQueryParam("api-version", equalTo("2024-02-01"))); - Try.of( - () -> client.withApiVersion("fooBar").chatCompletion(new OpenAiChatCompletionParameters())); + Try.of(() -> client.withApiVersion("fooBar").chatCompletion(new CreateChatCompletionRequest())); verify(exactly(1), postRequestedFor(anyUrl()).withQueryParam("api-version", equalTo("fooBar"))); assertThat(client) .describedAs( "withApiVersion should return a new object, the sut object should remain unchanged") .isNotSameAs(client.withApiVersion("fooBar")); - Try.of(() -> client.chatCompletion(new OpenAiChatCompletionParameters())); + Try.of(() -> client.chatCompletion(new CreateChatCompletionRequest())); verify( exactly(2), postRequestedFor(anyUrl()).withQueryParam("api-version", equalTo("2024-02-01"))); @@ -94,10 +108,10 @@ void apiVersion() { private static Runnable[] errorHandlingCalls() { return new Runnable[] { - () -> client.chatCompletion(new OpenAiChatCompletionParameters()), + () -> client.chatCompletion(new CreateChatCompletionRequest()), () -> client - .streamChatCompletionDeltas(new OpenAiChatCompletionParameters()) + .streamChatCompletionDeltas(new CreateChatCompletionRequest()) // the stream needs to be consumed to parse the response .forEach(System.out::println) }; @@ -180,11 +194,23 @@ void chatCompletionErrorHandling(@Nonnull final Runnable request) { private static Callable[] chatCompletionCalls() { return new Callable[] { () -> { - final var systemMessage = new OpenAiChatSystemMessage().setContent("You are a helpful AI"); + final var systemMessage = + new ChatCompletionRequestSystemMessage() + .role(ChatCompletionRequestSystemMessage.RoleEnum.SYSTEM) + .content(ChatCompletionRequestSystemMessageContent.create("You are a helpful AI")); final var userMessage = - new OpenAiChatUserMessage().addText("Hello World! Why is this phrase so famous?"); + new ChatCompletionRequestUserMessage() + .role(ChatCompletionRequestUserMessage.RoleEnum.USER) + .content( + ChatCompletionRequestUserMessageContent.create( + "Hello World! Why is this phrase so famous?")); final var request = - new OpenAiChatCompletionParameters().addMessages(systemMessage, userMessage); + new CreateChatCompletionRequest() + .addMessagesItem(systemMessage) + .addMessagesItem(userMessage) + .functions(null) + .tools(null) + .parallelToolCalls(null); return client.chatCompletion(request); }, () -> @@ -197,7 +223,7 @@ private static Callable[] chatCompletionCalls() { @SneakyThrows @ParameterizedTest @MethodSource("chatCompletionCalls") - void chatCompletion(@Nonnull final Callable request) { + void chatCompletion(@Nonnull final Callable request) { try (var inputStream = fileLoader.apply("__files/chatCompletionResponse.json")) { final String response = new String(inputStream.readAllBytes()); @@ -207,13 +233,13 @@ void chatCompletion(@Nonnull final Callable request) .withQueryParam("api-version", equalTo("2024-02-01")) .willReturn(okJson(response))); - final OpenAiChatCompletionOutput result = request.call(); + final CreateChatCompletionResponse result = request.call(); assertThat(result).isNotNull(); assertThat(result.getCreated()).isEqualTo(1727436279); assertThat(result.getId()).isEqualTo("chatcmpl-AC3NPPYlxem8kRBBAX9EBObMMsrnf"); assertThat(result.getModel()).isEqualTo("gpt-35-turbo"); - assertThat(result.getObject()).isEqualTo("chat.completion"); + assertThat(result.getObject().getValue()).isEqualTo("chat.completion"); assertThat(result.getSystemFingerprint()).isEqualTo("fp_e49e4201a9"); assertThat(result.getUsage()).isNotNull(); @@ -223,7 +249,7 @@ void chatCompletion(@Nonnull final Callable request) assertThat(result.getPromptFilterResults()).hasSize(1); assertThat(result.getPromptFilterResults().get(0).getPromptIndex()).isEqualTo(0); - OpenAiContentFilterPromptResults promptFilterResults = + ContentFilterPromptResults promptFilterResults = result.getPromptFilterResults().get(0).getContentFilterResults(); assertThat(promptFilterResults).isNotNull(); assertThat(promptFilterResults.getSexual()).isNotNull(); @@ -243,16 +269,16 @@ void chatCompletion(@Nonnull final Callable request) assertThat(promptFilterResults.getJailbreak()).isNull(); assertThat(result.getChoices()).hasSize(1); - OpenAiChatCompletionChoice choice = result.getChoices().get(0); - assertThat(choice.getFinishReason()).isEqualTo("stop"); + CreateChatCompletionResponseChoicesInner choice = result.getChoices().get(0); + assertThat(choice.getFinishReason()).isEqualTo(STOP); assertThat(choice.getIndex()).isEqualTo(0); assertThat(choice.getMessage().getContent()) .isEqualTo( "I'm an AI and cannot answer that question as beauty is subjective and varies from person to person."); - assertThat(choice.getMessage().getRole()).isEqualTo("assistant"); + assertThat(choice.getMessage().getRole()).isEqualTo(ASSISTANT); assertThat(choice.getMessage().getToolCalls()).isNull(); - OpenAiContentFilterPromptResults contentFilterResults = choice.getContentFilterResults(); + ContentFilterChoiceResults contentFilterResults = choice.getContentFilterResults(); assertThat(contentFilterResults).isNotNull(); assertThat(contentFilterResults.getSexual()).isNotNull(); assertThat(contentFilterResults.getSexual().isFiltered()).isFalse(); @@ -268,7 +294,7 @@ void chatCompletion(@Nonnull final Callable request) assertThat(contentFilterResults.getSelfHarm().isFiltered()).isFalse(); assertThat(contentFilterResults.getProfanity()).isNull(); assertThat(contentFilterResults.getError()).isNull(); - assertThat(contentFilterResults.getJailbreak()).isNull(); + // assertThat(contentFilterResults.getJailbreak()).isNull(); verify( postRequestedFor(urlPathEqualTo("/chat/completions")) @@ -277,16 +303,20 @@ void chatCompletion(@Nonnull final Callable request) equalToJson( """ { - "messages" : [ { - "role" : "system", - "content" : "You are a helpful AI" - }, { - "role" : "user", - "content" : [ { - "type" : "text", - "text" : "Hello World! Why is this phrase so famous?" - } ] - } ] + "temperature" : 1, + "top_p" : 1, + "stream" : false, + "presence_penalty" : 0, + "frequency_penalty" : 0, + "messages" : [ { + "content" : "You are a helpful AI", + "role" : "system" + }, { + "content" : "Hello World! Why is this phrase so famous?", + "role" : "user" + } ], + "logprobs" : false, + "n" : 1 }"""))); } } @@ -310,16 +340,20 @@ void history() { equalToJson( """ { - "messages" : [ { - "role" : "system", - "content" : "system prompt" - }, { - "role" : "user", - "content" : [ { - "type" : "text", - "text" : "chat completion 1" - } ] - } ] + "temperature" : 1, + "top_p" : 1, + "stream" : false, + "presence_penalty" : 0, + "frequency_penalty" : 0, + "messages" : [ { + "content" : "system prompt", + "role" : "system" + }, { + "content" : "chat completion 1", + "role" : "user" + } ], + "logprobs" : false, + "n" : 1 }"""))); client.withSystemPrompt("system prompt").chatCompletion("chat completion 2"); @@ -331,16 +365,20 @@ void history() { equalToJson( """ { - "messages" : [ { - "role" : "system", - "content" : "system prompt" - }, { - "role" : "user", - "content" : [ { - "type" : "text", - "text" : "chat completion 2" - } ] - } ] + "temperature" : 1, + "top_p" : 1, + "stream" : false, + "presence_penalty" : 0, + "frequency_penalty" : 0, + "messages" : [ { + "content" : "system prompt", + "role" : "system" + }, { + "content" : "chat completion 2", + "role" : "user" + } ], + "logprobs" : false, + "n" : 1 }"""))); } @@ -353,7 +391,8 @@ void embedding() { .withBodyFile("embeddingResponse.json") .withHeader("Content-Type", "application/json"))); - final var request = new OpenAiEmbeddingParameters().setInput("Hello World"); + final var request = + new EmbeddingsCreateRequest().input(EmbeddingsCreateRequestInput.create("Hello World")); final var result = client.embedding(request); assertThat(result).isNotNull(); @@ -361,7 +400,7 @@ void embedding() { assertThat(result.getObject()).isEqualTo("list"); assertThat(result.getUsage()).isNotNull(); - assertThat(result.getUsage().getCompletionTokens()).isNull(); + assertThat(result.getUsage().getCustomFieldNames()).doesNotContain("completion_tokens"); assertThat(result.getUsage().getPromptTokens()).isEqualTo(2); assertThat(result.getUsage().getTotalTokens()).isEqualTo(2); @@ -373,14 +412,19 @@ void embedding() { assertThat(embeddingData.getEmbedding()) .isNotNull() .isNotEmpty() - .isEqualTo(new float[] {0.0f, 3.4028235E38f, 1.4E-45f, 1.23f, -4.56f}); + .containsExactly( + new BigDecimal("0.0"), + new BigDecimal("3.4028235E+38"), + new BigDecimal("1.4E-45"), + new BigDecimal("1.23"), + new BigDecimal("-4.56")); verify( postRequestedFor(urlPathEqualTo("/embeddings")) .withRequestBody( equalToJson( """ - {"input":["Hello World"]}"""))); + {"input": "Hello World" }"""))); } @Test @@ -388,7 +432,8 @@ void testThrowsOnContentFilter() { var mock = mock(OpenAiClient.class); when(mock.streamChatCompletion(any())).thenCallRealMethod(); - var deltaWithContentFilter = mock(OpenAiChatCompletionDelta.class); + var deltaWithContentFilter = + mock(com.sap.ai.sdk.foundationmodels.openai.OpenAiChatCompletionDelta.class); when(deltaWithContentFilter.getFinishReason()).thenReturn("content_filter"); when(mock.streamChatCompletionDeltas(any())).thenReturn(Stream.of(deltaWithContentFilter)); @@ -415,11 +460,13 @@ void streamChatCompletionDeltasErrorHandling() throws IOException { // Configure the HttpClient mock to return the mock response doReturn(mockResponse).when(httpClient).executeOpen(any(), any(), any()); - final var request = - new OpenAiChatCompletionParameters() - .addMessages( - new OpenAiChatUserMessage() - .addText("Can you give me the first 100 numbers of the Fibonacci sequence?")); + final var userMessage = + new ChatCompletionRequestUserMessage() + .role(ChatCompletionRequestUserMessage.RoleEnum.USER) + .content( + ChatCompletionRequestUserMessageContent.create( + "Can you give me the first 100 numbers of the Fibonacci sequence?")); + final var request = new CreateChatCompletionRequest().addMessagesItem(userMessage); try (Stream stream = client.streamChatCompletionDeltas(request)) { assertThatThrownBy(() -> stream.forEach(System.out::println)) @@ -447,17 +494,26 @@ void streamChatCompletionDeltas() throws IOException { // Configure the HttpClient mock to return the mock response doReturn(mockResponse).when(httpClient).executeOpen(any(), any(), any()); - final var request = - new OpenAiChatCompletionParameters() - .addMessages( - new OpenAiChatUserMessage() - .addText("Can you give me the first 100 numbers of the Fibonacci sequence?")); + final var userMessage = + new ChatCompletionRequestUserMessage() + .role(ChatCompletionRequestUserMessage.RoleEnum.USER) + .content( + ChatCompletionRequestUserMessageContent.create( + "Can you give me the first 100 numbers of the Fibonacci sequence?")); + final var request = new CreateChatCompletionRequest().addMessagesItem(userMessage); try (Stream stream = client.streamChatCompletionDeltas(request)) { - OpenAiChatCompletionOutput totalOutput = new OpenAiChatCompletionOutput(); - final List deltaList = - stream.peek(totalOutput::addDelta).toList(); + final List deltaList = stream.toList(); + final var delta0 = (CreateChatCompletionResponse) deltaList.get(0).getOriginalResponse(); + final var delta1 = + (CreateChatCompletionStreamResponse) deltaList.get(1).getOriginalResponse(); + final var delta2 = + (CreateChatCompletionStreamResponse) deltaList.get(2).getOriginalResponse(); + final var delta3 = + (CreateChatCompletionStreamResponse) deltaList.get(3).getOriginalResponse(); + final var delta4 = + (CreateChatCompletionStreamResponse) deltaList.get(4).getOriginalResponse(); assertThat(deltaList).hasSize(5); // the first two and the last delta don't have any content @@ -467,33 +523,29 @@ void streamChatCompletionDeltas() throws IOException { assertThat(deltaList.get(3).getDeltaContent()).isEqualTo("!"); assertThat(deltaList.get(4).getDeltaContent()).isEqualTo(""); - assertThat(deltaList.get(0).getSystemFingerprint()).isNull(); - assertThat(deltaList.get(1).getSystemFingerprint()).isEqualTo("fp_e49e4201a9"); - assertThat(deltaList.get(2).getSystemFingerprint()).isEqualTo("fp_e49e4201a9"); - assertThat(deltaList.get(3).getSystemFingerprint()).isEqualTo("fp_e49e4201a9"); - assertThat(deltaList.get(4).getSystemFingerprint()).isEqualTo("fp_e49e4201a9"); - - assertThat(deltaList.get(0).getUsage()).isNull(); - assertThat(deltaList.get(1).getUsage()).isNull(); - assertThat(deltaList.get(2).getUsage()).isNull(); - assertThat(deltaList.get(3).getUsage()).isNull(); - final var usage = deltaList.get(4).getUsage(); - assertThat(usage).isNotNull(); - assertThat(usage.getCompletionTokens()).isEqualTo(607); - assertThat(usage.getPromptTokens()).isEqualTo(21); - assertThat(usage.getTotalTokens()).isEqualTo(628); - - assertThat(deltaList.get(0).getChoices()).isEmpty(); - assertThat(deltaList.get(1).getChoices()).hasSize(1); - assertThat(deltaList.get(2).getChoices()).hasSize(1); - assertThat(deltaList.get(3).getChoices()).hasSize(1); - assertThat(deltaList.get(4).getChoices()).hasSize(1); - - final var delta0 = deltaList.get(0); + assertThat(delta0.getSystemFingerprint()).isNull(); + assertThat(delta1.getSystemFingerprint()).isEqualTo("fp_e49e4201a9"); + assertThat(delta2.getSystemFingerprint()).isEqualTo("fp_e49e4201a9"); + assertThat(delta3.getSystemFingerprint()).isEqualTo("fp_e49e4201a9"); + assertThat(delta4.getSystemFingerprint()).isEqualTo("fp_e49e4201a9"); + + assertThat(delta0.getUsage()).isNull(); + assertThat(delta1.getCustomField("usage")).isNull(); + assertThat(delta2.getCustomField("usage")).isNull(); + assertThat(delta3.getCustomField("usage")).isNull(); + final Map delta4UsageRaw = (Map) delta4.getCustomField("usage"); + final var delta4Usage = MAPPER.convertValue(delta4UsageRaw, CompletionUsage.class); + assertThat(delta4Usage).isNotNull(); + assertThat(delta4Usage.getCompletionTokens()).isEqualTo(607); + assertThat(delta4Usage.getPromptTokens()).isEqualTo(21); + assertThat(delta4Usage.getTotalTokens()).isEqualTo(628); + + // delta 0 + assertThat(delta0.getId()).isEqualTo(""); assertThat(delta0.getCreated()).isEqualTo(0); assertThat(delta0.getModel()).isEqualTo(""); - assertThat(delta0.getObject()).isEqualTo(""); + assertThat(delta0.getObject()).isEqualTo(UNKNOWN_DEFAULT_OPEN_API); assertThat(delta0.getUsage()).isNull(); assertThat(delta0.getChoices()).isEmpty(); // prompt filter results are only present in delta 0 @@ -503,62 +555,69 @@ void streamChatCompletionDeltas() throws IOException { assertThat(promptFilter0).isNotNull(); assertFilter(promptFilter0); - final var delta2 = deltaList.get(2); + // delta 1 + assertThat(delta1.getChoices()).hasSize(1); + + // delta 2 assertThat(delta2.getId()).isEqualTo("chatcmpl-A16EvnkgEm6AdxY0NoOmGPjsJucQ1"); assertThat(delta2.getCreated()).isEqualTo(1724825677); assertThat(delta2.getModel()).isEqualTo("gpt-35-turbo"); - assertThat(delta2.getObject()).isEqualTo("chat.completion.chunk"); - assertThat(delta2.getUsage()).isNull(); - assertThat(delta2.getPromptFilterResults()).isNull(); + assertThat(delta2.getObject()).isEqualTo(CHAT_COMPLETION_CHUNK); + assertThat(delta2.getCustomField("usage")).isNull(); + assertThat(delta2.getCustomFieldNames()).doesNotContain("prompt_filter_results"); + assertThat(delta2.getChoices()).hasSize(1); final var choices2 = delta2.getChoices().get(0); assertThat(choices2.getIndex()).isEqualTo(0); assertThat(choices2.getFinishReason()).isNull(); - assertThat(choices2.getMessage()).isNotNull(); - // the role is only defined in delta 1, but it defaults to "assistant" for all deltas - assertThat(choices2.getMessage().getRole()).isEqualTo("assistant"); - assertThat(choices2.getMessage().getContent()).isEqualTo("Sure"); - assertThat(choices2.getMessage().getToolCalls()).isNull(); - final var filter2 = choices2.getContentFilterResults(); + assertThat(choices2.getDelta()).isNotNull(); + // the role is only defined in delta 1 + assertThat(choices2.getDelta().getRole()).isNull(); + assertThat(choices2.getDelta().getContent()).isEqualTo("Sure"); + assertThat(choices2.getDelta().getToolCalls()).isNotNull().isEmpty(); + final Map filter2raw = (Map) choices2.getCustomField("content_filter_results"); + final var filter2 = MAPPER.convertValue(filter2raw, ContentFilterPromptResults.class); assertFilter(filter2); - final var delta3 = deltaList.get(3); - assertThat(delta3.getDeltaContent()).isEqualTo("!"); - - final var delta4Choice = deltaList.get(4).getChoices().get(0); - assertThat(delta4Choice.getFinishReason()).isEqualTo("stop"); - assertThat(delta4Choice.getMessage()).isNotNull(); - // the role is only defined in delta 1, but it defaults to "assistant" for all deltas - assertThat(delta4Choice.getMessage().getRole()).isEqualTo("assistant"); - assertThat(delta4Choice.getMessage().getContent()).isNull(); - assertThat(delta4Choice.getMessage().getToolCalls()).isNull(); - assertThat(totalOutput.getChoices()).hasSize(1); - final var choice = totalOutput.getChoices().get(0); - assertThat(choice.getFinishReason()).isEqualTo("stop"); - assertFilter(choice.getContentFilterResults()); - assertThat(choice.getFinishReason()).isEqualTo("stop"); - assertThat(choice.getMessage()).isNotNull(); - assertThat(choice.getMessage().getRole()).isEqualTo("assistant"); - assertThat(choice.getMessage().getContent()).isEqualTo("Sure!"); - assertThat(choice.getMessage().getToolCalls()).isNull(); - assertThat(totalOutput.getId()).isEqualTo("chatcmpl-A16EvnkgEm6AdxY0NoOmGPjsJucQ1"); - assertThat(totalOutput.getCreated()).isEqualTo(1724825677); - assertThat(totalOutput.getModel()).isEqualTo("gpt-35-turbo"); - assertThat(totalOutput.getObject()).isEqualTo("chat.completion.chunk"); - final var totalUsage = totalOutput.getUsage(); - assertThat(totalUsage).isNotNull(); - assertThat(totalUsage.getCompletionTokens()).isEqualTo(607); - assertThat(totalUsage.getPromptTokens()).isEqualTo(21); - assertThat(totalUsage.getTotalTokens()).isEqualTo(628); - assertThat(totalOutput.getSystemFingerprint()).isEqualTo("fp_e49e4201a9"); - assertThat(totalOutput.getPromptFilterResults()).isNotNull(); - assertFilter(totalOutput.getPromptFilterResults().get(0).getContentFilterResults()); + // delta 3 + + assertThat(delta3.getChoices()).hasSize(1); + assertThat(deltaList.get(3).getDeltaContent()).isEqualTo("!"); + + // delta 4 + + assertThat(delta4.getChoices()).hasSize(1); + final var delta4Choice = delta4.getChoices().get(0); + assertThat(delta4Choice.getFinishReason()) + .isEqualTo(CreateChatCompletionStreamResponseChoicesInner.FinishReasonEnum.STOP); + assertThat(delta4Choice.getDelta().getContent()).isNull(); + // the role is only defined in delta 1 + assertThat(delta4Choice.getDelta().getRole()).isNull(); + assertThat(delta4Choice.getDelta().getContent()).isNull(); + assertThat(delta4Choice.getDelta().getToolCalls()).isEmpty(); + assertThat(delta4.getChoices()).hasSize(1); + final var choice = delta4.getChoices().get(0); + assertThat(choice.getFinishReason()) + .isEqualTo(CreateChatCompletionStreamResponseChoicesInner.FinishReasonEnum.STOP); + final Map filterRaw = (Map) choice.getCustomField("content_filter_results"); + assertThat(filterRaw).isEmpty(); + assertThat(choice.getDelta()).isNotNull(); + assertThat(choice.getDelta().getRole()).isNull(); + assertThat(choice.getDelta().getContent()).isNull(); + assertThat(choice.getDelta().getToolCalls()).isNotNull().isEmpty(); + assertThat(delta4.getId()).isEqualTo("chatcmpl-A16EvnkgEm6AdxY0NoOmGPjsJucQ1"); + assertThat(delta4.getCreated()).isEqualTo(1724825677); + assertThat(delta4.getModel()).isEqualTo("gpt-35-turbo"); + assertThat(delta4.getObject()).isEqualTo(CHAT_COMPLETION_CHUNK); + assertThat(choice.getCustomField("content_filter_results")).asInstanceOf(MAP).isEmpty(); + assertThat(delta4.getSystemFingerprint()).isEqualTo("fp_e49e4201a9"); + assertThat(delta4.getCustomFieldNames()).doesNotContain("prompt_filter_results"); } Mockito.verify(inputStream, times(1)).close(); } } - void assertFilter(OpenAiContentFilterPromptResults filter) { + void assertFilter(ContentFilterPromptResults filter) { assertThat(filter).isNotNull(); assertThat(filter.getHate()).isNotNull(); assertThat(filter.getHate().isFiltered()).isFalse(); diff --git a/pom.xml b/pom.xml index 090aeb7f1..fa658b0be 100644 --- a/pom.xml +++ b/pom.xml @@ -473,6 +473,7 @@ https://gitbox.apache.org/repos/asf?p=maven-pmd-plugin.git;a=blob_plain;f=src/ma com/sap/ai/sdk/core/client/* com/sap/ai/sdk/core/model/* + com/sap/ai/sdk/foundationmodels/openai/model2/* com/sap/ai/sdk/orchestration/model/* @@ -516,6 +517,7 @@ https://gitbox.apache.org/repos/asf?p=maven-pmd-plugin.git;a=blob_plain;f=src/ma com/sap/ai/sdk/core/client/* com/sap/ai/sdk/core/model/* com/sap/ai/sdk/orchestration/model/* + com/sap/ai/sdk/foundationmodels/openai/model2/* com/sap/ai/sdk/app/**/* diff --git a/sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/controllers/OpenAiController.java b/sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/controllers/OpenAiController.java index 24b451d52..ea7a8032c 100644 --- a/sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/controllers/OpenAiController.java +++ b/sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/controllers/OpenAiController.java @@ -5,10 +5,11 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.sap.ai.sdk.app.services.OpenAiService; -import com.sap.ai.sdk.foundationmodels.openai.model.OpenAiChatCompletionOutput; +import com.sap.ai.sdk.foundationmodels.openai.model2.CompletionUsage; import com.sap.cloud.sdk.cloudplatform.thread.ThreadContextExecutors; import java.io.IOException; import java.util.Arrays; +import java.util.concurrent.atomic.AtomicReference; import javax.annotation.Nonnull; import javax.annotation.Nullable; import lombok.extern.slf4j.Slf4j; @@ -44,7 +45,7 @@ ResponseEntity chatCompletion( if ("application/json".equals(accept)) { return ResponseEntity.ok().body(MAPPER.writeValueAsString(response)); } - return ResponseEntity.ok(response.getContent()); + return ResponseEntity.ok(response.getChoices().get(0).getMessage().getContent()); } /** @@ -61,14 +62,17 @@ ResponseEntity streamChatCompletionDeltas() { final var emitter = new ResponseBodyEmitter(); final Runnable consumeStream = () -> { - final var totalOutput = new OpenAiChatCompletionOutput(); + final var totalOutput = new AtomicReference(); // try-with-resources ensures the stream is closed try (stream) { - stream - .peek(totalOutput::addDelta) - .forEach(delta -> send(emitter, delta.getDeltaContent())); + stream.forEach( + delta -> { + final var usage = delta.getCompletionUsage(mapper); + totalOutput.compareAndExchange(null, usage); + send(emitter, delta.getDeltaContent()); + }); } finally { - send(emitter, "\n\n-----Total Output-----\n\n" + objectToJson(totalOutput)); + send(emitter, "\n\n-----Total Output-----\n\n" + totalOutput); emitter.complete(); } }; @@ -120,20 +124,6 @@ public static void send(@Nonnull final ResponseBodyEmitter emitter, @Nonnull fin } } - /** - * Convert an object to JSON - * - * @param obj The object to convert - * @return The JSON representation of the object - */ - private static String objectToJson(@Nonnull final Object obj) { - try { - return new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(obj); - } catch (final JsonProcessingException ignored) { - return "Could not parse object to JSON"; - } - } - /** * Chat request to OpenAI with an image * @@ -150,7 +140,7 @@ ResponseEntity chatCompletionImage( if ("application/json".equals(accept)) { return ResponseEntity.ok().body(MAPPER.writeValueAsString(response)); } - return ResponseEntity.ok(response.getContent()); + return ResponseEntity.ok(response.getChoices().get(0).getMessage().getContent()); } /** @@ -168,7 +158,7 @@ ResponseEntity chatCompletionTools( if ("application/json".equals(accept)) { return ResponseEntity.ok().body(MAPPER.writeValueAsString(response)); } - return ResponseEntity.ok(response.getContent()); + return ResponseEntity.ok(response.getChoices().get(0).getMessage().getContent()); } /** @@ -200,6 +190,6 @@ ResponseEntity chatCompletionWithResource( if ("application/json".equals(accept)) { return ResponseEntity.ok().body(MAPPER.writeValueAsString(response)); } - return ResponseEntity.ok(response.getContent()); + return ResponseEntity.ok(response.getChoices().get(0).getMessage().getContent()); } } diff --git a/sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/services/OpenAiService.java b/sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/services/OpenAiService.java index 5d5f26209..f299147ad 100644 --- a/sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/services/OpenAiService.java +++ b/sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/services/OpenAiService.java @@ -3,18 +3,30 @@ import static com.sap.ai.sdk.foundationmodels.openai.OpenAiModel.GPT_35_TURBO; import static com.sap.ai.sdk.foundationmodels.openai.OpenAiModel.GPT_4O; import static com.sap.ai.sdk.foundationmodels.openai.OpenAiModel.TEXT_EMBEDDING_ADA_002; -import static com.sap.ai.sdk.foundationmodels.openai.model.OpenAiChatCompletionTool.ToolType.FUNCTION; +import static com.sap.ai.sdk.foundationmodels.openai.model2.ChatCompletionRequestMessageContentPartImage.TypeEnum.IMAGE_URL; +import static com.sap.ai.sdk.foundationmodels.openai.model2.ChatCompletionRequestMessageContentPartImageImageUrl.DetailEnum.HIGH; +import static com.sap.ai.sdk.foundationmodels.openai.model2.ChatCompletionRequestMessageContentPartText.TypeEnum.TEXT; +import static com.sap.ai.sdk.foundationmodels.openai.model2.ChatCompletionRequestUserMessage.RoleEnum.USER; import com.sap.ai.sdk.core.AiCoreService; +import com.sap.ai.sdk.foundationmodels.openai.OpenAiChatCompletionDelta; import com.sap.ai.sdk.foundationmodels.openai.OpenAiClient; -import com.sap.ai.sdk.foundationmodels.openai.model.OpenAiChatCompletionDelta; -import com.sap.ai.sdk.foundationmodels.openai.model.OpenAiChatCompletionFunction; -import com.sap.ai.sdk.foundationmodels.openai.model.OpenAiChatCompletionOutput; -import com.sap.ai.sdk.foundationmodels.openai.model.OpenAiChatCompletionParameters; -import com.sap.ai.sdk.foundationmodels.openai.model.OpenAiChatCompletionTool; -import com.sap.ai.sdk.foundationmodels.openai.model.OpenAiChatMessage; -import com.sap.ai.sdk.foundationmodels.openai.model.OpenAiEmbeddingOutput; -import com.sap.ai.sdk.foundationmodels.openai.model.OpenAiEmbeddingParameters; +import com.sap.ai.sdk.foundationmodels.openai.model2.ChatCompletionNamedToolChoice; +import com.sap.ai.sdk.foundationmodels.openai.model2.ChatCompletionNamedToolChoiceFunction; +import com.sap.ai.sdk.foundationmodels.openai.model2.ChatCompletionRequestMessageContentPartImage; +import com.sap.ai.sdk.foundationmodels.openai.model2.ChatCompletionRequestMessageContentPartImageImageUrl; +import com.sap.ai.sdk.foundationmodels.openai.model2.ChatCompletionRequestMessageContentPartText; +import com.sap.ai.sdk.foundationmodels.openai.model2.ChatCompletionRequestUserMessage; +import com.sap.ai.sdk.foundationmodels.openai.model2.ChatCompletionRequestUserMessageContent; +import com.sap.ai.sdk.foundationmodels.openai.model2.ChatCompletionTool; +import com.sap.ai.sdk.foundationmodels.openai.model2.ChatCompletionToolChoiceOption; +import com.sap.ai.sdk.foundationmodels.openai.model2.CreateChatCompletionRequest; +import com.sap.ai.sdk.foundationmodels.openai.model2.CreateChatCompletionResponse; +import com.sap.ai.sdk.foundationmodels.openai.model2.EmbeddingsCreate200Response; +import com.sap.ai.sdk.foundationmodels.openai.model2.EmbeddingsCreateRequest; +import com.sap.ai.sdk.foundationmodels.openai.model2.EmbeddingsCreateRequestInput; +import com.sap.ai.sdk.foundationmodels.openai.model2.FunctionObject; +import java.net.URI; import java.util.List; import java.util.Map; import java.util.stream.Stream; @@ -34,7 +46,7 @@ public class OpenAiService { * @return the assistant message response */ @Nonnull - public OpenAiChatCompletionOutput chatCompletion(@Nonnull final String prompt) { + public CreateChatCompletionResponse chatCompletion(@Nonnull final String prompt) { return OpenAiClient.forModel(GPT_35_TURBO).chatCompletion(prompt); } @@ -46,9 +58,12 @@ public OpenAiChatCompletionOutput chatCompletion(@Nonnull final String prompt) { @Nonnull public Stream streamChatCompletionDeltas( @Nonnull final String message) { + final var userMessage = + new ChatCompletionRequestUserMessage() + .role(USER) + .content(ChatCompletionRequestUserMessageContent.create(message)); final var request = - new OpenAiChatCompletionParameters() - .addMessages(new OpenAiChatMessage.OpenAiChatUserMessage().addText(message)); + new CreateChatCompletionRequest().addMessagesItem(userMessage).functions(null).tools(null); return OpenAiClient.forModel(GPT_35_TURBO).streamChatCompletionDeltas(request); } @@ -72,15 +87,27 @@ public Stream streamChatCompletion(@Nonnull final String message) { * @return the assistant message response */ @Nonnull - public OpenAiChatCompletionOutput chatCompletionImage(@Nonnull final String linkToImage) { + public CreateChatCompletionResponse chatCompletionImage(@Nonnull final String linkToImage) { + final var partText = + new ChatCompletionRequestMessageContentPartText() + .type(TEXT) + .text("Describe the following image."); + final var partImageUrl = + new ChatCompletionRequestMessageContentPartImageImageUrl() + .url(URI.create(linkToImage)) + .detail(HIGH); + final var partImage = + new ChatCompletionRequestMessageContentPartImage().type(IMAGE_URL).imageUrl(partImageUrl); + final var userMessage = + new ChatCompletionRequestUserMessage() + .role(USER) + .content(ChatCompletionRequestUserMessageContent.create(List.of(partText, partImage))); final var request = - new OpenAiChatCompletionParameters() - .addMessages( - new OpenAiChatMessage.OpenAiChatUserMessage() - .addText("Describe the following image.") - .addImage( - linkToImage, - OpenAiChatMessage.OpenAiChatUserMessage.ImageDetailLevel.HIGH)); + new CreateChatCompletionRequest() + .addMessagesItem(userMessage) + .functions(null) + .tools(null) + .parallelToolCalls(null); return OpenAiClient.forModel(GPT_4O).chatCompletion(request); } @@ -92,21 +119,29 @@ public OpenAiChatCompletionOutput chatCompletionImage(@Nonnull final String link * @return the assistant message response */ @Nonnull - public OpenAiChatCompletionOutput chatCompletionTools(@Nonnull final String prompt) { + public CreateChatCompletionResponse chatCompletionTools(@Nonnull final String prompt) { final var question = "A pair of rabbits is placed in a field. Each month, every pair produces one new pair, starting from the second month. How many rabbits will there be after 12 months?"; final var par = Map.of("type", "object", "properties", Map.of("N", Map.of("type", "integer"))); - final var function = - new OpenAiChatCompletionFunction() - .setName("fibonacci") - .setDescription(prompt) - .setParameters(par); - final var tool = new OpenAiChatCompletionTool().setType(FUNCTION).setFunction(function); + final var function = new FunctionObject().name("fibonacci").description(prompt).parameters(par); + final var tool = + new ChatCompletionTool().type(ChatCompletionTool.TypeEnum.FUNCTION).function(function); + final var userMessage = + new ChatCompletionRequestUserMessage() + .role(USER) + .content(ChatCompletionRequestUserMessageContent.create(question)); + final var toolChoice = + ChatCompletionToolChoiceOption.create( + new ChatCompletionNamedToolChoice() + .type(ChatCompletionNamedToolChoice.TypeEnum.FUNCTION) + .function(new ChatCompletionNamedToolChoiceFunction().name("fibonacci"))); final var request = - new OpenAiChatCompletionParameters() - .addMessages(new OpenAiChatMessage.OpenAiChatUserMessage().addText(question)) - .setTools(List.of(tool)) - .setToolChoiceFunction("fibonacci"); + new CreateChatCompletionRequest() + .addMessagesItem(userMessage) + .tools(List.of(tool)) + .toolChoice(toolChoice) + .functions(null) + .parallelToolCalls(null); return OpenAiClient.forModel(GPT_35_TURBO).chatCompletion(request); } @@ -118,8 +153,9 @@ public OpenAiChatCompletionOutput chatCompletionTools(@Nonnull final String prom * @return the embedding response */ @Nonnull - public OpenAiEmbeddingOutput embedding(@Nonnull final String input) { - final var request = new OpenAiEmbeddingParameters().setInput(input); + public EmbeddingsCreate200Response embedding(@Nonnull final String input) { + final var request = + new EmbeddingsCreateRequest().input(EmbeddingsCreateRequestInput.create(input)); return OpenAiClient.forModel(TEXT_EMBEDDING_ADA_002).embedding(request); } @@ -132,7 +168,7 @@ public OpenAiEmbeddingOutput embedding(@Nonnull final String input) { * @return the assistant message response */ @Nonnull - public OpenAiChatCompletionOutput chatCompletionWithResource( + public CreateChatCompletionResponse chatCompletionWithResource( @Nonnull final String resourceGroup, @Nonnull final String prompt) { final var destination = diff --git a/sample-code/spring-app/src/test/java/com/sap/ai/sdk/app/controllers/OpenAiTest.java b/sample-code/spring-app/src/test/java/com/sap/ai/sdk/app/controllers/OpenAiTest.java index ec07fb037..766227e89 100644 --- a/sample-code/spring-app/src/test/java/com/sap/ai/sdk/app/controllers/OpenAiTest.java +++ b/sample-code/spring-app/src/test/java/com/sap/ai/sdk/app/controllers/OpenAiTest.java @@ -1,14 +1,18 @@ package com.sap.ai.sdk.app.controllers; import static com.sap.ai.sdk.foundationmodels.openai.OpenAiModel.GPT_35_TURBO; +import static com.sap.ai.sdk.foundationmodels.openai.model2.ChatCompletionResponseMessageRole.ASSISTANT; import static org.assertj.core.api.Assertions.assertThat; +import com.fasterxml.jackson.databind.ObjectMapper; import com.sap.ai.sdk.app.services.OpenAiService; import com.sap.ai.sdk.foundationmodels.openai.OpenAiClient; -import com.sap.ai.sdk.foundationmodels.openai.model.OpenAiChatCompletionOutput; -import com.sap.ai.sdk.foundationmodels.openai.model.OpenAiChatCompletionParameters; -import com.sap.ai.sdk.foundationmodels.openai.model.OpenAiChatMessage.OpenAiChatUserMessage; +import com.sap.ai.sdk.foundationmodels.openai.model2.ChatCompletionRequestUserMessage; +import com.sap.ai.sdk.foundationmodels.openai.model2.ChatCompletionRequestUserMessageContent; +import com.sap.ai.sdk.foundationmodels.openai.model2.CompletionUsage; +import com.sap.ai.sdk.foundationmodels.openai.model2.CreateChatCompletionRequest; import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -27,7 +31,7 @@ void chatCompletion() { final var completion = service.chatCompletion("Who is the prettiest"); final var message = completion.getChoices().get(0).getMessage(); - assertThat(message.getRole()).isEqualTo("assistant"); + assertThat(message.getRole()).isEqualTo(ASSISTANT); assertThat(message.getContent()).isNotEmpty(); } @@ -38,24 +42,32 @@ void chatCompletionImage() { "https://upload.wikimedia.org/wikipedia/commons/thumb/5/59/SAP_2011_logo.svg/440px-SAP_2011_logo.svg.png"); final var message = completion.getChoices().get(0).getMessage(); - assertThat(message.getRole()).isEqualTo("assistant"); + assertThat(message.getRole()).isEqualTo(ASSISTANT); assertThat(message.getContent()).isNotEmpty(); } @Test void streamChatCompletion() { + final var userMessage = + new ChatCompletionRequestUserMessage() + .role(ChatCompletionRequestUserMessage.RoleEnum.USER) + .content(ChatCompletionRequestUserMessageContent.create("Who is the prettiest?")); final var request = - new OpenAiChatCompletionParameters() - .addMessages(new OpenAiChatUserMessage().addText("Who is the prettiest?")); + new CreateChatCompletionRequest() + .addMessagesItem(userMessage) + .tools(null) + .functions(null) + .parallelToolCalls(null); - final var totalOutput = new OpenAiChatCompletionOutput(); + final var totalOutput = new AtomicReference(); final var filledDeltaCount = new AtomicInteger(0); OpenAiClient.forModel(GPT_35_TURBO) .streamChatCompletionDeltas(request) - .peek(totalOutput::addDelta) // foreach consumes all elements, closing the stream at the end .forEach( delta -> { + final var usage = delta.getCompletionUsage(new ObjectMapper()); + totalOutput.compareAndExchange(null, usage); final String deltaContent = delta.getDeltaContent(); log.info("delta: {}", delta); if (!deltaContent.isEmpty()) { @@ -67,10 +79,9 @@ void streamChatCompletion() { // see OpenAiChatCompletionDelta#getDeltaContent assertThat(filledDeltaCount.get()).isGreaterThan(0); - assertThat(totalOutput.getChoices()).isNotEmpty(); - assertThat(totalOutput.getChoices().get(0).getMessage().getContent()).isNotEmpty(); - assertThat(totalOutput.getPromptFilterResults()).isNotNull(); - assertThat(totalOutput.getChoices().get(0).getContentFilterResults()).isNotNull(); + assertThat(totalOutput.get().getTotalTokens()).isGreaterThan(0); + assertThat(totalOutput.get().getPromptTokens()).isEqualTo(14); + assertThat(totalOutput.get().getCompletionTokens()).isGreaterThan(0); } @Test @@ -79,7 +90,7 @@ void chatCompletionTools() { service.chatCompletionTools("Calculate the Fibonacci number for given sequence index."); final var message = completion.getChoices().get(0).getMessage(); - assertThat(message.getRole()).isEqualTo("assistant"); + assertThat(message.getRole()).isEqualTo(ASSISTANT); assertThat(message.getToolCalls()).isNotNull(); assertThat(message.getToolCalls().get(0).getFunction().getName()).isEqualTo("fibonacci"); } @@ -99,7 +110,7 @@ void chatCompletionWithResource() { service.chatCompletionWithResource("ai-sdk-java-e2e", "Where is the nearest coffee shop?"); final var message = completion.getChoices().get(0).getMessage(); - assertThat(message.getRole()).isEqualTo("assistant"); + assertThat(message.getRole()).isEqualTo(ASSISTANT); assertThat(message.getContent()).isNotEmpty(); } }