|
| 1 | +// Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | +// Licensed under the MIT License. |
| 3 | +// Code generated by Microsoft (R) TypeSpec Code Generator. |
| 4 | +package com.azure.search.documents.knowledgebases.models; |
| 5 | + |
| 6 | +import com.azure.core.annotation.Generated; |
| 7 | +import com.azure.core.annotation.Immutable; |
| 8 | +import com.azure.json.JsonReader; |
| 9 | +import com.azure.json.JsonToken; |
| 10 | +import com.azure.json.JsonWriter; |
| 11 | +import java.io.IOException; |
| 12 | + |
| 13 | +/** |
| 14 | + * Represents an LLM web summarization activity record. |
| 15 | + */ |
| 16 | +@Immutable |
| 17 | +public final class KnowledgeBaseModelWebSummarizationActivityRecord extends KnowledgeBaseActivityRecord { |
| 18 | + |
| 19 | + /* |
| 20 | + * The type of the activity record. |
| 21 | + */ |
| 22 | + @Generated |
| 23 | + private KnowledgeBaseActivityRecordType type = KnowledgeBaseActivityRecordType.MODEL_WEB_SUMMARIZATION; |
| 24 | + |
| 25 | + /* |
| 26 | + * The number of input tokens for the LLM web summarization activity. |
| 27 | + */ |
| 28 | + @Generated |
| 29 | + private Integer inputTokens; |
| 30 | + |
| 31 | + /* |
| 32 | + * The number of output tokens for the LLM web summarization activity. |
| 33 | + */ |
| 34 | + @Generated |
| 35 | + private Integer outputTokens; |
| 36 | + |
| 37 | + /** |
| 38 | + * Creates an instance of KnowledgeBaseModelWebSummarizationActivityRecord class. |
| 39 | + * |
| 40 | + * @param id the id value to set. |
| 41 | + */ |
| 42 | + @Generated |
| 43 | + private KnowledgeBaseModelWebSummarizationActivityRecord(int id) { |
| 44 | + super(id); |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * Get the type property: The type of the activity record. |
| 49 | + * |
| 50 | + * @return the type value. |
| 51 | + */ |
| 52 | + @Generated |
| 53 | + @Override |
| 54 | + public KnowledgeBaseActivityRecordType getType() { |
| 55 | + return this.type; |
| 56 | + } |
| 57 | + |
| 58 | + /** |
| 59 | + * Get the inputTokens property: The number of input tokens for the LLM web summarization activity. |
| 60 | + * |
| 61 | + * @return the inputTokens value. |
| 62 | + */ |
| 63 | + @Generated |
| 64 | + public Integer getInputTokens() { |
| 65 | + return this.inputTokens; |
| 66 | + } |
| 67 | + |
| 68 | + /** |
| 69 | + * Get the outputTokens property: The number of output tokens for the LLM web summarization activity. |
| 70 | + * |
| 71 | + * @return the outputTokens value. |
| 72 | + */ |
| 73 | + @Generated |
| 74 | + public Integer getOutputTokens() { |
| 75 | + return this.outputTokens; |
| 76 | + } |
| 77 | + |
| 78 | + /** |
| 79 | + * {@inheritDoc} |
| 80 | + */ |
| 81 | + @Generated |
| 82 | + @Override |
| 83 | + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { |
| 84 | + jsonWriter.writeStartObject(); |
| 85 | + jsonWriter.writeIntField("id", getId()); |
| 86 | + jsonWriter.writeNumberField("elapsedMs", getElapsedMs()); |
| 87 | + jsonWriter.writeJsonField("error", getError()); |
| 88 | + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); |
| 89 | + jsonWriter.writeNumberField("inputTokens", this.inputTokens); |
| 90 | + jsonWriter.writeNumberField("outputTokens", this.outputTokens); |
| 91 | + return jsonWriter.writeEndObject(); |
| 92 | + } |
| 93 | + |
| 94 | + /** |
| 95 | + * Reads an instance of KnowledgeBaseModelWebSummarizationActivityRecord from the JsonReader. |
| 96 | + * |
| 97 | + * @param jsonReader The JsonReader being read. |
| 98 | + * @return An instance of KnowledgeBaseModelWebSummarizationActivityRecord if the JsonReader was pointing to an |
| 99 | + * instance of it, or null if it was pointing to JSON null. |
| 100 | + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. |
| 101 | + * @throws IOException If an error occurs while reading the KnowledgeBaseModelWebSummarizationActivityRecord. |
| 102 | + */ |
| 103 | + @Generated |
| 104 | + public static KnowledgeBaseModelWebSummarizationActivityRecord fromJson(JsonReader jsonReader) throws IOException { |
| 105 | + return jsonReader.readObject(reader -> { |
| 106 | + int id = 0; |
| 107 | + Integer elapsedMs = null; |
| 108 | + KnowledgeBaseErrorDetail error = null; |
| 109 | + KnowledgeBaseActivityRecordType type = KnowledgeBaseActivityRecordType.MODEL_WEB_SUMMARIZATION; |
| 110 | + Integer inputTokens = null; |
| 111 | + Integer outputTokens = null; |
| 112 | + while (reader.nextToken() != JsonToken.END_OBJECT) { |
| 113 | + String fieldName = reader.getFieldName(); |
| 114 | + reader.nextToken(); |
| 115 | + if ("id".equals(fieldName)) { |
| 116 | + id = reader.getInt(); |
| 117 | + } else if ("elapsedMs".equals(fieldName)) { |
| 118 | + elapsedMs = reader.getNullable(JsonReader::getInt); |
| 119 | + } else if ("error".equals(fieldName)) { |
| 120 | + error = KnowledgeBaseErrorDetail.fromJson(reader); |
| 121 | + } else if ("type".equals(fieldName)) { |
| 122 | + type = KnowledgeBaseActivityRecordType.fromString(reader.getString()); |
| 123 | + } else if ("inputTokens".equals(fieldName)) { |
| 124 | + inputTokens = reader.getNullable(JsonReader::getInt); |
| 125 | + } else if ("outputTokens".equals(fieldName)) { |
| 126 | + outputTokens = reader.getNullable(JsonReader::getInt); |
| 127 | + } else { |
| 128 | + reader.skipChildren(); |
| 129 | + } |
| 130 | + } |
| 131 | + KnowledgeBaseModelWebSummarizationActivityRecord deserializedKnowledgeBaseModelWebSummarizationActivityRecord |
| 132 | + = new KnowledgeBaseModelWebSummarizationActivityRecord(id); |
| 133 | + deserializedKnowledgeBaseModelWebSummarizationActivityRecord.setElapsedMs(elapsedMs); |
| 134 | + deserializedKnowledgeBaseModelWebSummarizationActivityRecord.setError(error); |
| 135 | + deserializedKnowledgeBaseModelWebSummarizationActivityRecord.type = type; |
| 136 | + deserializedKnowledgeBaseModelWebSummarizationActivityRecord.inputTokens = inputTokens; |
| 137 | + deserializedKnowledgeBaseModelWebSummarizationActivityRecord.outputTokens = outputTokens; |
| 138 | + return deserializedKnowledgeBaseModelWebSummarizationActivityRecord; |
| 139 | + }); |
| 140 | + } |
| 141 | +} |
0 commit comments