|
| 1 | +/* |
| 2 | + * Copyright (c) 2025 SAP SE or an SAP affiliate company. All rights reserved. |
| 3 | + */ |
| 4 | + |
| 5 | +/* |
| 6 | + * Azure OpenAI Service API |
| 7 | + * Azure OpenAI APIs for completions and search |
| 8 | + * |
| 9 | + * The version of the OpenAPI document: 2024-10-21 |
| 10 | + * |
| 11 | + * |
| 12 | + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). |
| 13 | + * https://openapi-generator.tech |
| 14 | + * Do not edit the class manually. |
| 15 | + */ |
| 16 | + |
| 17 | +package com.sap.ai.sdk.foundationmodels.openai.generated.model; |
| 18 | + |
| 19 | +import com.fasterxml.jackson.annotation.JsonAnyGetter; |
| 20 | +import com.fasterxml.jackson.annotation.JsonAnySetter; |
| 21 | +import com.fasterxml.jackson.annotation.JsonIgnore; |
| 22 | +import com.fasterxml.jackson.annotation.JsonProperty; |
| 23 | +import java.util.LinkedHashMap; |
| 24 | +import java.util.Map; |
| 25 | +import java.util.NoSuchElementException; |
| 26 | +import java.util.Objects; |
| 27 | +import java.util.Set; |
| 28 | +import javax.annotation.Nonnull; |
| 29 | +import javax.annotation.Nullable; |
| 30 | + |
| 31 | +/** |
| 32 | + * Deprecated and replaced by `tool_calls`. The name and arguments of a function that |
| 33 | + * should be called, as generated by the model. |
| 34 | + */ |
| 35 | +// CHECKSTYLE:OFF |
| 36 | +@com.google.common.annotations.Beta |
| 37 | +public class ChatCompletionFunctionCall |
| 38 | +// CHECKSTYLE:ON |
| 39 | +{ |
| 40 | + @JsonProperty("name") |
| 41 | + private String name; |
| 42 | + |
| 43 | + @JsonProperty("arguments") |
| 44 | + private String arguments; |
| 45 | + |
| 46 | + @JsonAnySetter @JsonAnyGetter |
| 47 | + private final Map<String, Object> cloudSdkCustomFields = new LinkedHashMap<>(); |
| 48 | + |
| 49 | + /** |
| 50 | + * Set the name of this {@link ChatCompletionFunctionCall} instance and return the same instance. |
| 51 | + * |
| 52 | + * @param name The name of the function to call. |
| 53 | + * @return The same instance of this {@link ChatCompletionFunctionCall} class |
| 54 | + */ |
| 55 | + @Nonnull |
| 56 | + public ChatCompletionFunctionCall name(@Nonnull final String name) { |
| 57 | + this.name = name; |
| 58 | + return this; |
| 59 | + } |
| 60 | + |
| 61 | + /** |
| 62 | + * The name of the function to call. |
| 63 | + * |
| 64 | + * @return name The name of this {@link ChatCompletionFunctionCall} instance. |
| 65 | + */ |
| 66 | + @Nonnull |
| 67 | + public String getName() { |
| 68 | + return name; |
| 69 | + } |
| 70 | + |
| 71 | + /** |
| 72 | + * Set the name of this {@link ChatCompletionFunctionCall} instance. |
| 73 | + * |
| 74 | + * @param name The name of the function to call. |
| 75 | + */ |
| 76 | + public void setName(@Nonnull final String name) { |
| 77 | + this.name = name; |
| 78 | + } |
| 79 | + |
| 80 | + /** |
| 81 | + * Set the arguments of this {@link ChatCompletionFunctionCall} instance and return the same |
| 82 | + * instance. |
| 83 | + * |
| 84 | + * @param arguments The arguments to call the function with, as generated by the model in JSON |
| 85 | + * format. Note that the model does not always generate valid JSON, and may hallucinate |
| 86 | + * parameters not defined by your function schema. Validate the arguments in your code before |
| 87 | + * calling your function. |
| 88 | + * @return The same instance of this {@link ChatCompletionFunctionCall} class |
| 89 | + */ |
| 90 | + @Nonnull |
| 91 | + public ChatCompletionFunctionCall arguments(@Nonnull final String arguments) { |
| 92 | + this.arguments = arguments; |
| 93 | + return this; |
| 94 | + } |
| 95 | + |
| 96 | + /** |
| 97 | + * The arguments to call the function with, as generated by the model in JSON format. Note that |
| 98 | + * the model does not always generate valid JSON, and may hallucinate parameters not defined by |
| 99 | + * your function schema. Validate the arguments in your code before calling your function. |
| 100 | + * |
| 101 | + * @return arguments The arguments of this {@link ChatCompletionFunctionCall} instance. |
| 102 | + */ |
| 103 | + @Nonnull |
| 104 | + public String getArguments() { |
| 105 | + return arguments; |
| 106 | + } |
| 107 | + |
| 108 | + /** |
| 109 | + * Set the arguments of this {@link ChatCompletionFunctionCall} instance. |
| 110 | + * |
| 111 | + * @param arguments The arguments to call the function with, as generated by the model in JSON |
| 112 | + * format. Note that the model does not always generate valid JSON, and may hallucinate |
| 113 | + * parameters not defined by your function schema. Validate the arguments in your code before |
| 114 | + * calling your function. |
| 115 | + */ |
| 116 | + public void setArguments(@Nonnull final String arguments) { |
| 117 | + this.arguments = arguments; |
| 118 | + } |
| 119 | + |
| 120 | + /** |
| 121 | + * Get the names of the unrecognizable properties of the {@link ChatCompletionFunctionCall}. |
| 122 | + * |
| 123 | + * @return The set of properties names |
| 124 | + */ |
| 125 | + @JsonIgnore |
| 126 | + @Nonnull |
| 127 | + public Set<String> getCustomFieldNames() { |
| 128 | + return cloudSdkCustomFields.keySet(); |
| 129 | + } |
| 130 | + |
| 131 | + /** |
| 132 | + * Get the value of an unrecognizable property of this {@link ChatCompletionFunctionCall} |
| 133 | + * instance. |
| 134 | + * |
| 135 | + * @param name The name of the property |
| 136 | + * @return The value of the property |
| 137 | + * @throws NoSuchElementException If no property with the given name could be found. |
| 138 | + */ |
| 139 | + @Nullable |
| 140 | + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { |
| 141 | + if (!cloudSdkCustomFields.containsKey(name)) { |
| 142 | + throw new NoSuchElementException( |
| 143 | + "ChatCompletionFunctionCall has no field with name '" + name + "'."); |
| 144 | + } |
| 145 | + return cloudSdkCustomFields.get(name); |
| 146 | + } |
| 147 | + |
| 148 | + /** |
| 149 | + * Set an unrecognizable property of this {@link ChatCompletionFunctionCall} instance. If the map |
| 150 | + * previously contained a mapping for the key, the old value is replaced by the specified value. |
| 151 | + * |
| 152 | + * @param customFieldName The name of the property |
| 153 | + * @param customFieldValue The value of the property |
| 154 | + */ |
| 155 | + @JsonIgnore |
| 156 | + public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) { |
| 157 | + cloudSdkCustomFields.put(customFieldName, customFieldValue); |
| 158 | + } |
| 159 | + |
| 160 | + @Override |
| 161 | + public boolean equals(@Nullable final Object o) { |
| 162 | + if (this == o) { |
| 163 | + return true; |
| 164 | + } |
| 165 | + if (o == null || getClass() != o.getClass()) { |
| 166 | + return false; |
| 167 | + } |
| 168 | + final ChatCompletionFunctionCall chatCompletionFunctionCall = (ChatCompletionFunctionCall) o; |
| 169 | + return Objects.equals( |
| 170 | + this.cloudSdkCustomFields, chatCompletionFunctionCall.cloudSdkCustomFields) |
| 171 | + && Objects.equals(this.name, chatCompletionFunctionCall.name) |
| 172 | + && Objects.equals(this.arguments, chatCompletionFunctionCall.arguments); |
| 173 | + } |
| 174 | + |
| 175 | + @Override |
| 176 | + public int hashCode() { |
| 177 | + return Objects.hash(name, arguments, cloudSdkCustomFields); |
| 178 | + } |
| 179 | + |
| 180 | + @Override |
| 181 | + @Nonnull |
| 182 | + public String toString() { |
| 183 | + final StringBuilder sb = new StringBuilder(); |
| 184 | + sb.append("class ChatCompletionFunctionCall {\n"); |
| 185 | + sb.append(" name: ").append(toIndentedString(name)).append("\n"); |
| 186 | + sb.append(" arguments: ").append(toIndentedString(arguments)).append("\n"); |
| 187 | + cloudSdkCustomFields.forEach( |
| 188 | + (k, v) -> |
| 189 | + sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); |
| 190 | + sb.append("}"); |
| 191 | + return sb.toString(); |
| 192 | + } |
| 193 | + |
| 194 | + /** |
| 195 | + * Convert the given object to string with each line indented by 4 spaces (except the first line). |
| 196 | + */ |
| 197 | + private String toIndentedString(final Object o) { |
| 198 | + if (o == null) { |
| 199 | + return "null"; |
| 200 | + } |
| 201 | + return o.toString().replace("\n", "\n "); |
| 202 | + } |
| 203 | +} |
0 commit comments