|
| 1 | +/* |
| 2 | + * Internal Orchestration Service API |
| 3 | + * Orchestration is an inference service which provides common additional capabilities for business AI scenarios, such as content filtering and data masking. At the core of the service is the LLM module which allows for an easy, harmonized access to the language models of gen AI hub. The service is designed to be modular and extensible, allowing for the addition of new modules in the future. Each module can be configured independently and at runtime, allowing for a high degree of flexibility in the orchestration of AI services. |
| 4 | + * |
| 5 | + * |
| 6 | + * |
| 7 | + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). |
| 8 | + * https://openapi-generator.tech |
| 9 | + * Do not edit the class manually. |
| 10 | + */ |
| 11 | + |
| 12 | +package com.sap.ai.sdk.orchestration.model; |
| 13 | + |
| 14 | +import com.fasterxml.jackson.annotation.JsonAnyGetter; |
| 15 | +import com.fasterxml.jackson.annotation.JsonAnySetter; |
| 16 | +import com.fasterxml.jackson.annotation.JsonCreator; |
| 17 | +import com.fasterxml.jackson.annotation.JsonIgnore; |
| 18 | +import com.fasterxml.jackson.annotation.JsonProperty; |
| 19 | +import com.fasterxml.jackson.annotation.JsonValue; |
| 20 | +import java.util.LinkedHashMap; |
| 21 | +import java.util.Map; |
| 22 | +import java.util.NoSuchElementException; |
| 23 | +import java.util.Objects; |
| 24 | +import java.util.Set; |
| 25 | +import javax.annotation.Nonnull; |
| 26 | +import javax.annotation.Nullable; |
| 27 | + |
| 28 | +/** Represents an embedding vector returned by embedding endpoint. */ |
| 29 | +// CHECKSTYLE:OFF |
| 30 | +public class EmbeddingResult |
| 31 | +// CHECKSTYLE:ON |
| 32 | +{ |
| 33 | + /** The object type, which is always \"embedding\". */ |
| 34 | + public enum ObjectEnum { |
| 35 | + /** The EMBEDDING option of this EmbeddingResult */ |
| 36 | + EMBEDDING("embedding"), |
| 37 | + |
| 38 | + /** The UNKNOWN_DEFAULT_OPEN_API option of this EmbeddingResult */ |
| 39 | + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); |
| 40 | + |
| 41 | + private String value; |
| 42 | + |
| 43 | + ObjectEnum(String value) { |
| 44 | + this.value = value; |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * Get the value of the enum |
| 49 | + * |
| 50 | + * @return The enum value |
| 51 | + */ |
| 52 | + @JsonValue |
| 53 | + @Nonnull |
| 54 | + public String getValue() { |
| 55 | + return value; |
| 56 | + } |
| 57 | + |
| 58 | + /** |
| 59 | + * Get the String value of the enum value. |
| 60 | + * |
| 61 | + * @return The enum value as String |
| 62 | + */ |
| 63 | + @Override |
| 64 | + @Nonnull |
| 65 | + public String toString() { |
| 66 | + return String.valueOf(value); |
| 67 | + } |
| 68 | + |
| 69 | + /** |
| 70 | + * Get the enum value from a String value |
| 71 | + * |
| 72 | + * @param value The String value |
| 73 | + * @return The enum value of type EmbeddingResult |
| 74 | + */ |
| 75 | + @JsonCreator |
| 76 | + @Nonnull |
| 77 | + public static ObjectEnum fromValue(@Nonnull final String value) { |
| 78 | + for (ObjectEnum b : ObjectEnum.values()) { |
| 79 | + if (b.value.equals(value)) { |
| 80 | + return b; |
| 81 | + } |
| 82 | + } |
| 83 | + return UNKNOWN_DEFAULT_OPEN_API; |
| 84 | + } |
| 85 | + } |
| 86 | + |
| 87 | + @JsonProperty("object") |
| 88 | + private ObjectEnum _object; |
| 89 | + |
| 90 | + @JsonProperty("embedding") |
| 91 | + private Embedding embedding; |
| 92 | + |
| 93 | + @JsonProperty("index") |
| 94 | + private Integer index; |
| 95 | + |
| 96 | + @JsonAnySetter @JsonAnyGetter |
| 97 | + private final Map<String, Object> cloudSdkCustomFields = new LinkedHashMap<>(); |
| 98 | + |
| 99 | + /** Default constructor for EmbeddingResult. */ |
| 100 | + protected EmbeddingResult() {} |
| 101 | + |
| 102 | + /** |
| 103 | + * Set the _object of this {@link EmbeddingResult} instance and return the same instance. |
| 104 | + * |
| 105 | + * @param _object The object type, which is always \"embedding\". |
| 106 | + * @return The same instance of this {@link EmbeddingResult} class |
| 107 | + */ |
| 108 | + @Nonnull |
| 109 | + public EmbeddingResult _object(@Nonnull final ObjectEnum _object) { |
| 110 | + this._object = _object; |
| 111 | + return this; |
| 112 | + } |
| 113 | + |
| 114 | + /** |
| 115 | + * The object type, which is always \"embedding\". |
| 116 | + * |
| 117 | + * @return _object The _object of this {@link EmbeddingResult} instance. |
| 118 | + */ |
| 119 | + @Nonnull |
| 120 | + public ObjectEnum getObject() { |
| 121 | + return _object; |
| 122 | + } |
| 123 | + |
| 124 | + /** |
| 125 | + * Set the _object of this {@link EmbeddingResult} instance. |
| 126 | + * |
| 127 | + * @param _object The object type, which is always \"embedding\". |
| 128 | + */ |
| 129 | + public void setObject(@Nonnull final ObjectEnum _object) { |
| 130 | + this._object = _object; |
| 131 | + } |
| 132 | + |
| 133 | + /** |
| 134 | + * Set the embedding of this {@link EmbeddingResult} instance and return the same instance. |
| 135 | + * |
| 136 | + * @param embedding The embedding of this {@link EmbeddingResult} |
| 137 | + * @return The same instance of this {@link EmbeddingResult} class |
| 138 | + */ |
| 139 | + @Nonnull |
| 140 | + public EmbeddingResult embedding(@Nonnull final Embedding embedding) { |
| 141 | + this.embedding = embedding; |
| 142 | + return this; |
| 143 | + } |
| 144 | + |
| 145 | + /** |
| 146 | + * Get embedding |
| 147 | + * |
| 148 | + * @return embedding The embedding of this {@link EmbeddingResult} instance. |
| 149 | + */ |
| 150 | + @Nonnull |
| 151 | + public Embedding getEmbedding() { |
| 152 | + return embedding; |
| 153 | + } |
| 154 | + |
| 155 | + /** |
| 156 | + * Set the embedding of this {@link EmbeddingResult} instance. |
| 157 | + * |
| 158 | + * @param embedding The embedding of this {@link EmbeddingResult} |
| 159 | + */ |
| 160 | + public void setEmbedding(@Nonnull final Embedding embedding) { |
| 161 | + this.embedding = embedding; |
| 162 | + } |
| 163 | + |
| 164 | + /** |
| 165 | + * Set the index of this {@link EmbeddingResult} instance and return the same instance. |
| 166 | + * |
| 167 | + * @param index The index of the embedding in the list of embeddings. |
| 168 | + * @return The same instance of this {@link EmbeddingResult} class |
| 169 | + */ |
| 170 | + @Nonnull |
| 171 | + public EmbeddingResult index(@Nonnull final Integer index) { |
| 172 | + this.index = index; |
| 173 | + return this; |
| 174 | + } |
| 175 | + |
| 176 | + /** |
| 177 | + * The index of the embedding in the list of embeddings. |
| 178 | + * |
| 179 | + * @return index The index of this {@link EmbeddingResult} instance. |
| 180 | + */ |
| 181 | + @Nonnull |
| 182 | + public Integer getIndex() { |
| 183 | + return index; |
| 184 | + } |
| 185 | + |
| 186 | + /** |
| 187 | + * Set the index of this {@link EmbeddingResult} instance. |
| 188 | + * |
| 189 | + * @param index The index of the embedding in the list of embeddings. |
| 190 | + */ |
| 191 | + public void setIndex(@Nonnull final Integer index) { |
| 192 | + this.index = index; |
| 193 | + } |
| 194 | + |
| 195 | + /** |
| 196 | + * Get the names of the unrecognizable properties of the {@link EmbeddingResult}. |
| 197 | + * |
| 198 | + * @return The set of properties names |
| 199 | + */ |
| 200 | + @JsonIgnore |
| 201 | + @Nonnull |
| 202 | + public Set<String> getCustomFieldNames() { |
| 203 | + return cloudSdkCustomFields.keySet(); |
| 204 | + } |
| 205 | + |
| 206 | + /** |
| 207 | + * Get the value of an unrecognizable property of this {@link EmbeddingResult} instance. |
| 208 | + * |
| 209 | + * @deprecated Use {@link #toMap()} instead. |
| 210 | + * @param name The name of the property |
| 211 | + * @return The value of the property |
| 212 | + * @throws NoSuchElementException If no property with the given name could be found. |
| 213 | + */ |
| 214 | + @Nullable |
| 215 | + @Deprecated |
| 216 | + public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { |
| 217 | + if (!cloudSdkCustomFields.containsKey(name)) { |
| 218 | + throw new NoSuchElementException("EmbeddingResult has no field with name '" + name + "'."); |
| 219 | + } |
| 220 | + return cloudSdkCustomFields.get(name); |
| 221 | + } |
| 222 | + |
| 223 | + /** |
| 224 | + * Get the value of all properties of this {@link EmbeddingResult} instance including unrecognized |
| 225 | + * properties. |
| 226 | + * |
| 227 | + * @return The map of all properties |
| 228 | + */ |
| 229 | + @JsonIgnore |
| 230 | + @Nonnull |
| 231 | + public Map<String, Object> toMap() { |
| 232 | + final Map<String, Object> declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); |
| 233 | + if (_object != null) declaredFields.put("_object", _object); |
| 234 | + if (embedding != null) declaredFields.put("embedding", embedding); |
| 235 | + if (index != null) declaredFields.put("index", index); |
| 236 | + return declaredFields; |
| 237 | + } |
| 238 | + |
| 239 | + /** |
| 240 | + * Set an unrecognizable property of this {@link EmbeddingResult} instance. If the map previously |
| 241 | + * contained a mapping for the key, the old value is replaced by the specified value. |
| 242 | + * |
| 243 | + * @param customFieldName The name of the property |
| 244 | + * @param customFieldValue The value of the property |
| 245 | + */ |
| 246 | + @JsonIgnore |
| 247 | + public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) { |
| 248 | + cloudSdkCustomFields.put(customFieldName, customFieldValue); |
| 249 | + } |
| 250 | + |
| 251 | + @Override |
| 252 | + public boolean equals(@Nullable final java.lang.Object o) { |
| 253 | + if (this == o) { |
| 254 | + return true; |
| 255 | + } |
| 256 | + if (o == null || getClass() != o.getClass()) { |
| 257 | + return false; |
| 258 | + } |
| 259 | + final EmbeddingResult embeddingResult = (EmbeddingResult) o; |
| 260 | + return Objects.equals(this.cloudSdkCustomFields, embeddingResult.cloudSdkCustomFields) |
| 261 | + && Objects.equals(this._object, embeddingResult._object) |
| 262 | + && Objects.equals(this.embedding, embeddingResult.embedding) |
| 263 | + && Objects.equals(this.index, embeddingResult.index); |
| 264 | + } |
| 265 | + |
| 266 | + @Override |
| 267 | + public int hashCode() { |
| 268 | + return Objects.hash(_object, embedding, index, cloudSdkCustomFields); |
| 269 | + } |
| 270 | + |
| 271 | + @Override |
| 272 | + @Nonnull |
| 273 | + public String toString() { |
| 274 | + final StringBuilder sb = new StringBuilder(); |
| 275 | + sb.append("class EmbeddingResult {\n"); |
| 276 | + sb.append(" _object: ").append(toIndentedString(_object)).append("\n"); |
| 277 | + sb.append(" embedding: ").append(toIndentedString(embedding)).append("\n"); |
| 278 | + sb.append(" index: ").append(toIndentedString(index)).append("\n"); |
| 279 | + cloudSdkCustomFields.forEach( |
| 280 | + (k, v) -> |
| 281 | + sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); |
| 282 | + sb.append("}"); |
| 283 | + return sb.toString(); |
| 284 | + } |
| 285 | + |
| 286 | + /** |
| 287 | + * Convert the given object to string with each line indented by 4 spaces (except the first line). |
| 288 | + */ |
| 289 | + private String toIndentedString(final java.lang.Object o) { |
| 290 | + if (o == null) { |
| 291 | + return "null"; |
| 292 | + } |
| 293 | + return o.toString().replace("\n", "\n "); |
| 294 | + } |
| 295 | + |
| 296 | + /** |
| 297 | + * Create a type-safe, fluent-api builder object to construct a new {@link EmbeddingResult} |
| 298 | + * instance with all required arguments. |
| 299 | + */ |
| 300 | + public static Builder create() { |
| 301 | + return (_object) -> |
| 302 | + (embedding) -> |
| 303 | + (index) -> new EmbeddingResult()._object(_object).embedding(embedding).index(index); |
| 304 | + } |
| 305 | + |
| 306 | + /** Builder helper class. */ |
| 307 | + public interface Builder { |
| 308 | + /** |
| 309 | + * Set the _object of this {@link EmbeddingResult} instance. |
| 310 | + * |
| 311 | + * @param _object The object type, which is always \"embedding\". |
| 312 | + * @return The EmbeddingResult builder. |
| 313 | + */ |
| 314 | + Builder1 _object(@Nonnull final ObjectEnum _object); |
| 315 | + } |
| 316 | + |
| 317 | + /** Builder helper class. */ |
| 318 | + public interface Builder1 { |
| 319 | + /** |
| 320 | + * Set the embedding of this {@link EmbeddingResult} instance. |
| 321 | + * |
| 322 | + * @param embedding The embedding of this {@link EmbeddingResult} |
| 323 | + * @return The EmbeddingResult builder. |
| 324 | + */ |
| 325 | + Builder2 embedding(@Nonnull final Embedding embedding); |
| 326 | + } |
| 327 | + |
| 328 | + /** Builder helper class. */ |
| 329 | + public interface Builder2 { |
| 330 | + /** |
| 331 | + * Set the index of this {@link EmbeddingResult} instance. |
| 332 | + * |
| 333 | + * @param index The index of the embedding in the list of embeddings. |
| 334 | + * @return The EmbeddingResult instance. |
| 335 | + */ |
| 336 | + EmbeddingResult index(@Nonnull final Integer index); |
| 337 | + } |
| 338 | +} |
0 commit comments