From 6504ca1b94b2f79879303786ca561f00e4ebe5c4 Mon Sep 17 00:00:00 2001 From: Shawn Fang Date: Tue, 21 May 2024 14:16:51 -0700 Subject: [PATCH 1/7] regenerated without changes --- sdk/openai/azure-ai-openai/CHANGELOG.md | 2 +- .../azure/ai/openai/OpenAIServiceVersion.java | 9 +- .../implementation/OpenAIClientImpl.java | 50 ++++ ...ExtensionRetrieveDocumentFilterReason.java | 59 ++++ .../AzureChatExtensionRetrievedDocument.java | 283 ++++++++++++++++++ .../AzureChatExtensionsMessageContext.java | 22 ++ .../AzureCosmosDBChatExtensionParameters.java | 115 +++++++ ...eLearningIndexChatExtensionParameters.java | 116 +++++++ .../AzureSearchChatExtensionParameters.java | 115 +++++++ .../ElasticsearchChatExtensionParameters.java | 115 +++++++ .../ImageGenerationPromptFilterResults.java | 21 ++ .../models/OnYourDataContextProperty.java | 63 ++++ ...DataDeploymentNameVectorizationSource.java | 39 ++- ...OnYourDataEndpointVectorizationSource.java | 33 +- ...earchAccessTokenAuthenticationOptions.java | 109 +++++++ ...ctorSearchApiKeyAuthenticationOptions.java | 108 +++++++ ...DataVectorSearchAuthenticationOptions.java | 113 +++++++ ...ourDataVectorSearchAuthenticationType.java | 58 ++++ .../PineconeChatExtensionParameters.java | 115 +++++++ .../azure-ai-openai_apiview_properties.json | 7 + sdk/openai/azure-ai-openai/tsp-location.yaml | 2 +- 21 files changed, 1532 insertions(+), 22 deletions(-) create mode 100644 sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/AzureChatExtensionRetrieveDocumentFilterReason.java create mode 100644 sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/AzureChatExtensionRetrievedDocument.java create mode 100644 sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataContextProperty.java create mode 100644 sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataVectorSearchAccessTokenAuthenticationOptions.java create mode 100644 sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataVectorSearchApiKeyAuthenticationOptions.java create mode 100644 sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataVectorSearchAuthenticationOptions.java create mode 100644 sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataVectorSearchAuthenticationType.java diff --git a/sdk/openai/azure-ai-openai/CHANGELOG.md b/sdk/openai/azure-ai-openai/CHANGELOG.md index 257f4ed1ae68..3f79b3407226 100644 --- a/sdk/openai/azure-ai-openai/CHANGELOG.md +++ b/sdk/openai/azure-ai-openai/CHANGELOG.md @@ -4,7 +4,7 @@ ### Features Added -- Added support for service API version, `2024-04-01-preview`. +- Added support for service API versions, `2024-04-01-preview` and `2024-05-01-preview`. - Note that `AOAI` refers to Azure OpenAI and `OAI` refers to OpenAI. **Audio** diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/OpenAIServiceVersion.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/OpenAIServiceVersion.java index dc12f29c2a80..8d810e97aee4 100644 --- a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/OpenAIServiceVersion.java +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/OpenAIServiceVersion.java @@ -43,7 +43,12 @@ public enum OpenAIServiceVersion implements ServiceVersion { /** * Enum value 2024-04-01-preview. */ - V2024_04_01_PREVIEW("2024-04-01-preview"); + V2024_04_01_PREVIEW("2024-04-01-preview"), + + /** + * Enum value 2024-05-01-preview. + */ + V2024_05_01_PREVIEW("2024-05-01-preview"); private final String version; @@ -65,6 +70,6 @@ public String getVersion() { * @return The latest {@link OpenAIServiceVersion}. */ public static OpenAIServiceVersion getLatest() { - return V2024_04_01_PREVIEW; + return V2024_05_01_PREVIEW; } } diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/implementation/OpenAIClientImpl.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/implementation/OpenAIClientImpl.java index 6bc221457dbd..48b58a1ad600 100644 --- a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/implementation/OpenAIClientImpl.java +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/implementation/OpenAIClientImpl.java @@ -1090,6 +1090,22 @@ public Response getCompletionsWithResponse(String deploymentOrModelN * } * ] * intent: String (Optional) + * all_retrieved_documents (Optional): [ + * (Optional){ + * content: String (Required) + * title: String (Optional) + * url: String (Optional) + * filepath: String (Optional) + * chunk_id: String (Optional) + * search_queries (Required): [ + * String (Required) + * ] + * data_source_index: int (Required) + * original_search_score: Double (Optional) + * rerank_score: Double (Optional) + * filter_reason: String(score/rerank) (Optional) + * } + * ] * } * } * logprobs (Required): { @@ -1328,6 +1344,22 @@ public Mono> getChatCompletionsWithResponseAsync(String dep * } * ] * intent: String (Optional) + * all_retrieved_documents (Optional): [ + * (Optional){ + * content: String (Required) + * title: String (Optional) + * url: String (Optional) + * filepath: String (Optional) + * chunk_id: String (Optional) + * search_queries (Required): [ + * String (Required) + * ] + * data_source_index: int (Required) + * original_search_score: Double (Optional) + * rerank_score: Double (Optional) + * filter_reason: String(score/rerank) (Optional) + * } + * ] * } * } * logprobs (Required): { @@ -1515,6 +1547,15 @@ public Response getChatCompletionsWithResponse(String deploymentOrMo * detected: boolean (Required) * } * jailbreak (Optional): (recursive schema, see jailbreak above) + * custom_blocklists (Optional): { + * filtered: boolean (Required) + * details (Required): [ + * (Required){ + * filtered: boolean (Required) + * id: String (Required) + * } + * ] + * } * } * } * ] @@ -1587,6 +1628,15 @@ public Mono> getImageGenerationsWithResponseAsync(String de * detected: boolean (Required) * } * jailbreak (Optional): (recursive schema, see jailbreak above) + * custom_blocklists (Optional): { + * filtered: boolean (Required) + * details (Required): [ + * (Required){ + * filtered: boolean (Required) + * id: String (Required) + * } + * ] + * } * } * } * ] diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/AzureChatExtensionRetrieveDocumentFilterReason.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/AzureChatExtensionRetrieveDocumentFilterReason.java new file mode 100644 index 000000000000..2112b8d74f60 --- /dev/null +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/AzureChatExtensionRetrieveDocumentFilterReason.java @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.openai.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The reason for filtering the retrieved document. + */ +public final class AzureChatExtensionRetrieveDocumentFilterReason + extends ExpandableStringEnum { + /** + * The document is filtered by original search score threshold defined by `strictness` configure. + */ + @Generated + public static final AzureChatExtensionRetrieveDocumentFilterReason SCORE = fromString("score"); + + /** + * The document is not filtered by original search score threshold, but is filtered by rerank score and + * `top_n_documents` configure. + */ + @Generated + public static final AzureChatExtensionRetrieveDocumentFilterReason RERANK = fromString("rerank"); + + /** + * Creates a new instance of AzureChatExtensionRetrieveDocumentFilterReason value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public AzureChatExtensionRetrieveDocumentFilterReason() { + } + + /** + * Creates or finds a AzureChatExtensionRetrieveDocumentFilterReason from its string representation. + * + * @param name a name to look for. + * @return the corresponding AzureChatExtensionRetrieveDocumentFilterReason. + */ + @Generated + public static AzureChatExtensionRetrieveDocumentFilterReason fromString(String name) { + return fromString(name, AzureChatExtensionRetrieveDocumentFilterReason.class); + } + + /** + * Gets known AzureChatExtensionRetrieveDocumentFilterReason values. + * + * @return known AzureChatExtensionRetrieveDocumentFilterReason values. + */ + @Generated + public static Collection values() { + return values(AzureChatExtensionRetrieveDocumentFilterReason.class); + } +} diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/AzureChatExtensionRetrievedDocument.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/AzureChatExtensionRetrievedDocument.java new file mode 100644 index 000000000000..4206db93254d --- /dev/null +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/AzureChatExtensionRetrievedDocument.java @@ -0,0 +1,283 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.openai.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * The retrieved document. + */ +@Immutable +public final class AzureChatExtensionRetrievedDocument + implements JsonSerializable { + /* + * The content of the citation. + */ + @Generated + private final String content; + + /* + * The title of the citation. + */ + @Generated + private String title; + + /* + * The URL of the citation. + */ + @Generated + private String url; + + /* + * The file path of the citation. + */ + @Generated + private String filepath; + + /* + * The chunk ID of the citation. + */ + @Generated + private String chunkId; + + /* + * The search queries used to retrieve the document. + */ + @Generated + private final List searchQueries; + + /* + * The index of the data source. + */ + @Generated + private final int dataSourceIndex; + + /* + * The original search score of the retrieved document. + */ + @Generated + private Double originalSearchScore; + + /* + * The rerank score of the retrieved document. + */ + @Generated + private Double rerankScore; + + /* + * Represents the rationale for filtering the document. If the document does not undergo filtering, + * this field will remain unset. + */ + @Generated + private AzureChatExtensionRetrieveDocumentFilterReason filterReason; + + /** + * Creates an instance of AzureChatExtensionRetrievedDocument class. + * + * @param content the content value to set. + * @param searchQueries the searchQueries value to set. + * @param dataSourceIndex the dataSourceIndex value to set. + */ + @Generated + private AzureChatExtensionRetrievedDocument(String content, List searchQueries, int dataSourceIndex) { + this.content = content; + this.searchQueries = searchQueries; + this.dataSourceIndex = dataSourceIndex; + } + + /** + * Get the content property: The content of the citation. + * + * @return the content value. + */ + @Generated + public String getContent() { + return this.content; + } + + /** + * Get the title property: The title of the citation. + * + * @return the title value. + */ + @Generated + public String getTitle() { + return this.title; + } + + /** + * Get the url property: The URL of the citation. + * + * @return the url value. + */ + @Generated + public String getUrl() { + return this.url; + } + + /** + * Get the filepath property: The file path of the citation. + * + * @return the filepath value. + */ + @Generated + public String getFilepath() { + return this.filepath; + } + + /** + * Get the chunkId property: The chunk ID of the citation. + * + * @return the chunkId value. + */ + @Generated + public String getChunkId() { + return this.chunkId; + } + + /** + * Get the searchQueries property: The search queries used to retrieve the document. + * + * @return the searchQueries value. + */ + @Generated + public List getSearchQueries() { + return this.searchQueries; + } + + /** + * Get the dataSourceIndex property: The index of the data source. + * + * @return the dataSourceIndex value. + */ + @Generated + public int getDataSourceIndex() { + return this.dataSourceIndex; + } + + /** + * Get the originalSearchScore property: The original search score of the retrieved document. + * + * @return the originalSearchScore value. + */ + @Generated + public Double getOriginalSearchScore() { + return this.originalSearchScore; + } + + /** + * Get the rerankScore property: The rerank score of the retrieved document. + * + * @return the rerankScore value. + */ + @Generated + public Double getRerankScore() { + return this.rerankScore; + } + + /** + * Get the filterReason property: Represents the rationale for filtering the document. If the document does not + * undergo filtering, + * this field will remain unset. + * + * @return the filterReason value. + */ + @Generated + public AzureChatExtensionRetrieveDocumentFilterReason getFilterReason() { + return this.filterReason; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("content", this.content); + jsonWriter.writeArrayField("search_queries", this.searchQueries, + (writer, element) -> writer.writeString(element)); + jsonWriter.writeIntField("data_source_index", this.dataSourceIndex); + jsonWriter.writeStringField("title", this.title); + jsonWriter.writeStringField("url", this.url); + jsonWriter.writeStringField("filepath", this.filepath); + jsonWriter.writeStringField("chunk_id", this.chunkId); + jsonWriter.writeNumberField("original_search_score", this.originalSearchScore); + jsonWriter.writeNumberField("rerank_score", this.rerankScore); + jsonWriter.writeStringField("filter_reason", this.filterReason == null ? null : this.filterReason.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AzureChatExtensionRetrievedDocument from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AzureChatExtensionRetrievedDocument if the JsonReader was pointing to an instance of it, + * or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the AzureChatExtensionRetrievedDocument. + */ + @Generated + public static AzureChatExtensionRetrievedDocument fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String content = null; + List searchQueries = null; + int dataSourceIndex = 0; + String title = null; + String url = null; + String filepath = null; + String chunkId = null; + Double originalSearchScore = null; + Double rerankScore = null; + AzureChatExtensionRetrieveDocumentFilterReason filterReason = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("content".equals(fieldName)) { + content = reader.getString(); + } else if ("search_queries".equals(fieldName)) { + searchQueries = reader.readArray(reader1 -> reader1.getString()); + } else if ("data_source_index".equals(fieldName)) { + dataSourceIndex = reader.getInt(); + } else if ("title".equals(fieldName)) { + title = reader.getString(); + } else if ("url".equals(fieldName)) { + url = reader.getString(); + } else if ("filepath".equals(fieldName)) { + filepath = reader.getString(); + } else if ("chunk_id".equals(fieldName)) { + chunkId = reader.getString(); + } else if ("original_search_score".equals(fieldName)) { + originalSearchScore = reader.getNullable(JsonReader::getDouble); + } else if ("rerank_score".equals(fieldName)) { + rerankScore = reader.getNullable(JsonReader::getDouble); + } else if ("filter_reason".equals(fieldName)) { + filterReason = AzureChatExtensionRetrieveDocumentFilterReason.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + AzureChatExtensionRetrievedDocument deserializedAzureChatExtensionRetrievedDocument + = new AzureChatExtensionRetrievedDocument(content, searchQueries, dataSourceIndex); + deserializedAzureChatExtensionRetrievedDocument.title = title; + deserializedAzureChatExtensionRetrievedDocument.url = url; + deserializedAzureChatExtensionRetrievedDocument.filepath = filepath; + deserializedAzureChatExtensionRetrievedDocument.chunkId = chunkId; + deserializedAzureChatExtensionRetrievedDocument.originalSearchScore = originalSearchScore; + deserializedAzureChatExtensionRetrievedDocument.rerankScore = rerankScore; + deserializedAzureChatExtensionRetrievedDocument.filterReason = filterReason; + + return deserializedAzureChatExtensionRetrievedDocument; + }); + } +} diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/AzureChatExtensionsMessageContext.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/AzureChatExtensionsMessageContext.java index 939deaa01fd9..d61b26fd7b61 100644 --- a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/AzureChatExtensionsMessageContext.java +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/AzureChatExtensionsMessageContext.java @@ -76,6 +76,8 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); jsonWriter.writeArrayField("citations", this.citations, (writer, element) -> writer.writeJson(element)); jsonWriter.writeStringField("intent", this.intent); + jsonWriter.writeArrayField("all_retrieved_documents", this.allRetrievedDocuments, + (writer, element) -> writer.writeJson(element)); return jsonWriter.writeEndObject(); } @@ -101,6 +103,10 @@ public static AzureChatExtensionsMessageContext fromJson(JsonReader jsonReader) deserializedAzureChatExtensionsMessageContext.citations = citations; } else if ("intent".equals(fieldName)) { deserializedAzureChatExtensionsMessageContext.intent = reader.getString(); + } else if ("all_retrieved_documents".equals(fieldName)) { + List allRetrievedDocuments + = reader.readArray(reader1 -> AzureChatExtensionRetrievedDocument.fromJson(reader1)); + deserializedAzureChatExtensionsMessageContext.allRetrievedDocuments = allRetrievedDocuments; } else { reader.skipChildren(); } @@ -108,4 +114,20 @@ public static AzureChatExtensionsMessageContext fromJson(JsonReader jsonReader) return deserializedAzureChatExtensionsMessageContext; }); } + + /* + * All the retrieved documents. + */ + @Generated + private List allRetrievedDocuments; + + /** + * Get the allRetrievedDocuments property: All the retrieved documents. + * + * @return the allRetrievedDocuments value. + */ + @Generated + public List getAllRetrievedDocuments() { + return this.allRetrievedDocuments; + } } diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/AzureCosmosDBChatExtensionParameters.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/AzureCosmosDBChatExtensionParameters.java index b72934422eed..6e4b105a9061 100644 --- a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/AzureCosmosDBChatExtensionParameters.java +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/AzureCosmosDBChatExtensionParameters.java @@ -10,6 +10,7 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; +import java.util.List; /** * Parameters to use when configuring Azure OpenAI On Your Data chat extensions when using Azure Cosmos DB for @@ -299,6 +300,10 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeBooleanField("in_scope", this.inScope); jsonWriter.writeNumberField("strictness", this.strictness); jsonWriter.writeStringField("role_information", this.roleInformation); + jsonWriter.writeNumberField("max_search_queries", this.maxSearchQueries); + jsonWriter.writeBooleanField("allow_partial_result", this.allowPartialResult); + jsonWriter.writeArrayField("include_contexts", this.includeContexts, + (writer, element) -> writer.writeString(element == null ? null : element.toString())); return jsonWriter.writeEndObject(); } @@ -324,6 +329,9 @@ public static AzureCosmosDBChatExtensionParameters fromJson(JsonReader jsonReade Boolean inScope = null; Integer strictness = null; String roleInformation = null; + Integer maxSearchQueries = null; + Boolean allowPartialResult = null; + List includeContexts = null; while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); @@ -347,6 +355,13 @@ public static AzureCosmosDBChatExtensionParameters fromJson(JsonReader jsonReade strictness = reader.getNullable(JsonReader::getInt); } else if ("role_information".equals(fieldName)) { roleInformation = reader.getString(); + } else if ("max_search_queries".equals(fieldName)) { + maxSearchQueries = reader.getNullable(JsonReader::getInt); + } else if ("allow_partial_result".equals(fieldName)) { + allowPartialResult = reader.getNullable(JsonReader::getBoolean); + } else if ("include_contexts".equals(fieldName)) { + includeContexts + = reader.readArray(reader1 -> OnYourDataContextProperty.fromString(reader1.getString())); } else { reader.skipChildren(); } @@ -359,7 +374,107 @@ public static AzureCosmosDBChatExtensionParameters fromJson(JsonReader jsonReade deserializedAzureCosmosDBChatExtensionParameters.inScope = inScope; deserializedAzureCosmosDBChatExtensionParameters.strictness = strictness; deserializedAzureCosmosDBChatExtensionParameters.roleInformation = roleInformation; + deserializedAzureCosmosDBChatExtensionParameters.maxSearchQueries = maxSearchQueries; + deserializedAzureCosmosDBChatExtensionParameters.allowPartialResult = allowPartialResult; + deserializedAzureCosmosDBChatExtensionParameters.includeContexts = includeContexts; return deserializedAzureCosmosDBChatExtensionParameters; }); } + + /* + * The max number of rewritten queries should be send to search provider for one user message. If not specified, + * the system will decide the number of queries to send. + */ + @Generated + private Integer maxSearchQueries; + + /* + * If specified as true, the system will allow partial search results to be used and the request fails if all the + * queries fail. + * If not specified, or specified as false, the request will fail if any search query fails. + */ + @Generated + private Boolean allowPartialResult; + + /* + * The included properties of the output context. If not specified, the default value is `citations` and `intent`. + */ + @Generated + private List includeContexts; + + /** + * Get the maxSearchQueries property: The max number of rewritten queries should be send to search provider for one + * user message. If not specified, + * the system will decide the number of queries to send. + * + * @return the maxSearchQueries value. + */ + @Generated + public Integer getMaxSearchQueries() { + return this.maxSearchQueries; + } + + /** + * Set the maxSearchQueries property: The max number of rewritten queries should be send to search provider for one + * user message. If not specified, + * the system will decide the number of queries to send. + * + * @param maxSearchQueries the maxSearchQueries value to set. + * @return the AzureCosmosDBChatExtensionParameters object itself. + */ + @Generated + public AzureCosmosDBChatExtensionParameters setMaxSearchQueries(Integer maxSearchQueries) { + this.maxSearchQueries = maxSearchQueries; + return this; + } + + /** + * Get the allowPartialResult property: If specified as true, the system will allow partial search results to be + * used and the request fails if all the queries fail. + * If not specified, or specified as false, the request will fail if any search query fails. + * + * @return the allowPartialResult value. + */ + @Generated + public Boolean isAllowPartialResult() { + return this.allowPartialResult; + } + + /** + * Set the allowPartialResult property: If specified as true, the system will allow partial search results to be + * used and the request fails if all the queries fail. + * If not specified, or specified as false, the request will fail if any search query fails. + * + * @param allowPartialResult the allowPartialResult value to set. + * @return the AzureCosmosDBChatExtensionParameters object itself. + */ + @Generated + public AzureCosmosDBChatExtensionParameters setAllowPartialResult(Boolean allowPartialResult) { + this.allowPartialResult = allowPartialResult; + return this; + } + + /** + * Get the includeContexts property: The included properties of the output context. If not specified, the default + * value is `citations` and `intent`. + * + * @return the includeContexts value. + */ + @Generated + public List getIncludeContexts() { + return this.includeContexts; + } + + /** + * Set the includeContexts property: The included properties of the output context. If not specified, the default + * value is `citations` and `intent`. + * + * @param includeContexts the includeContexts value to set. + * @return the AzureCosmosDBChatExtensionParameters object itself. + */ + @Generated + public AzureCosmosDBChatExtensionParameters setIncludeContexts(List includeContexts) { + this.includeContexts = includeContexts; + return this; + } } diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/AzureMachineLearningIndexChatExtensionParameters.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/AzureMachineLearningIndexChatExtensionParameters.java index 422a6f87faa2..894b9dff2d64 100644 --- a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/AzureMachineLearningIndexChatExtensionParameters.java +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/AzureMachineLearningIndexChatExtensionParameters.java @@ -10,6 +10,7 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; +import java.util.List; /** * Parameters for the Azure Machine Learning vector index chat extension. The supported authentication types are @@ -291,6 +292,10 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeBooleanField("in_scope", this.inScope); jsonWriter.writeNumberField("strictness", this.strictness); jsonWriter.writeStringField("role_information", this.roleInformation); + jsonWriter.writeNumberField("max_search_queries", this.maxSearchQueries); + jsonWriter.writeBooleanField("allow_partial_result", this.allowPartialResult); + jsonWriter.writeArrayField("include_contexts", this.includeContexts, + (writer, element) -> writer.writeString(element == null ? null : element.toString())); jsonWriter.writeStringField("filter", this.filter); return jsonWriter.writeEndObject(); } @@ -315,6 +320,9 @@ public static AzureMachineLearningIndexChatExtensionParameters fromJson(JsonRead Boolean inScope = null; Integer strictness = null; String roleInformation = null; + Integer maxSearchQueries = null; + Boolean allowPartialResult = null; + List includeContexts = null; String filter = null; while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); @@ -335,6 +343,13 @@ public static AzureMachineLearningIndexChatExtensionParameters fromJson(JsonRead strictness = reader.getNullable(JsonReader::getInt); } else if ("role_information".equals(fieldName)) { roleInformation = reader.getString(); + } else if ("max_search_queries".equals(fieldName)) { + maxSearchQueries = reader.getNullable(JsonReader::getInt); + } else if ("allow_partial_result".equals(fieldName)) { + allowPartialResult = reader.getNullable(JsonReader::getBoolean); + } else if ("include_contexts".equals(fieldName)) { + includeContexts + = reader.readArray(reader1 -> OnYourDataContextProperty.fromString(reader1.getString())); } else if ("filter".equals(fieldName)) { filter = reader.getString(); } else { @@ -348,8 +363,109 @@ public static AzureMachineLearningIndexChatExtensionParameters fromJson(JsonRead deserializedAzureMachineLearningIndexChatExtensionParameters.inScope = inScope; deserializedAzureMachineLearningIndexChatExtensionParameters.strictness = strictness; deserializedAzureMachineLearningIndexChatExtensionParameters.roleInformation = roleInformation; + deserializedAzureMachineLearningIndexChatExtensionParameters.maxSearchQueries = maxSearchQueries; + deserializedAzureMachineLearningIndexChatExtensionParameters.allowPartialResult = allowPartialResult; + deserializedAzureMachineLearningIndexChatExtensionParameters.includeContexts = includeContexts; deserializedAzureMachineLearningIndexChatExtensionParameters.filter = filter; return deserializedAzureMachineLearningIndexChatExtensionParameters; }); } + + /* + * The max number of rewritten queries should be send to search provider for one user message. If not specified, + * the system will decide the number of queries to send. + */ + @Generated + private Integer maxSearchQueries; + + /* + * If specified as true, the system will allow partial search results to be used and the request fails if all the + * queries fail. + * If not specified, or specified as false, the request will fail if any search query fails. + */ + @Generated + private Boolean allowPartialResult; + + /* + * The included properties of the output context. If not specified, the default value is `citations` and `intent`. + */ + @Generated + private List includeContexts; + + /** + * Get the maxSearchQueries property: The max number of rewritten queries should be send to search provider for one + * user message. If not specified, + * the system will decide the number of queries to send. + * + * @return the maxSearchQueries value. + */ + @Generated + public Integer getMaxSearchQueries() { + return this.maxSearchQueries; + } + + /** + * Set the maxSearchQueries property: The max number of rewritten queries should be send to search provider for one + * user message. If not specified, + * the system will decide the number of queries to send. + * + * @param maxSearchQueries the maxSearchQueries value to set. + * @return the AzureMachineLearningIndexChatExtensionParameters object itself. + */ + @Generated + public AzureMachineLearningIndexChatExtensionParameters setMaxSearchQueries(Integer maxSearchQueries) { + this.maxSearchQueries = maxSearchQueries; + return this; + } + + /** + * Get the allowPartialResult property: If specified as true, the system will allow partial search results to be + * used and the request fails if all the queries fail. + * If not specified, or specified as false, the request will fail if any search query fails. + * + * @return the allowPartialResult value. + */ + @Generated + public Boolean isAllowPartialResult() { + return this.allowPartialResult; + } + + /** + * Set the allowPartialResult property: If specified as true, the system will allow partial search results to be + * used and the request fails if all the queries fail. + * If not specified, or specified as false, the request will fail if any search query fails. + * + * @param allowPartialResult the allowPartialResult value to set. + * @return the AzureMachineLearningIndexChatExtensionParameters object itself. + */ + @Generated + public AzureMachineLearningIndexChatExtensionParameters setAllowPartialResult(Boolean allowPartialResult) { + this.allowPartialResult = allowPartialResult; + return this; + } + + /** + * Get the includeContexts property: The included properties of the output context. If not specified, the default + * value is `citations` and `intent`. + * + * @return the includeContexts value. + */ + @Generated + public List getIncludeContexts() { + return this.includeContexts; + } + + /** + * Set the includeContexts property: The included properties of the output context. If not specified, the default + * value is `citations` and `intent`. + * + * @param includeContexts the includeContexts value to set. + * @return the AzureMachineLearningIndexChatExtensionParameters object itself. + */ + @Generated + public AzureMachineLearningIndexChatExtensionParameters + setIncludeContexts(List includeContexts) { + this.includeContexts = includeContexts; + return this; + } } diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/AzureSearchChatExtensionParameters.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/AzureSearchChatExtensionParameters.java index 5adcedf4cf18..8de44ef16ec3 100644 --- a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/AzureSearchChatExtensionParameters.java +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/AzureSearchChatExtensionParameters.java @@ -10,6 +10,7 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; +import java.util.List; /** * Parameters for Azure Cognitive Search when used as an Azure OpenAI chat extension. The supported authentication types @@ -382,6 +383,10 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeBooleanField("in_scope", this.inScope); jsonWriter.writeNumberField("strictness", this.strictness); jsonWriter.writeStringField("role_information", this.roleInformation); + jsonWriter.writeNumberField("max_search_queries", this.maxSearchQueries); + jsonWriter.writeBooleanField("allow_partial_result", this.allowPartialResult); + jsonWriter.writeArrayField("include_contexts", this.includeContexts, + (writer, element) -> writer.writeString(element == null ? null : element.toString())); jsonWriter.writeJsonField("fields_mapping", this.fieldsMapping); jsonWriter.writeStringField("query_type", this.queryType == null ? null : this.queryType.toString()); jsonWriter.writeStringField("semantic_configuration", this.semanticConfiguration); @@ -409,6 +414,9 @@ public static AzureSearchChatExtensionParameters fromJson(JsonReader jsonReader) Boolean inScope = null; Integer strictness = null; String roleInformation = null; + Integer maxSearchQueries = null; + Boolean allowPartialResult = null; + List includeContexts = null; AzureSearchIndexFieldMappingOptions fieldsMapping = null; AzureSearchQueryType queryType = null; String semanticConfiguration = null; @@ -431,6 +439,13 @@ public static AzureSearchChatExtensionParameters fromJson(JsonReader jsonReader) strictness = reader.getNullable(JsonReader::getInt); } else if ("role_information".equals(fieldName)) { roleInformation = reader.getString(); + } else if ("max_search_queries".equals(fieldName)) { + maxSearchQueries = reader.getNullable(JsonReader::getInt); + } else if ("allow_partial_result".equals(fieldName)) { + allowPartialResult = reader.getNullable(JsonReader::getBoolean); + } else if ("include_contexts".equals(fieldName)) { + includeContexts + = reader.readArray(reader1 -> OnYourDataContextProperty.fromString(reader1.getString())); } else if ("fields_mapping".equals(fieldName)) { fieldsMapping = AzureSearchIndexFieldMappingOptions.fromJson(reader); } else if ("query_type".equals(fieldName)) { @@ -452,6 +467,9 @@ public static AzureSearchChatExtensionParameters fromJson(JsonReader jsonReader) deserializedAzureSearchChatExtensionParameters.inScope = inScope; deserializedAzureSearchChatExtensionParameters.strictness = strictness; deserializedAzureSearchChatExtensionParameters.roleInformation = roleInformation; + deserializedAzureSearchChatExtensionParameters.maxSearchQueries = maxSearchQueries; + deserializedAzureSearchChatExtensionParameters.allowPartialResult = allowPartialResult; + deserializedAzureSearchChatExtensionParameters.includeContexts = includeContexts; deserializedAzureSearchChatExtensionParameters.fieldsMapping = fieldsMapping; deserializedAzureSearchChatExtensionParameters.queryType = queryType; deserializedAzureSearchChatExtensionParameters.semanticConfiguration = semanticConfiguration; @@ -460,4 +478,101 @@ public static AzureSearchChatExtensionParameters fromJson(JsonReader jsonReader) return deserializedAzureSearchChatExtensionParameters; }); } + + /* + * The max number of rewritten queries should be send to search provider for one user message. If not specified, + * the system will decide the number of queries to send. + */ + @Generated + private Integer maxSearchQueries; + + /* + * If specified as true, the system will allow partial search results to be used and the request fails if all the + * queries fail. + * If not specified, or specified as false, the request will fail if any search query fails. + */ + @Generated + private Boolean allowPartialResult; + + /* + * The included properties of the output context. If not specified, the default value is `citations` and `intent`. + */ + @Generated + private List includeContexts; + + /** + * Get the maxSearchQueries property: The max number of rewritten queries should be send to search provider for one + * user message. If not specified, + * the system will decide the number of queries to send. + * + * @return the maxSearchQueries value. + */ + @Generated + public Integer getMaxSearchQueries() { + return this.maxSearchQueries; + } + + /** + * Set the maxSearchQueries property: The max number of rewritten queries should be send to search provider for one + * user message. If not specified, + * the system will decide the number of queries to send. + * + * @param maxSearchQueries the maxSearchQueries value to set. + * @return the AzureSearchChatExtensionParameters object itself. + */ + @Generated + public AzureSearchChatExtensionParameters setMaxSearchQueries(Integer maxSearchQueries) { + this.maxSearchQueries = maxSearchQueries; + return this; + } + + /** + * Get the allowPartialResult property: If specified as true, the system will allow partial search results to be + * used and the request fails if all the queries fail. + * If not specified, or specified as false, the request will fail if any search query fails. + * + * @return the allowPartialResult value. + */ + @Generated + public Boolean isAllowPartialResult() { + return this.allowPartialResult; + } + + /** + * Set the allowPartialResult property: If specified as true, the system will allow partial search results to be + * used and the request fails if all the queries fail. + * If not specified, or specified as false, the request will fail if any search query fails. + * + * @param allowPartialResult the allowPartialResult value to set. + * @return the AzureSearchChatExtensionParameters object itself. + */ + @Generated + public AzureSearchChatExtensionParameters setAllowPartialResult(Boolean allowPartialResult) { + this.allowPartialResult = allowPartialResult; + return this; + } + + /** + * Get the includeContexts property: The included properties of the output context. If not specified, the default + * value is `citations` and `intent`. + * + * @return the includeContexts value. + */ + @Generated + public List getIncludeContexts() { + return this.includeContexts; + } + + /** + * Set the includeContexts property: The included properties of the output context. If not specified, the default + * value is `citations` and `intent`. + * + * @param includeContexts the includeContexts value to set. + * @return the AzureSearchChatExtensionParameters object itself. + */ + @Generated + public AzureSearchChatExtensionParameters setIncludeContexts(List includeContexts) { + this.includeContexts = includeContexts; + return this; + } } diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ElasticsearchChatExtensionParameters.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ElasticsearchChatExtensionParameters.java index 8a7a01072070..33e726548647 100644 --- a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ElasticsearchChatExtensionParameters.java +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ElasticsearchChatExtensionParameters.java @@ -10,6 +10,7 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; +import java.util.List; /** * Parameters to use when configuring Elasticsearch® as an Azure OpenAI chat extension. The supported authentication @@ -326,6 +327,10 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeBooleanField("in_scope", this.inScope); jsonWriter.writeNumberField("strictness", this.strictness); jsonWriter.writeStringField("role_information", this.roleInformation); + jsonWriter.writeNumberField("max_search_queries", this.maxSearchQueries); + jsonWriter.writeBooleanField("allow_partial_result", this.allowPartialResult); + jsonWriter.writeArrayField("include_contexts", this.includeContexts, + (writer, element) -> writer.writeString(element == null ? null : element.toString())); jsonWriter.writeJsonField("fields_mapping", this.fieldsMapping); jsonWriter.writeStringField("query_type", this.queryType == null ? null : this.queryType.toString()); jsonWriter.writeJsonField("embedding_dependency", this.embeddingDependency); @@ -351,6 +356,9 @@ public static ElasticsearchChatExtensionParameters fromJson(JsonReader jsonReade Boolean inScope = null; Integer strictness = null; String roleInformation = null; + Integer maxSearchQueries = null; + Boolean allowPartialResult = null; + List includeContexts = null; ElasticsearchIndexFieldMappingOptions fieldsMapping = null; ElasticsearchQueryType queryType = null; OnYourDataVectorizationSource embeddingDependency = null; @@ -371,6 +379,13 @@ public static ElasticsearchChatExtensionParameters fromJson(JsonReader jsonReade strictness = reader.getNullable(JsonReader::getInt); } else if ("role_information".equals(fieldName)) { roleInformation = reader.getString(); + } else if ("max_search_queries".equals(fieldName)) { + maxSearchQueries = reader.getNullable(JsonReader::getInt); + } else if ("allow_partial_result".equals(fieldName)) { + allowPartialResult = reader.getNullable(JsonReader::getBoolean); + } else if ("include_contexts".equals(fieldName)) { + includeContexts + = reader.readArray(reader1 -> OnYourDataContextProperty.fromString(reader1.getString())); } else if ("fields_mapping".equals(fieldName)) { fieldsMapping = ElasticsearchIndexFieldMappingOptions.fromJson(reader); } else if ("query_type".equals(fieldName)) { @@ -388,10 +403,110 @@ public static ElasticsearchChatExtensionParameters fromJson(JsonReader jsonReade deserializedElasticsearchChatExtensionParameters.inScope = inScope; deserializedElasticsearchChatExtensionParameters.strictness = strictness; deserializedElasticsearchChatExtensionParameters.roleInformation = roleInformation; + deserializedElasticsearchChatExtensionParameters.maxSearchQueries = maxSearchQueries; + deserializedElasticsearchChatExtensionParameters.allowPartialResult = allowPartialResult; + deserializedElasticsearchChatExtensionParameters.includeContexts = includeContexts; deserializedElasticsearchChatExtensionParameters.fieldsMapping = fieldsMapping; deserializedElasticsearchChatExtensionParameters.queryType = queryType; deserializedElasticsearchChatExtensionParameters.embeddingDependency = embeddingDependency; return deserializedElasticsearchChatExtensionParameters; }); } + + /* + * The max number of rewritten queries should be send to search provider for one user message. If not specified, + * the system will decide the number of queries to send. + */ + @Generated + private Integer maxSearchQueries; + + /* + * If specified as true, the system will allow partial search results to be used and the request fails if all the + * queries fail. + * If not specified, or specified as false, the request will fail if any search query fails. + */ + @Generated + private Boolean allowPartialResult; + + /* + * The included properties of the output context. If not specified, the default value is `citations` and `intent`. + */ + @Generated + private List includeContexts; + + /** + * Get the maxSearchQueries property: The max number of rewritten queries should be send to search provider for one + * user message. If not specified, + * the system will decide the number of queries to send. + * + * @return the maxSearchQueries value. + */ + @Generated + public Integer getMaxSearchQueries() { + return this.maxSearchQueries; + } + + /** + * Set the maxSearchQueries property: The max number of rewritten queries should be send to search provider for one + * user message. If not specified, + * the system will decide the number of queries to send. + * + * @param maxSearchQueries the maxSearchQueries value to set. + * @return the ElasticsearchChatExtensionParameters object itself. + */ + @Generated + public ElasticsearchChatExtensionParameters setMaxSearchQueries(Integer maxSearchQueries) { + this.maxSearchQueries = maxSearchQueries; + return this; + } + + /** + * Get the allowPartialResult property: If specified as true, the system will allow partial search results to be + * used and the request fails if all the queries fail. + * If not specified, or specified as false, the request will fail if any search query fails. + * + * @return the allowPartialResult value. + */ + @Generated + public Boolean isAllowPartialResult() { + return this.allowPartialResult; + } + + /** + * Set the allowPartialResult property: If specified as true, the system will allow partial search results to be + * used and the request fails if all the queries fail. + * If not specified, or specified as false, the request will fail if any search query fails. + * + * @param allowPartialResult the allowPartialResult value to set. + * @return the ElasticsearchChatExtensionParameters object itself. + */ + @Generated + public ElasticsearchChatExtensionParameters setAllowPartialResult(Boolean allowPartialResult) { + this.allowPartialResult = allowPartialResult; + return this; + } + + /** + * Get the includeContexts property: The included properties of the output context. If not specified, the default + * value is `citations` and `intent`. + * + * @return the includeContexts value. + */ + @Generated + public List getIncludeContexts() { + return this.includeContexts; + } + + /** + * Set the includeContexts property: The included properties of the output context. If not specified, the default + * value is `citations` and `intent`. + * + * @param includeContexts the includeContexts value to set. + * @return the ElasticsearchChatExtensionParameters object itself. + */ + @Generated + public ElasticsearchChatExtensionParameters setIncludeContexts(List includeContexts) { + this.includeContexts = includeContexts; + return this; + } } diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ImageGenerationPromptFilterResults.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ImageGenerationPromptFilterResults.java index 1e0c0fba43cf..23e20f5c8eab 100644 --- a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ImageGenerationPromptFilterResults.java +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ImageGenerationPromptFilterResults.java @@ -151,6 +151,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeJsonField("self_harm", this.selfHarm); jsonWriter.writeJsonField("profanity", this.profanity); jsonWriter.writeJsonField("jailbreak", this.jailbreak); + jsonWriter.writeJsonField("custom_blocklists", this.customBlocklists); return jsonWriter.writeEndObject(); } @@ -184,6 +185,9 @@ public static ImageGenerationPromptFilterResults fromJson(JsonReader jsonReader) } else if ("jailbreak".equals(fieldName)) { deserializedImageGenerationPromptFilterResults.jailbreak = ContentFilterDetectionResult.fromJson(reader); + } else if ("custom_blocklists".equals(fieldName)) { + deserializedImageGenerationPromptFilterResults.customBlocklists + = ContentFilterDetailedResults.fromJson(reader); } else { reader.skipChildren(); } @@ -191,4 +195,21 @@ public static ImageGenerationPromptFilterResults fromJson(JsonReader jsonReader) return deserializedImageGenerationPromptFilterResults; }); } + + /* + * Information about customer block lists and if something was detected the associated list ID. + */ + @Generated + private ContentFilterDetailedResults customBlocklists; + + /** + * Get the customBlocklists property: Information about customer block lists and if something was detected the + * associated list ID. + * + * @return the customBlocklists value. + */ + @Generated + public ContentFilterDetailedResults getCustomBlocklists() { + return this.customBlocklists; + } } diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataContextProperty.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataContextProperty.java new file mode 100644 index 000000000000..b26178783571 --- /dev/null +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataContextProperty.java @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.openai.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The context property. + */ +public final class OnYourDataContextProperty extends ExpandableStringEnum { + /** + * The `citations` property. + */ + @Generated + public static final OnYourDataContextProperty CITATIONS = fromString("citations"); + + /** + * The `intent` property. + */ + @Generated + public static final OnYourDataContextProperty INTENT = fromString("intent"); + + /** + * The `all_retrieved_documents` property. + */ + @Generated + public static final OnYourDataContextProperty ALL_RETRIEVED_DOCUMENTS = fromString("all_retrieved_documents"); + + /** + * Creates a new instance of OnYourDataContextProperty value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public OnYourDataContextProperty() { + } + + /** + * Creates or finds a OnYourDataContextProperty from its string representation. + * + * @param name a name to look for. + * @return the corresponding OnYourDataContextProperty. + */ + @Generated + public static OnYourDataContextProperty fromString(String name) { + return fromString(name, OnYourDataContextProperty.class); + } + + /** + * Gets known OnYourDataContextProperty values. + * + * @return known OnYourDataContextProperty values. + */ + @Generated + public static Collection values() { + return values(OnYourDataContextProperty.class); + } +} diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataDeploymentNameVectorizationSource.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataDeploymentNameVectorizationSource.java index 7006488046c6..42d2e3a5704b 100644 --- a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataDeploymentNameVectorizationSource.java +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataDeploymentNameVectorizationSource.java @@ -3,8 +3,8 @@ // Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.ai.openai.models; +import com.azure.core.annotation.Fluent; import com.azure.core.annotation.Generated; -import com.azure.core.annotation.Immutable; import com.azure.json.JsonReader; import com.azure.json.JsonToken; import com.azure.json.JsonWriter; @@ -14,7 +14,7 @@ * The details of a a vectorization source, used by Azure OpenAI On Your Data when applying vector search, that is based * on an internal embeddings model deployment name in the same Azure OpenAI resource. */ -@Immutable +@Fluent public final class OnYourDataDeploymentNameVectorizationSource extends OnYourDataVectorizationSource { /* @@ -71,6 +71,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStartObject(); jsonWriter.writeStringField("deployment_name", this.deploymentName); jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + jsonWriter.writeNumberField("dimensions", this.dimensions); return jsonWriter.writeEndObject(); } @@ -88,6 +89,7 @@ public static OnYourDataDeploymentNameVectorizationSource fromJson(JsonReader js return jsonReader.readObject(reader -> { String deploymentName = null; OnYourDataVectorizationSourceType type = OnYourDataVectorizationSourceType.DEPLOYMENT_NAME; + Integer dimensions = null; while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); @@ -95,6 +97,8 @@ public static OnYourDataDeploymentNameVectorizationSource fromJson(JsonReader js deploymentName = reader.getString(); } else if ("type".equals(fieldName)) { type = OnYourDataVectorizationSourceType.fromString(reader.getString()); + } else if ("dimensions".equals(fieldName)) { + dimensions = reader.getNullable(JsonReader::getInt); } else { reader.skipChildren(); } @@ -102,7 +106,38 @@ public static OnYourDataDeploymentNameVectorizationSource fromJson(JsonReader js OnYourDataDeploymentNameVectorizationSource deserializedOnYourDataDeploymentNameVectorizationSource = new OnYourDataDeploymentNameVectorizationSource(deploymentName); deserializedOnYourDataDeploymentNameVectorizationSource.type = type; + deserializedOnYourDataDeploymentNameVectorizationSource.dimensions = dimensions; return deserializedOnYourDataDeploymentNameVectorizationSource; }); } + + /* + * The number of dimensions the embeddings should have. Only supported in `text-embedding-3` and later models. + */ + @Generated + private Integer dimensions; + + /** + * Get the dimensions property: The number of dimensions the embeddings should have. Only supported in + * `text-embedding-3` and later models. + * + * @return the dimensions value. + */ + @Generated + public Integer getDimensions() { + return this.dimensions; + } + + /** + * Set the dimensions property: The number of dimensions the embeddings should have. Only supported in + * `text-embedding-3` and later models. + * + * @param dimensions the dimensions value to set. + * @return the OnYourDataDeploymentNameVectorizationSource object itself. + */ + @Generated + public OnYourDataDeploymentNameVectorizationSource setDimensions(Integer dimensions) { + this.dimensions = dimensions; + return this; + } } diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataEndpointVectorizationSource.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataEndpointVectorizationSource.java index 5f14fdf04a61..2a056511c943 100644 --- a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataEndpointVectorizationSource.java +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataEndpointVectorizationSource.java @@ -29,19 +29,7 @@ public final class OnYourDataEndpointVectorizationSource extends OnYourDataVecto * Specifies the authentication options to use when retrieving embeddings from the specified endpoint. */ @Generated - private final OnYourDataAuthenticationOptions authentication; - - /** - * Creates an instance of OnYourDataEndpointVectorizationSource class. - * - * @param endpoint the endpoint value to set. - * @param authentication the authentication value to set. - */ - @Generated - public OnYourDataEndpointVectorizationSource(String endpoint, OnYourDataAuthenticationOptions authentication) { - this.endpoint = endpoint; - this.authentication = authentication; - } + private final OnYourDataVectorSearchAuthenticationOptions authentication; /** * Get the endpoint property: Specifies the resource endpoint URL from which embeddings should be retrieved. It @@ -63,7 +51,7 @@ public String getEndpoint() { * @return the authentication value. */ @Generated - public OnYourDataAuthenticationOptions getAuthentication() { + public OnYourDataVectorSearchAuthenticationOptions getAuthentication() { return this.authentication; } @@ -110,7 +98,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { public static OnYourDataEndpointVectorizationSource fromJson(JsonReader jsonReader) throws IOException { return jsonReader.readObject(reader -> { String endpoint = null; - OnYourDataAuthenticationOptions authentication = null; + OnYourDataVectorSearchAuthenticationOptions authentication = null; OnYourDataVectorizationSourceType type = OnYourDataVectorizationSourceType.ENDPOINT; while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); @@ -118,7 +106,7 @@ public static OnYourDataEndpointVectorizationSource fromJson(JsonReader jsonRead if ("endpoint".equals(fieldName)) { endpoint = reader.getString(); } else if ("authentication".equals(fieldName)) { - authentication = OnYourDataAuthenticationOptions.fromJson(reader); + authentication = OnYourDataVectorSearchAuthenticationOptions.fromJson(reader); } else if ("type".equals(fieldName)) { type = OnYourDataVectorizationSourceType.fromString(reader.getString()); } else { @@ -131,4 +119,17 @@ public static OnYourDataEndpointVectorizationSource fromJson(JsonReader jsonRead return deserializedOnYourDataEndpointVectorizationSource; }); } + + /** + * Creates an instance of OnYourDataEndpointVectorizationSource class. + * + * @param endpoint the endpoint value to set. + * @param authentication the authentication value to set. + */ + @Generated + public OnYourDataEndpointVectorizationSource(String endpoint, + OnYourDataVectorSearchAuthenticationOptions authentication) { + this.endpoint = endpoint; + this.authentication = authentication; + } } diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataVectorSearchAccessTokenAuthenticationOptions.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataVectorSearchAccessTokenAuthenticationOptions.java new file mode 100644 index 000000000000..0e099ed1953a --- /dev/null +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataVectorSearchAccessTokenAuthenticationOptions.java @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.openai.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The authentication options for Azure OpenAI On Your Data vector search when using access token. + */ +@Immutable +public final class OnYourDataVectorSearchAccessTokenAuthenticationOptions + extends OnYourDataVectorSearchAuthenticationOptions { + /* + * The type of authentication to use. + */ + @Generated + private OnYourDataVectorSearchAuthenticationType type = OnYourDataVectorSearchAuthenticationType.ACCESS_TOKEN; + + /* + * The access token to use for authentication. + */ + @Generated + private final String accessToken; + + /** + * Creates an instance of OnYourDataVectorSearchAccessTokenAuthenticationOptions class. + * + * @param accessToken the accessToken value to set. + */ + @Generated + public OnYourDataVectorSearchAccessTokenAuthenticationOptions(String accessToken) { + this.accessToken = accessToken; + } + + /** + * Get the type property: The type of authentication to use. + * + * @return the type value. + */ + @Generated + @Override + public OnYourDataVectorSearchAuthenticationType getType() { + return this.type; + } + + /** + * Get the accessToken property: The access token to use for authentication. + * + * @return the accessToken value. + */ + @Generated + public String getAccessToken() { + return this.accessToken; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("access_token", this.accessToken); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OnYourDataVectorSearchAccessTokenAuthenticationOptions from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OnYourDataVectorSearchAccessTokenAuthenticationOptions if the JsonReader was pointing to + * an instance of it, or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the OnYourDataVectorSearchAccessTokenAuthenticationOptions. + */ + @Generated + public static OnYourDataVectorSearchAccessTokenAuthenticationOptions fromJson(JsonReader jsonReader) + throws IOException { + return jsonReader.readObject(reader -> { + String accessToken = null; + OnYourDataVectorSearchAuthenticationType type = OnYourDataVectorSearchAuthenticationType.ACCESS_TOKEN; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("access_token".equals(fieldName)) { + accessToken = reader.getString(); + } else if ("type".equals(fieldName)) { + type = OnYourDataVectorSearchAuthenticationType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + OnYourDataVectorSearchAccessTokenAuthenticationOptions deserializedOnYourDataVectorSearchAccessTokenAuthenticationOptions + = new OnYourDataVectorSearchAccessTokenAuthenticationOptions(accessToken); + deserializedOnYourDataVectorSearchAccessTokenAuthenticationOptions.type = type; + + return deserializedOnYourDataVectorSearchAccessTokenAuthenticationOptions; + }); + } +} diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataVectorSearchApiKeyAuthenticationOptions.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataVectorSearchApiKeyAuthenticationOptions.java new file mode 100644 index 000000000000..0f8fa32f523d --- /dev/null +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataVectorSearchApiKeyAuthenticationOptions.java @@ -0,0 +1,108 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.openai.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The authentication options for Azure OpenAI On Your Data when using an API key. + */ +@Immutable +public final class OnYourDataVectorSearchApiKeyAuthenticationOptions + extends OnYourDataVectorSearchAuthenticationOptions { + /* + * The type of authentication to use. + */ + @Generated + private OnYourDataVectorSearchAuthenticationType type = OnYourDataVectorSearchAuthenticationType.API_KEY; + + /* + * The API key to use for authentication. + */ + @Generated + private final String key; + + /** + * Creates an instance of OnYourDataVectorSearchApiKeyAuthenticationOptions class. + * + * @param key the key value to set. + */ + @Generated + public OnYourDataVectorSearchApiKeyAuthenticationOptions(String key) { + this.key = key; + } + + /** + * Get the type property: The type of authentication to use. + * + * @return the type value. + */ + @Generated + @Override + public OnYourDataVectorSearchAuthenticationType getType() { + return this.type; + } + + /** + * Get the key property: The API key to use for authentication. + * + * @return the key value. + */ + @Generated + public String getKey() { + return this.key; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("key", this.key); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OnYourDataVectorSearchApiKeyAuthenticationOptions from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OnYourDataVectorSearchApiKeyAuthenticationOptions if the JsonReader was pointing to an + * instance of it, or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the OnYourDataVectorSearchApiKeyAuthenticationOptions. + */ + @Generated + public static OnYourDataVectorSearchApiKeyAuthenticationOptions fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String key = null; + OnYourDataVectorSearchAuthenticationType type = OnYourDataVectorSearchAuthenticationType.API_KEY; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("key".equals(fieldName)) { + key = reader.getString(); + } else if ("type".equals(fieldName)) { + type = OnYourDataVectorSearchAuthenticationType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + OnYourDataVectorSearchApiKeyAuthenticationOptions deserializedOnYourDataVectorSearchApiKeyAuthenticationOptions + = new OnYourDataVectorSearchApiKeyAuthenticationOptions(key); + deserializedOnYourDataVectorSearchApiKeyAuthenticationOptions.type = type; + + return deserializedOnYourDataVectorSearchApiKeyAuthenticationOptions; + }); + } +} diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataVectorSearchAuthenticationOptions.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataVectorSearchAuthenticationOptions.java new file mode 100644 index 000000000000..38a587a1d0a2 --- /dev/null +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataVectorSearchAuthenticationOptions.java @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.openai.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The authentication options for Azure OpenAI On Your Data vector search. + */ +@Immutable +public class OnYourDataVectorSearchAuthenticationOptions + implements JsonSerializable { + /* + * The type of authentication to use. + */ + @Generated + private OnYourDataVectorSearchAuthenticationType type; + + /** + * Creates an instance of OnYourDataVectorSearchAuthenticationOptions class. + */ + @Generated + public OnYourDataVectorSearchAuthenticationOptions() { + this.type = OnYourDataVectorSearchAuthenticationType.fromString("OnYourDataVectorSearchAuthenticationOptions"); + } + + /** + * Get the type property: The type of authentication to use. + * + * @return the type value. + */ + @Generated + public OnYourDataVectorSearchAuthenticationType getType() { + return this.type; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OnYourDataVectorSearchAuthenticationOptions from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OnYourDataVectorSearchAuthenticationOptions if the JsonReader was pointing to an instance + * of it, or null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the OnYourDataVectorSearchAuthenticationOptions. + */ + @Generated + public static OnYourDataVectorSearchAuthenticationOptions fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + readerToUse.nextToken(); // Prepare for reading + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("type".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("api_key".equals(discriminatorValue)) { + return OnYourDataVectorSearchApiKeyAuthenticationOptions.fromJson(readerToUse.reset()); + } else if ("access_token".equals(discriminatorValue)) { + return OnYourDataVectorSearchAccessTokenAuthenticationOptions.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static OnYourDataVectorSearchAuthenticationOptions fromJsonKnownDiscriminator(JsonReader jsonReader) + throws IOException { + return jsonReader.readObject(reader -> { + OnYourDataVectorSearchAuthenticationOptions deserializedOnYourDataVectorSearchAuthenticationOptions + = new OnYourDataVectorSearchAuthenticationOptions(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("type".equals(fieldName)) { + deserializedOnYourDataVectorSearchAuthenticationOptions.type + = OnYourDataVectorSearchAuthenticationType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedOnYourDataVectorSearchAuthenticationOptions; + }); + } +} diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataVectorSearchAuthenticationType.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataVectorSearchAuthenticationType.java new file mode 100644 index 000000000000..b4e6fb1eba2c --- /dev/null +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataVectorSearchAuthenticationType.java @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.openai.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The authentication types supported with Azure OpenAI On Your Data vector search. + */ +public final class OnYourDataVectorSearchAuthenticationType + extends ExpandableStringEnum { + /** + * Authentication via API key. + */ + @Generated + public static final OnYourDataVectorSearchAuthenticationType API_KEY = fromString("api_key"); + + /** + * Authentication via access token. + */ + @Generated + public static final OnYourDataVectorSearchAuthenticationType ACCESS_TOKEN = fromString("access_token"); + + /** + * Creates a new instance of OnYourDataVectorSearchAuthenticationType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public OnYourDataVectorSearchAuthenticationType() { + } + + /** + * Creates or finds a OnYourDataVectorSearchAuthenticationType from its string representation. + * + * @param name a name to look for. + * @return the corresponding OnYourDataVectorSearchAuthenticationType. + */ + @Generated + public static OnYourDataVectorSearchAuthenticationType fromString(String name) { + return fromString(name, OnYourDataVectorSearchAuthenticationType.class); + } + + /** + * Gets known OnYourDataVectorSearchAuthenticationType values. + * + * @return known OnYourDataVectorSearchAuthenticationType values. + */ + @Generated + public static Collection values() { + return values(OnYourDataVectorSearchAuthenticationType.class); + } +} diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/PineconeChatExtensionParameters.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/PineconeChatExtensionParameters.java index bccc91a1b3a9..46bd8570f19e 100644 --- a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/PineconeChatExtensionParameters.java +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/PineconeChatExtensionParameters.java @@ -10,6 +10,7 @@ import com.azure.json.JsonToken; import com.azure.json.JsonWriter; import java.io.IOException; +import java.util.List; /** * Parameters for configuring Azure OpenAI Pinecone chat extensions. The supported authentication type is APIKey. @@ -278,6 +279,10 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeBooleanField("in_scope", this.inScope); jsonWriter.writeNumberField("strictness", this.strictness); jsonWriter.writeStringField("role_information", this.roleInformation); + jsonWriter.writeNumberField("max_search_queries", this.maxSearchQueries); + jsonWriter.writeBooleanField("allow_partial_result", this.allowPartialResult); + jsonWriter.writeArrayField("include_contexts", this.includeContexts, + (writer, element) -> writer.writeString(element == null ? null : element.toString())); return jsonWriter.writeEndObject(); } @@ -302,6 +307,9 @@ public static PineconeChatExtensionParameters fromJson(JsonReader jsonReader) th Boolean inScope = null; Integer strictness = null; String roleInformation = null; + Integer maxSearchQueries = null; + Boolean allowPartialResult = null; + List includeContexts = null; while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); @@ -323,6 +331,13 @@ public static PineconeChatExtensionParameters fromJson(JsonReader jsonReader) th strictness = reader.getNullable(JsonReader::getInt); } else if ("role_information".equals(fieldName)) { roleInformation = reader.getString(); + } else if ("max_search_queries".equals(fieldName)) { + maxSearchQueries = reader.getNullable(JsonReader::getInt); + } else if ("allow_partial_result".equals(fieldName)) { + allowPartialResult = reader.getNullable(JsonReader::getBoolean); + } else if ("include_contexts".equals(fieldName)) { + includeContexts + = reader.readArray(reader1 -> OnYourDataContextProperty.fromString(reader1.getString())); } else { reader.skipChildren(); } @@ -334,7 +349,107 @@ public static PineconeChatExtensionParameters fromJson(JsonReader jsonReader) th deserializedPineconeChatExtensionParameters.inScope = inScope; deserializedPineconeChatExtensionParameters.strictness = strictness; deserializedPineconeChatExtensionParameters.roleInformation = roleInformation; + deserializedPineconeChatExtensionParameters.maxSearchQueries = maxSearchQueries; + deserializedPineconeChatExtensionParameters.allowPartialResult = allowPartialResult; + deserializedPineconeChatExtensionParameters.includeContexts = includeContexts; return deserializedPineconeChatExtensionParameters; }); } + + /* + * The max number of rewritten queries should be send to search provider for one user message. If not specified, + * the system will decide the number of queries to send. + */ + @Generated + private Integer maxSearchQueries; + + /* + * If specified as true, the system will allow partial search results to be used and the request fails if all the + * queries fail. + * If not specified, or specified as false, the request will fail if any search query fails. + */ + @Generated + private Boolean allowPartialResult; + + /* + * The included properties of the output context. If not specified, the default value is `citations` and `intent`. + */ + @Generated + private List includeContexts; + + /** + * Get the maxSearchQueries property: The max number of rewritten queries should be send to search provider for one + * user message. If not specified, + * the system will decide the number of queries to send. + * + * @return the maxSearchQueries value. + */ + @Generated + public Integer getMaxSearchQueries() { + return this.maxSearchQueries; + } + + /** + * Set the maxSearchQueries property: The max number of rewritten queries should be send to search provider for one + * user message. If not specified, + * the system will decide the number of queries to send. + * + * @param maxSearchQueries the maxSearchQueries value to set. + * @return the PineconeChatExtensionParameters object itself. + */ + @Generated + public PineconeChatExtensionParameters setMaxSearchQueries(Integer maxSearchQueries) { + this.maxSearchQueries = maxSearchQueries; + return this; + } + + /** + * Get the allowPartialResult property: If specified as true, the system will allow partial search results to be + * used and the request fails if all the queries fail. + * If not specified, or specified as false, the request will fail if any search query fails. + * + * @return the allowPartialResult value. + */ + @Generated + public Boolean isAllowPartialResult() { + return this.allowPartialResult; + } + + /** + * Set the allowPartialResult property: If specified as true, the system will allow partial search results to be + * used and the request fails if all the queries fail. + * If not specified, or specified as false, the request will fail if any search query fails. + * + * @param allowPartialResult the allowPartialResult value to set. + * @return the PineconeChatExtensionParameters object itself. + */ + @Generated + public PineconeChatExtensionParameters setAllowPartialResult(Boolean allowPartialResult) { + this.allowPartialResult = allowPartialResult; + return this; + } + + /** + * Get the includeContexts property: The included properties of the output context. If not specified, the default + * value is `citations` and `intent`. + * + * @return the includeContexts value. + */ + @Generated + public List getIncludeContexts() { + return this.includeContexts; + } + + /** + * Set the includeContexts property: The included properties of the output context. If not specified, the default + * value is `citations` and `intent`. + * + * @param includeContexts the includeContexts value to set. + * @return the PineconeChatExtensionParameters object itself. + */ + @Generated + public PineconeChatExtensionParameters setIncludeContexts(List includeContexts) { + this.includeContexts = includeContexts; + return this; + } } diff --git a/sdk/openai/azure-ai-openai/src/main/resources/META-INF/azure-ai-openai_apiview_properties.json b/sdk/openai/azure-ai-openai/src/main/resources/META-INF/azure-ai-openai_apiview_properties.json index 86eb054f57b0..4b3970714a61 100644 --- a/sdk/openai/azure-ai-openai/src/main/resources/META-INF/azure-ai-openai_apiview_properties.json +++ b/sdk/openai/azure-ai-openai/src/main/resources/META-INF/azure-ai-openai_apiview_properties.json @@ -56,6 +56,8 @@ "com.azure.ai.openai.models.AzureChatEnhancements": "Azure.OpenAI.AzureChatEnhancements", "com.azure.ai.openai.models.AzureChatExtensionConfiguration": "Azure.OpenAI.AzureChatExtensionConfiguration", "com.azure.ai.openai.models.AzureChatExtensionDataSourceResponseCitation": "Azure.OpenAI.AzureChatExtensionDataSourceResponseCitation", + "com.azure.ai.openai.models.AzureChatExtensionRetrieveDocumentFilterReason": "Azure.OpenAI.AzureChatExtensionRetrieveDocumentFilterReason", + "com.azure.ai.openai.models.AzureChatExtensionRetrievedDocument": "Azure.OpenAI.AzureChatExtensionRetrievedDocument", "com.azure.ai.openai.models.AzureChatExtensionType": "Azure.OpenAI.AzureChatExtensionType", "com.azure.ai.openai.models.AzureChatExtensionsMessageContext": "Azure.OpenAI.AzureChatExtensionsMessageContext", "com.azure.ai.openai.models.AzureChatGroundingEnhancementConfiguration": "Azure.OpenAI.AzureChatGroundingEnhancementConfiguration", @@ -147,6 +149,7 @@ "com.azure.ai.openai.models.OnYourDataAuthenticationOptions": "Azure.OpenAI.OnYourDataAuthenticationOptions", "com.azure.ai.openai.models.OnYourDataAuthenticationType": "Azure.OpenAI.OnYourDataAuthenticationType", "com.azure.ai.openai.models.OnYourDataConnectionStringAuthenticationOptions": "Azure.OpenAI.OnYourDataConnectionStringAuthenticationOptions", + "com.azure.ai.openai.models.OnYourDataContextProperty": "Azure.OpenAI.OnYourDataContextProperty", "com.azure.ai.openai.models.OnYourDataDeploymentNameVectorizationSource": "Azure.OpenAI.OnYourDataDeploymentNameVectorizationSource", "com.azure.ai.openai.models.OnYourDataEncodedApiKeyAuthenticationOptions": "Azure.OpenAI.OnYourDataEncodedApiKeyAuthenticationOptions", "com.azure.ai.openai.models.OnYourDataEndpointVectorizationSource": "Azure.OpenAI.OnYourDataEndpointVectorizationSource", @@ -154,6 +157,10 @@ "com.azure.ai.openai.models.OnYourDataModelIdVectorizationSource": "Azure.OpenAI.OnYourDataModelIdVectorizationSource", "com.azure.ai.openai.models.OnYourDataSystemAssignedManagedIdentityAuthenticationOptions": "Azure.OpenAI.OnYourDataSystemAssignedManagedIdentityAuthenticationOptions", "com.azure.ai.openai.models.OnYourDataUserAssignedManagedIdentityAuthenticationOptions": "Azure.OpenAI.OnYourDataUserAssignedManagedIdentityAuthenticationOptions", + "com.azure.ai.openai.models.OnYourDataVectorSearchAccessTokenAuthenticationOptions": "Azure.OpenAI.OnYourDataVectorSearchAccessTokenAuthenticationOptions", + "com.azure.ai.openai.models.OnYourDataVectorSearchApiKeyAuthenticationOptions": "Azure.OpenAI.OnYourDataVectorSearchApiKeyAuthenticationOptions", + "com.azure.ai.openai.models.OnYourDataVectorSearchAuthenticationOptions": "Azure.OpenAI.OnYourDataVectorSearchAuthenticationOptions", + "com.azure.ai.openai.models.OnYourDataVectorSearchAuthenticationType": "Azure.OpenAI.OnYourDataVectorSearchAuthenticationType", "com.azure.ai.openai.models.OnYourDataVectorizationSource": "Azure.OpenAI.OnYourDataVectorizationSource", "com.azure.ai.openai.models.OnYourDataVectorizationSourceType": "Azure.OpenAI.OnYourDataVectorizationSourceType", "com.azure.ai.openai.models.PineconeChatExtensionConfiguration": "Azure.OpenAI.PineconeChatExtensionConfiguration", diff --git a/sdk/openai/azure-ai-openai/tsp-location.yaml b/sdk/openai/azure-ai-openai/tsp-location.yaml index 78d1c954f7f0..77aa0ac51754 100644 --- a/sdk/openai/azure-ai-openai/tsp-location.yaml +++ b/sdk/openai/azure-ai-openai/tsp-location.yaml @@ -1,5 +1,5 @@ directory: specification/cognitiveservices/OpenAI.Inference additionalDirectories: - specification/cognitiveservices/OpenAI.Authoring -commit: 38749f76f08fd434885ce198b167c65058ab79f1 +commit: 572dee40c3841583617078423ef47cd2042ffd55 repo: Azure/azure-rest-api-specs From 1cdbb42431e0929b70f517faf5691418a33c45bc Mon Sep 17 00:00:00 2001 From: Shawn Fang Date: Tue, 21 May 2024 15:53:54 -0700 Subject: [PATCH 2/7] revert the changes from last merged and unreleased changes based on 2024-04-01-preview --- sdk/openai/azure-ai-openai/assets.json | 2 +- .../azure/ai/openai/models/ChatCompletionsOptions.java | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/sdk/openai/azure-ai-openai/assets.json b/sdk/openai/azure-ai-openai/assets.json index 5ade4481ff33..62611939b82a 100644 --- a/sdk/openai/azure-ai-openai/assets.json +++ b/sdk/openai/azure-ai-openai/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "java", "TagPrefix": "java/openai/azure-ai-openai", - "Tag": "java/openai/azure-ai-openai_589fab4377" + "Tag": "java/openai/azure-ai-openai_4a8899256e" } diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ChatCompletionsOptions.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ChatCompletionsOptions.java index 4c28b127dd95..5087390c7bcd 100644 --- a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ChatCompletionsOptions.java +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ChatCompletionsOptions.java @@ -3,6 +3,7 @@ // Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.ai.openai.models; +import com.azure.ai.openai.implementation.models.FunctionCallPreset; import com.azure.core.annotation.Fluent; import com.azure.core.annotation.Generated; import com.azure.core.util.BinaryData; @@ -536,7 +537,13 @@ public FunctionCallConfig getFunctionCall() { */ public ChatCompletionsOptions setFunctionCall(FunctionCallConfig functionCallConfig) { this.functionCallConfig = functionCallConfig; - this.functionCall = BinaryData.fromObject(new FunctionName(this.functionCallConfig.getName())); + if (FunctionCallPreset.values() + .stream() + .anyMatch(preset -> preset.toString().equals(functionCallConfig.getName()))) { + this.functionCall = BinaryData.fromObject(FunctionCallPreset.fromString(this.functionCallConfig.getName())); + } else { + this.functionCall = BinaryData.fromObject(new FunctionName(this.functionCallConfig.getName())); + } return this; } From adecff8ac1c7fb7b56c00dc221b9dca9ed07b0cb Mon Sep 17 00:00:00 2001 From: Shawn Fang Date: Tue, 21 May 2024 18:05:35 -0700 Subject: [PATCH 3/7] draft --- .../com/azure/ai/openai/NonAzureOpenAIAsyncClientTest.java | 4 ++-- .../com/azure/ai/openai/NonAzureOpenAISyncClientTest.java | 4 ++-- .../test/java/com/azure/ai/openai/OpenAIAsyncClientTest.java | 4 ++-- .../test/java/com/azure/ai/openai/OpenAIClientTestBase.java | 2 ++ .../test/java/com/azure/ai/openai/OpenAISyncClientTest.java | 4 ++-- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/NonAzureOpenAIAsyncClientTest.java b/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/NonAzureOpenAIAsyncClientTest.java index 8373b7a1446d..a823a39239b5 100644 --- a/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/NonAzureOpenAIAsyncClientTest.java +++ b/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/NonAzureOpenAIAsyncClientTest.java @@ -300,7 +300,7 @@ public void testChatFunctionAutoPreset(HttpClient httpClient, OpenAIServiceVersi ChatChoice chatChoice = chatCompletions.getChoices().get(0); MyFunctionCallArguments arguments = assertFunctionCall( chatChoice, - "MyFunction", + "Sanitized", MyFunctionCallArguments.class); assertTrue(arguments.getLocation().contains("San Francisco")); assertEquals(arguments.getUnit(), "CELSIUS"); @@ -756,7 +756,7 @@ public void testGetChatCompletionsToolCall(HttpClient httpClient, OpenAIServiceV ChatCompletionsFunctionToolCall functionToolCall = (ChatCompletionsFunctionToolCall) responseMessage.getToolCalls().get(0); assertNotNull(functionToolCall); - assertEquals(functionToolCall.getFunction().getName(), "FutureTemperature"); // see base class + assertEquals(functionToolCall.getFunction().getName(), "Sanitized"); // see base class assertFalse(functionToolCall.getFunction().getArguments() == null || functionToolCall.getFunction().getArguments().isEmpty()); return client.getChatCompletions(modelId, getChatCompletionsOptionWithToolCallFollowUp( diff --git a/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/NonAzureOpenAISyncClientTest.java b/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/NonAzureOpenAISyncClientTest.java index 89627ffcadd7..dc958f4457c1 100644 --- a/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/NonAzureOpenAISyncClientTest.java +++ b/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/NonAzureOpenAISyncClientTest.java @@ -255,7 +255,7 @@ public void testChatFunctionAutoPreset(HttpClient httpClient, OpenAIServiceVersi ChatChoice chatChoice = chatCompletions.getChoices().get(0); MyFunctionCallArguments arguments = assertFunctionCall( chatChoice, - "MyFunction", + "Sanitized", MyFunctionCallArguments.class); assertTrue(arguments.getLocation().contains("San Francisco")); assertEquals(arguments.getUnit(), "CELSIUS"); @@ -681,7 +681,7 @@ public void testGetChatCompletionsToolCall(HttpClient httpClient, OpenAIServiceV ChatCompletionsFunctionToolCall functionToolCall = (ChatCompletionsFunctionToolCall) responseMessage.getToolCalls().get(0); assertNotNull(functionToolCall); - assertEquals(functionToolCall.getFunction().getName(), "FutureTemperature"); // see base class + assertEquals(functionToolCall.getFunction().getName(), "Sanitized"); assertFalse(functionToolCall.getFunction().getArguments() == null || functionToolCall.getFunction().getArguments().isEmpty()); diff --git a/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAIAsyncClientTest.java b/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAIAsyncClientTest.java index d84cdcc74595..3933bb524dd6 100644 --- a/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAIAsyncClientTest.java +++ b/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAIAsyncClientTest.java @@ -308,7 +308,7 @@ public void testChatFunctionAutoPreset(HttpClient httpClient, OpenAIServiceVersi ChatChoice chatChoice = chatCompletions.getChoices().get(0); MyFunctionCallArguments arguments = assertFunctionCall( chatChoice, - "MyFunction", + "Sanitized", MyFunctionCallArguments.class); assertTrue(arguments.getLocation().contains("San Francisco")); assertEquals(arguments.getUnit(), "CELSIUS"); @@ -893,7 +893,7 @@ public void testGetChatCompletionsToolCall(HttpClient httpClient, OpenAIServiceV ChatCompletionsFunctionToolCall functionToolCall = (ChatCompletionsFunctionToolCall) responseMessage.getToolCalls().get(0); assertNotNull(functionToolCall); - assertEquals(functionToolCall.getFunction().getName(), "FutureTemperature"); // see base class + assertEquals(functionToolCall.getFunction().getName(), "Sanitized"); // see base class assertFalse(functionToolCall.getFunction().getArguments() == null || functionToolCall.getFunction().getArguments().isEmpty()); diff --git a/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAIClientTestBase.java b/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAIClientTestBase.java index fb91301203e4..60c6f8d53ff9 100644 --- a/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAIClientTestBase.java +++ b/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAIClientTestBase.java @@ -126,6 +126,8 @@ OpenAIClientBuilder getNonAzureOpenAIClientBuilder(HttpClient httpClient) { if (getTestMode() != TestMode.LIVE) { addTestRecordCustomSanitizers(); addCustomMatchers(); + // Disable `AZSDK2015` and `AZSDK3430` sanitizers for non-Azure tests + interceptorManager.removeSanitizers(Arrays.asList("AZSDK2015", "AZSDK3430")); } if (getTestMode() == TestMode.PLAYBACK) { diff --git a/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAISyncClientTest.java b/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAISyncClientTest.java index 6f9ecdf7ac15..5944e2a2b780 100644 --- a/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAISyncClientTest.java +++ b/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAISyncClientTest.java @@ -260,7 +260,7 @@ public void testChatFunctionAutoPreset(HttpClient httpClient, OpenAIServiceVersi ChatChoice chatChoice = chatCompletions.getChoices().get(0); MyFunctionCallArguments arguments = assertFunctionCall( chatChoice, - "MyFunction", + "Sanitized", MyFunctionCallArguments.class); assertTrue(arguments.getLocation().contains("San Francisco")); assertEquals(arguments.getUnit(), "CELSIUS"); @@ -800,7 +800,7 @@ public void testGetChatCompletionsToolCall(HttpClient httpClient, OpenAIServiceV ChatCompletionsFunctionToolCall functionToolCall = (ChatCompletionsFunctionToolCall) responseMessage.getToolCalls().get(0); assertNotNull(functionToolCall); - assertEquals(functionToolCall.getFunction().getName(), "FutureTemperature"); // see base class + assertEquals(functionToolCall.getFunction().getName(), "Sanitized"); // see base class assertFalse(functionToolCall.getFunction().getArguments() == null || functionToolCall.getFunction().getArguments().isEmpty()); From 6746713caf3054ebef09d82724d39f34dfd69754 Mon Sep 17 00:00:00 2001 From: Shawn Fang Date: Wed, 22 May 2024 10:31:32 -0700 Subject: [PATCH 4/7] add disable sanitizers --- sdk/openai/azure-ai-openai/CHANGELOG.md | 17 ++++++++ sdk/openai/azure-ai-openai/assets.json | 2 +- .../openai/NonAzureOpenAIAsyncClientTest.java | 2 - .../openai/NonAzureOpenAISyncClientTest.java | 2 - .../ai/openai/OpenAIAsyncClientTest.java | 39 +++++++++++++++++- .../azure/ai/openai/OpenAIClientTestBase.java | 41 +++++++++++++++---- .../azure/ai/openai/OpenAISyncClientTest.java | 35 +++++++++++++++- 7 files changed, 121 insertions(+), 17 deletions(-) diff --git a/sdk/openai/azure-ai-openai/CHANGELOG.md b/sdk/openai/azure-ai-openai/CHANGELOG.md index 3f79b3407226..59b13e48b262 100644 --- a/sdk/openai/azure-ai-openai/CHANGELOG.md +++ b/sdk/openai/azure-ai-openai/CHANGELOG.md @@ -17,7 +17,23 @@ **Chat** +- [AOAI] Added new class `OnYourDataContextProperty` to represent the context property in the On Your Data deployment. +- [AOAI] Added new class `OnYourDataVectorSearchAuthenticationType`, `OnYourDataVectorSearchAuthenticationOptions`, `OnYourDataVectorSearchApiKeyAuthenticationOptions`, `OnYourDataVectorSearchAccessTokenAuthenticationOptions` for the vector search authentication options. +- [AOAI] Added new class `AzureChatExtensionRetrievedDocument` and `AzureChatExtensionRetrieveDocumentFilterReason` to represent the retrieved document and filter reason in the chat extension. +- [AOAI] Added a new property `all_retrieved_documents` in `AzureChatExtensionsMessageContext` class to represent all the retrieved documents in the chat extension. - [AOAI] Added a new property `indirectAttack` in `ContentFilterResultDetailsForPrompt` class to represent the indirect attack results. +- [AOAI] Added new properties `max_search_queries`, `allow_partial_result`, and `include_contexts` in + `AzureCosmosDBChatExtensionParameters`, `AzureMachineLearningIndexChatExtensionParameters`, + `AzureSearchChatExtensionParameters`, `ElasticsearchChatExtensionParameters`, `PineconeChatExtensionParameters` class + to support additional search queries. + +**Embeddings** + +- [AOAI] Added a new property `dimensions` in `OnYourDataDeploymentNameVectorizationSource` class to represent the dimensions of the vectorization source. + +**Image** + +- [AOAI] Added a new property `custom_blocklists` in `ImageGenerationPromptFilterResults` class to represent the prompt filter results. ### Breaking Changes @@ -25,6 +41,7 @@ - [AOAI] Added a new class `ContentFilterDetailedResults` to represent detailed content filter results, which replaces the `customBlocklists` response property type, `List` in `ContentFilterResultDetailsForPrompt` and `ContentFilterResultsForChoice` class. +- [AOAI] Replace the `OnYourDataAuthenticationOptions` by `OnYourDataVectorSearchAuthenticationOptions` in the `OnYourDataEndpointVectorizationSource` class. ### Bugs Fixed diff --git a/sdk/openai/azure-ai-openai/assets.json b/sdk/openai/azure-ai-openai/assets.json index 62611939b82a..2f9d3c51964f 100644 --- a/sdk/openai/azure-ai-openai/assets.json +++ b/sdk/openai/azure-ai-openai/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "java", "TagPrefix": "java/openai/azure-ai-openai", - "Tag": "java/openai/azure-ai-openai_4a8899256e" + "Tag": "java/openai/azure-ai-openai_959f9440df" } diff --git a/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/NonAzureOpenAIAsyncClientTest.java b/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/NonAzureOpenAIAsyncClientTest.java index a823a39239b5..aa45e696b0a2 100644 --- a/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/NonAzureOpenAIAsyncClientTest.java +++ b/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/NonAzureOpenAIAsyncClientTest.java @@ -300,7 +300,6 @@ public void testChatFunctionAutoPreset(HttpClient httpClient, OpenAIServiceVersi ChatChoice chatChoice = chatCompletions.getChoices().get(0); MyFunctionCallArguments arguments = assertFunctionCall( chatChoice, - "Sanitized", MyFunctionCallArguments.class); assertTrue(arguments.getLocation().contains("San Francisco")); assertEquals(arguments.getUnit(), "CELSIUS"); @@ -756,7 +755,6 @@ public void testGetChatCompletionsToolCall(HttpClient httpClient, OpenAIServiceV ChatCompletionsFunctionToolCall functionToolCall = (ChatCompletionsFunctionToolCall) responseMessage.getToolCalls().get(0); assertNotNull(functionToolCall); - assertEquals(functionToolCall.getFunction().getName(), "Sanitized"); // see base class assertFalse(functionToolCall.getFunction().getArguments() == null || functionToolCall.getFunction().getArguments().isEmpty()); return client.getChatCompletions(modelId, getChatCompletionsOptionWithToolCallFollowUp( diff --git a/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/NonAzureOpenAISyncClientTest.java b/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/NonAzureOpenAISyncClientTest.java index dc958f4457c1..cb4f9ba1c817 100644 --- a/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/NonAzureOpenAISyncClientTest.java +++ b/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/NonAzureOpenAISyncClientTest.java @@ -255,7 +255,6 @@ public void testChatFunctionAutoPreset(HttpClient httpClient, OpenAIServiceVersi ChatChoice chatChoice = chatCompletions.getChoices().get(0); MyFunctionCallArguments arguments = assertFunctionCall( chatChoice, - "Sanitized", MyFunctionCallArguments.class); assertTrue(arguments.getLocation().contains("San Francisco")); assertEquals(arguments.getUnit(), "CELSIUS"); @@ -681,7 +680,6 @@ public void testGetChatCompletionsToolCall(HttpClient httpClient, OpenAIServiceV ChatCompletionsFunctionToolCall functionToolCall = (ChatCompletionsFunctionToolCall) responseMessage.getToolCalls().get(0); assertNotNull(functionToolCall); - assertEquals(functionToolCall.getFunction().getName(), "Sanitized"); assertFalse(functionToolCall.getFunction().getArguments() == null || functionToolCall.getFunction().getArguments().isEmpty()); diff --git a/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAIAsyncClientTest.java b/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAIAsyncClientTest.java index 3933bb524dd6..7ceb4cf60a7e 100644 --- a/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAIAsyncClientTest.java +++ b/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAIAsyncClientTest.java @@ -7,6 +7,7 @@ import com.azure.ai.openai.models.AudioTranscriptionFormat; import com.azure.ai.openai.models.AudioTranscriptionTimestampGranularity; import com.azure.ai.openai.models.AudioTranslationFormat; +import com.azure.ai.openai.models.AzureChatExtensionsMessageContext; import com.azure.ai.openai.models.AzureSearchChatExtensionConfiguration; import com.azure.ai.openai.models.AzureSearchChatExtensionParameters; import com.azure.ai.openai.models.ChatChoice; @@ -25,6 +26,7 @@ import com.azure.ai.openai.models.FunctionCall; import com.azure.ai.openai.models.FunctionCallConfig; import com.azure.ai.openai.models.OnYourDataApiKeyAuthenticationOptions; +import com.azure.ai.openai.models.OnYourDataContextProperty; import com.azure.ai.openai.models.SpeechGenerationResponseFormat; import com.azure.core.exception.HttpResponseException; import com.azure.core.exception.ResourceNotFoundException; @@ -308,7 +310,6 @@ public void testChatFunctionAutoPreset(HttpClient httpClient, OpenAIServiceVersi ChatChoice chatChoice = chatCompletions.getChoices().get(0); MyFunctionCallArguments arguments = assertFunctionCall( chatChoice, - "Sanitized", MyFunctionCallArguments.class); assertTrue(arguments.getLocation().contains("San Francisco")); assertEquals(arguments.getUnit(), "CELSIUS"); @@ -494,6 +495,41 @@ public void testChatCompletionsBasicSearchExtension(HttpClient httpClient, OpenA }); } + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.openai.TestUtils#getTestParameters") + public void testChatCompletionSearchExtensionContextPropertyFilter(HttpClient httpClient, OpenAIServiceVersion serviceVersion) { + client = getOpenAIAsyncClient(httpClient, serviceVersion); + + getChatCompletionsAzureChatSearchRunner((deploymentName, chatCompletionsOptions) -> { + AzureSearchChatExtensionParameters searchParameters = new AzureSearchChatExtensionParameters( + "https://openaisdktestsearch.search.windows.net", + "openai-test-index-carbon-wiki" + ); + + // Only have citations in the search results, default are 'citations' and 'intent'. + List contextProperties = new ArrayList<>(); + contextProperties.add(OnYourDataContextProperty.CITATIONS); + + searchParameters.setAuthentication(new OnYourDataApiKeyAuthenticationOptions(getAzureCognitiveSearchKey())) + .setIncludeContexts(contextProperties); + + AzureSearchChatExtensionConfiguration cognitiveSearchConfiguration = + new AzureSearchChatExtensionConfiguration(searchParameters); + + chatCompletionsOptions.setDataSources(Arrays.asList(cognitiveSearchConfiguration)); + + StepVerifier.create(client.getChatCompletions(deploymentName, chatCompletionsOptions)) + .assertNext(chatCompletions -> { + AzureChatExtensionsMessageContext context = chatCompletions.getChoices().get(0) + .getMessage().getContext(); + assertNotNull(context); + assertNull(context.getIntent()); + assertFalse(CoreUtils.isNullOrEmpty(context.getCitations())); + }) + .verifyComplete(); + }); + } + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @MethodSource("com.azure.ai.openai.TestUtils#getTestParameters") public void testChatCompletionsStreamingBasicSearchExtension(HttpClient httpClient, OpenAIServiceVersion serviceVersion) { @@ -893,7 +929,6 @@ public void testGetChatCompletionsToolCall(HttpClient httpClient, OpenAIServiceV ChatCompletionsFunctionToolCall functionToolCall = (ChatCompletionsFunctionToolCall) responseMessage.getToolCalls().get(0); assertNotNull(functionToolCall); - assertEquals(functionToolCall.getFunction().getName(), "Sanitized"); // see base class assertFalse(functionToolCall.getFunction().getArguments() == null || functionToolCall.getFunction().getArguments().isEmpty()); diff --git a/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAIClientTestBase.java b/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAIClientTestBase.java index 60c6f8d53ff9..11fd8eea6c02 100644 --- a/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAIClientTestBase.java +++ b/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAIClientTestBase.java @@ -15,6 +15,7 @@ import com.azure.ai.openai.models.AudioTranslation; import com.azure.ai.openai.models.AudioTranslationOptions; import com.azure.ai.openai.models.AzureChatExtensionDataSourceResponseCitation; +import com.azure.ai.openai.models.AzureChatExtensionRetrievedDocument; import com.azure.ai.openai.models.AzureChatExtensionsMessageContext; import com.azure.ai.openai.models.ChatChoice; import com.azure.ai.openai.models.ChatCompletions; @@ -96,17 +97,25 @@ OpenAIClientBuilder getOpenAIClientBuilder(HttpClient httpClient, OpenAIServiceV OpenAIClientBuilder builder = new OpenAIClientBuilder() .httpClient(httpClient) .serviceVersion(serviceVersion); - - if (getTestMode() != TestMode.LIVE) { + TestMode testMode = getTestMode(); + if (testMode != TestMode.LIVE) { addTestRecordCustomSanitizers(); addCustomMatchers(); } - if (getTestMode() == TestMode.PLAYBACK) { + // TODO: Remove this block once the azure-core-test has fixed the issue. + // AZSDK3430 is already in the default remove list: + // https://github.com/Azure/azure-sdk-for-java/blob/f0d4e21415eb49400a989d09bc5e5af97f0cc438/sdk/core/azure-core-test/src/main/java/com/azure/core/test/utils/TestProxyUtils.java#L50 + if (getTestMode() == TestMode.RECORD) { + // Disable "$..id"=AZSDK3430 sanitizers for both azure and non-azure clients. + interceptorManager.removeSanitizers(Arrays.asList("AZSDK3430")); + } + + if (testMode == TestMode.PLAYBACK) { builder .endpoint("https://localhost:8080") .credential(new AzureKeyCredential(FAKE_API_KEY)); - } else if (getTestMode() == TestMode.RECORD) { + } else if (testMode == TestMode.RECORD) { builder .addPolicy(interceptorManager.getRecordPolicy()) .endpoint(Configuration.getGlobalConfiguration().get("AZURE_OPENAI_ENDPOINT")) @@ -126,8 +135,16 @@ OpenAIClientBuilder getNonAzureOpenAIClientBuilder(HttpClient httpClient) { if (getTestMode() != TestMode.LIVE) { addTestRecordCustomSanitizers(); addCustomMatchers(); - // Disable `AZSDK2015` and `AZSDK3430` sanitizers for non-Azure tests - interceptorManager.removeSanitizers(Arrays.asList("AZSDK2015", "AZSDK3430")); + // Disable "Set-Cookie"=AZSDK2015 for non-azure client only. + interceptorManager.removeSanitizers(Arrays.asList("AZSDK2015")); + } + + // TODO: Remove this block once the azure-core-test has fixed the issue. + // AZSDK3430 is already in the default remove list: + // https://github.com/Azure/azure-sdk-for-java/blob/f0d4e21415eb49400a989d09bc5e5af97f0cc438/sdk/core/azure-core-test/src/main/java/com/azure/core/test/utils/TestProxyUtils.java#L50 + if (getTestMode() == TestMode.RECORD) { + // Disable "$..id"=AZSDK3430 sanitizers for both azure and non-azure clients. + interceptorManager.removeSanitizers(Arrays.asList("AZSDK3430")); } if (getTestMode() == TestMode.PLAYBACK) { @@ -580,11 +597,10 @@ static void assertImageGenerationsForAzure(ImageGenerations actual) { assertNotNull(imageGenerationData.getPromptFilterResults()); } - static T assertFunctionCall(ChatChoice actual, String functionName, Class myPropertiesClazz) { + static T assertFunctionCall(ChatChoice actual, Class myPropertiesClazz) { assertEquals(0, actual.getIndex()); assertEquals("function_call", actual.getFinishReason().toString()); FunctionCall functionCall = actual.getMessage().getFunctionCall(); - assertEquals(functionName, functionCall.getName()); BinaryData argumentJson = BinaryData.fromString(functionCall.getArguments()); return argumentJson.toObject(myPropertiesClazz); } @@ -643,6 +659,15 @@ static void assertChatCompletionsCognitiveSearch(ChatCompletions chatCompletions assertNotNull(messageContext.getIntent()); AzureChatExtensionDataSourceResponseCitation firstResponseCitation = messageContext.getCitations().get(0); assertNotNull(firstResponseCitation.getContent()); + List allRetrievedDocuments = messageContext.getAllRetrievedDocuments(); + + if (!CoreUtils.isNullOrEmpty(allRetrievedDocuments)) { + for (AzureChatExtensionRetrievedDocument retrievedDocument : allRetrievedDocuments) { + assertNotNull(retrievedDocument.getContent()); + assertFalse(CoreUtils.isNullOrEmpty(retrievedDocument.getSearchQueries())); + assertNotNull(retrievedDocument.getFilterReason()); + } + } } // Some of the quirks of stream ChatCompletions: diff --git a/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAISyncClientTest.java b/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAISyncClientTest.java index 5944e2a2b780..c5eb9d454a8e 100644 --- a/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAISyncClientTest.java +++ b/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAISyncClientTest.java @@ -8,6 +8,7 @@ import com.azure.ai.openai.models.AudioTranscriptionTimestampGranularity; import com.azure.ai.openai.models.AudioTranslation; import com.azure.ai.openai.models.AudioTranslationFormat; +import com.azure.ai.openai.models.AzureChatExtensionsMessageContext; import com.azure.ai.openai.models.AzureSearchChatExtensionConfiguration; import com.azure.ai.openai.models.AzureSearchChatExtensionParameters; import com.azure.ai.openai.models.ChatChoice; @@ -26,6 +27,7 @@ import com.azure.ai.openai.models.FunctionCall; import com.azure.ai.openai.models.FunctionCallConfig; import com.azure.ai.openai.models.OnYourDataApiKeyAuthenticationOptions; +import com.azure.ai.openai.models.OnYourDataContextProperty; import com.azure.ai.openai.models.SpeechGenerationResponseFormat; import com.azure.core.exception.HttpResponseException; import com.azure.core.exception.ResourceNotFoundException; @@ -39,6 +41,7 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; +import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; @@ -260,7 +263,6 @@ public void testChatFunctionAutoPreset(HttpClient httpClient, OpenAIServiceVersi ChatChoice chatChoice = chatCompletions.getChoices().get(0); MyFunctionCallArguments arguments = assertFunctionCall( chatChoice, - "Sanitized", MyFunctionCallArguments.class); assertTrue(arguments.getLocation().contains("San Francisco")); assertEquals(arguments.getUnit(), "CELSIUS"); @@ -423,6 +425,36 @@ public void testChatCompletionsBasicSearchExtension(HttpClient httpClient, OpenA }); } + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) + @MethodSource("com.azure.ai.openai.TestUtils#getTestParameters") + public void testChatCompletionSearchExtensionContextPropertyFilter(HttpClient httpClient, OpenAIServiceVersion serviceVersion) { + client = getOpenAIClient(httpClient, serviceVersion); + + getChatCompletionsAzureChatSearchRunner((deploymentName, chatCompletionsOptions) -> { + AzureSearchChatExtensionParameters searchParameters = new AzureSearchChatExtensionParameters( + "https://openaisdktestsearch.search.windows.net", + "openai-test-index-carbon-wiki" + ); + + // Only have citations in the search results, default are 'citations' and 'intent'. + List contextProperties = new ArrayList<>(); + contextProperties.add(OnYourDataContextProperty.CITATIONS); + + searchParameters.setAuthentication(new OnYourDataApiKeyAuthenticationOptions(getAzureCognitiveSearchKey())) + .setIncludeContexts(contextProperties); + AzureSearchChatExtensionConfiguration cognitiveSearchConfiguration = + new AzureSearchChatExtensionConfiguration(searchParameters); + + chatCompletionsOptions.setDataSources(Arrays.asList(cognitiveSearchConfiguration)); + ChatCompletions chatCompletions = client.getChatCompletions(deploymentName, chatCompletionsOptions); + + AzureChatExtensionsMessageContext context = chatCompletions.getChoices().get(0).getMessage().getContext(); + assertNotNull(context); + assertNull(context.getIntent()); + assertFalse(CoreUtils.isNullOrEmpty(context.getCitations())); + }); + } + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @MethodSource("com.azure.ai.openai.TestUtils#getTestParameters") public void testChatCompletionsStreamingBasicSearchExtension(HttpClient httpClient, OpenAIServiceVersion serviceVersion) { @@ -800,7 +832,6 @@ public void testGetChatCompletionsToolCall(HttpClient httpClient, OpenAIServiceV ChatCompletionsFunctionToolCall functionToolCall = (ChatCompletionsFunctionToolCall) responseMessage.getToolCalls().get(0); assertNotNull(functionToolCall); - assertEquals(functionToolCall.getFunction().getName(), "Sanitized"); // see base class assertFalse(functionToolCall.getFunction().getArguments() == null || functionToolCall.getFunction().getArguments().isEmpty()); From 7a1e547e16ba360496da3c77772279d91bb28870 Mon Sep 17 00:00:00 2001 From: Shawn Fang Date: Thu, 23 May 2024 21:11:31 -0700 Subject: [PATCH 5/7] added cspell word and increase code coverage --- .vscode/cspell.json | 3 ++ sdk/openai/azure-ai-openai/CHANGELOG.md | 10 ++-- .../azure/ai/openai/OpenAIClientTestBase.java | 51 +++++++++++++++++++ 3 files changed, 61 insertions(+), 3 deletions(-) diff --git a/.vscode/cspell.json b/.vscode/cspell.json index b6179c8abc93..f00e2eefb171 100644 --- a/.vscode/cspell.json +++ b/.vscode/cspell.json @@ -390,6 +390,9 @@ "reimaging", "Remediations", "requireReleaseDeps", + "rerank", + "Rerank", + "RERANK", "resourcemanager", "Retriable", "revapi", diff --git a/sdk/openai/azure-ai-openai/CHANGELOG.md b/sdk/openai/azure-ai-openai/CHANGELOG.md index 59b13e48b262..2d8008103fe4 100644 --- a/sdk/openai/azure-ai-openai/CHANGELOG.md +++ b/sdk/openai/azure-ai-openai/CHANGELOG.md @@ -18,9 +18,13 @@ **Chat** - [AOAI] Added new class `OnYourDataContextProperty` to represent the context property in the On Your Data deployment. -- [AOAI] Added new class `OnYourDataVectorSearchAuthenticationType`, `OnYourDataVectorSearchAuthenticationOptions`, `OnYourDataVectorSearchApiKeyAuthenticationOptions`, `OnYourDataVectorSearchAccessTokenAuthenticationOptions` for the vector search authentication options. -- [AOAI] Added new class `AzureChatExtensionRetrievedDocument` and `AzureChatExtensionRetrieveDocumentFilterReason` to represent the retrieved document and filter reason in the chat extension. -- [AOAI] Added a new property `all_retrieved_documents` in `AzureChatExtensionsMessageContext` class to represent all the retrieved documents in the chat extension. +- [AOAI] Added new class `OnYourDataVectorSearchAuthenticationType`, `OnYourDataVectorSearchAuthenticationOptions`, + `OnYourDataVectorSearchApiKeyAuthenticationOptions`, `OnYourDataVectorSearchAccessTokenAuthenticationOptions` for the + vector search authentication options. +- [AOAI] Added new class `AzureChatExtensionRetrievedDocument` and `AzureChatExtensionRetrieveDocumentFilterReason` to + represent the retrieved document and filter reason in the chat extension. +- [AOAI] Added a new property `all_retrieved_documents` in `AzureChatExtensionsMessageContext` class to represent all + the retrieved documents in the chat extension. - [AOAI] Added a new property `indirectAttack` in `ContentFilterResultDetailsForPrompt` class to represent the indirect attack results. - [AOAI] Added new properties `max_search_queries`, `allow_partial_result`, and `include_contexts` in `AzureCosmosDBChatExtensionParameters`, `AzureMachineLearningIndexChatExtensionParameters`, diff --git a/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAIClientTestBase.java b/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAIClientTestBase.java index 11fd8eea6c02..91dbbc71523f 100644 --- a/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAIClientTestBase.java +++ b/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAIClientTestBase.java @@ -36,6 +36,9 @@ import com.azure.ai.openai.models.Choice; import com.azure.ai.openai.models.Completions; import com.azure.ai.openai.models.CompletionsFinishReason; +import com.azure.ai.openai.models.ContentFilterCitedDetectionResult; +import com.azure.ai.openai.models.ContentFilterDetailedResults; +import com.azure.ai.openai.models.ContentFilterDetectionResult; import com.azure.ai.openai.models.ContentFilterResult; import com.azure.ai.openai.models.ContentFilterResultDetailsForPrompt; import com.azure.ai.openai.models.ContentFilterResultsForChoice; @@ -625,6 +628,30 @@ static void assertSafePromptContentFilterResults(ContentFilterResultsForPrompt c ContentFilterResult violence = promptFilterDetails.getViolence(); assertFalse(violence.isFiltered()); assertEquals(violence.getSeverity(), ContentFilterSeverity.SAFE); + + ContentFilterDetailedResults customBlocklists = promptFilterDetails.getCustomBlocklists(); + if (customBlocklists != null) { + assertFalse(customBlocklists.isFiltered()); + assertNull(customBlocklists.getDetails()); + } + + ContentFilterDetectionResult indirectAttack = promptFilterDetails.getIndirectAttack(); + if (indirectAttack != null) { + assertFalse(indirectAttack.isFiltered()); + assertFalse(indirectAttack.isDetected()); + } + + ContentFilterDetectionResult profanity = promptFilterDetails.getProfanity(); + if (profanity != null) { + assertFalse(profanity.isFiltered()); + assertFalse(profanity.isDetected()); + } + + ContentFilterDetectionResult jailbreak = promptFilterDetails.getJailbreak(); + if (jailbreak != null) { + assertFalse(jailbreak.isFiltered()); + assertFalse(jailbreak.isDetected()); + } } static void assertSafeChoiceContentFilterResults(ContentFilterResultsForChoice contentFilterResults) { @@ -645,6 +672,30 @@ static void assertSafeChoiceContentFilterResults(ContentFilterResultsForChoice c ContentFilterResult violence = contentFilterResults.getViolence(); assertFalse(violence.isFiltered()); assertEquals(violence.getSeverity(), ContentFilterSeverity.SAFE); + + ContentFilterDetailedResults customBlocklists = contentFilterResults.getCustomBlocklists(); + if (customBlocklists != null) { + assertFalse(customBlocklists.isFiltered()); + assertNull(customBlocklists.getDetails()); + } + + ContentFilterDetectionResult profanity = contentFilterResults.getProfanity(); + if (profanity != null) { + assertFalse(profanity.isFiltered()); + assertFalse(profanity.isDetected()); + } + + ContentFilterDetectionResult protectedMaterialText = contentFilterResults.getProtectedMaterialText(); + if (protectedMaterialText != null) { + assertFalse(protectedMaterialText.isFiltered()); + assertFalse(protectedMaterialText.isDetected()); + } + + ContentFilterCitedDetectionResult protectedMaterialCode = contentFilterResults.getProtectedMaterialCode(); + if (protectedMaterialCode != null) { + assertFalse(protectedMaterialCode.isFiltered()); + assertFalse(protectedMaterialCode.isDetected()); + } } static void assertChatCompletionsCognitiveSearch(ChatCompletions chatCompletions) { From 74f0a53c23d46b6a62d8f0fbf08f614ce20d527f Mon Sep 17 00:00:00 2001 From: Shawn Fang Date: Fri, 24 May 2024 02:41:00 -0700 Subject: [PATCH 6/7] update commit SHA and regenerated --- sdk/openai/azure-ai-openai/CHANGELOG.md | 3 +- ...ExtensionRetrieveDocumentFilterReason.java | 8 +++--- .../AzureChatExtensionRetrievedDocument.java | 28 +++++++++---------- .../openai/models/ChatCompletionsOptions.java | 6 ++-- .../models/OnYourDataContextProperty.java | 8 +++--- ...earchAccessTokenAuthenticationOptions.java | 12 ++++---- ...ctorSearchApiKeyAuthenticationOptions.java | 12 ++++---- ...DataVectorSearchAuthenticationOptions.java | 11 ++++---- ...ourDataVectorSearchAuthenticationType.java | 8 +++--- sdk/openai/azure-ai-openai/tsp-location.yaml | 2 +- 10 files changed, 46 insertions(+), 52 deletions(-) diff --git a/sdk/openai/azure-ai-openai/CHANGELOG.md b/sdk/openai/azure-ai-openai/CHANGELOG.md index 2d8008103fe4..9f574d701193 100644 --- a/sdk/openai/azure-ai-openai/CHANGELOG.md +++ b/sdk/openai/azure-ai-openai/CHANGELOG.md @@ -45,7 +45,8 @@ - [AOAI] Added a new class `ContentFilterDetailedResults` to represent detailed content filter results, which replaces the `customBlocklists` response property type, `List` in `ContentFilterResultDetailsForPrompt` and `ContentFilterResultsForChoice` class. -- [AOAI] Replace the `OnYourDataAuthenticationOptions` by `OnYourDataVectorSearchAuthenticationOptions` in the `OnYourDataEndpointVectorizationSource` class. +- [AOAI] Replaced `OnYourDataAuthenticationOptions` with `OnYourDataVectorSearchAuthenticationOptions` in the `OnYourDataEndpointVectorizationSource` class. + Currently, `OnYourDataEndpointVectorizationSource` only supports `OnYourDataApiKeyAuthenticationOptions` and `OnYourDataAccessTokenAuthenticationOptions` as authentication options. ### Bugs Fixed diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/AzureChatExtensionRetrieveDocumentFilterReason.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/AzureChatExtensionRetrieveDocumentFilterReason.java index 2112b8d74f60..644012207bb0 100644 --- a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/AzureChatExtensionRetrieveDocumentFilterReason.java +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/AzureChatExtensionRetrieveDocumentFilterReason.java @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. - package com.azure.ai.openai.models; import com.azure.core.annotation.Generated; @@ -13,6 +12,7 @@ */ public final class AzureChatExtensionRetrieveDocumentFilterReason extends ExpandableStringEnum { + /** * The document is filtered by original search score threshold defined by `strictness` configure. */ @@ -28,7 +28,7 @@ public final class AzureChatExtensionRetrieveDocumentFilterReason /** * Creates a new instance of AzureChatExtensionRetrieveDocumentFilterReason value. - * + * * @deprecated Use the {@link #fromString(String)} factory method. */ @Generated @@ -38,7 +38,7 @@ public AzureChatExtensionRetrieveDocumentFilterReason() { /** * Creates or finds a AzureChatExtensionRetrieveDocumentFilterReason from its string representation. - * + * * @param name a name to look for. * @return the corresponding AzureChatExtensionRetrieveDocumentFilterReason. */ @@ -49,7 +49,7 @@ public static AzureChatExtensionRetrieveDocumentFilterReason fromString(String n /** * Gets known AzureChatExtensionRetrieveDocumentFilterReason values. - * + * * @return known AzureChatExtensionRetrieveDocumentFilterReason values. */ @Generated diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/AzureChatExtensionRetrievedDocument.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/AzureChatExtensionRetrievedDocument.java index 4206db93254d..ae279f0064db 100644 --- a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/AzureChatExtensionRetrievedDocument.java +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/AzureChatExtensionRetrievedDocument.java @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. - package com.azure.ai.openai.models; import com.azure.core.annotation.Generated; @@ -19,6 +18,7 @@ @Immutable public final class AzureChatExtensionRetrievedDocument implements JsonSerializable { + /* * The content of the citation. */ @@ -82,7 +82,7 @@ public final class AzureChatExtensionRetrievedDocument /** * Creates an instance of AzureChatExtensionRetrievedDocument class. - * + * * @param content the content value to set. * @param searchQueries the searchQueries value to set. * @param dataSourceIndex the dataSourceIndex value to set. @@ -96,7 +96,7 @@ private AzureChatExtensionRetrievedDocument(String content, List searchQ /** * Get the content property: The content of the citation. - * + * * @return the content value. */ @Generated @@ -106,7 +106,7 @@ public String getContent() { /** * Get the title property: The title of the citation. - * + * * @return the title value. */ @Generated @@ -116,7 +116,7 @@ public String getTitle() { /** * Get the url property: The URL of the citation. - * + * * @return the url value. */ @Generated @@ -126,7 +126,7 @@ public String getUrl() { /** * Get the filepath property: The file path of the citation. - * + * * @return the filepath value. */ @Generated @@ -136,7 +136,7 @@ public String getFilepath() { /** * Get the chunkId property: The chunk ID of the citation. - * + * * @return the chunkId value. */ @Generated @@ -146,7 +146,7 @@ public String getChunkId() { /** * Get the searchQueries property: The search queries used to retrieve the document. - * + * * @return the searchQueries value. */ @Generated @@ -156,7 +156,7 @@ public List getSearchQueries() { /** * Get the dataSourceIndex property: The index of the data source. - * + * * @return the dataSourceIndex value. */ @Generated @@ -166,7 +166,7 @@ public int getDataSourceIndex() { /** * Get the originalSearchScore property: The original search score of the retrieved document. - * + * * @return the originalSearchScore value. */ @Generated @@ -176,7 +176,7 @@ public Double getOriginalSearchScore() { /** * Get the rerankScore property: The rerank score of the retrieved document. - * + * * @return the rerankScore value. */ @Generated @@ -188,7 +188,7 @@ public Double getRerankScore() { * Get the filterReason property: Represents the rationale for filtering the document. If the document does not * undergo filtering, * this field will remain unset. - * + * * @return the filterReason value. */ @Generated @@ -219,7 +219,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of AzureChatExtensionRetrievedDocument from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of AzureChatExtensionRetrievedDocument if the JsonReader was pointing to an instance of it, * or null if it was pointing to JSON null. @@ -242,7 +242,6 @@ public static AzureChatExtensionRetrievedDocument fromJson(JsonReader jsonReader while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); - if ("content".equals(fieldName)) { content = reader.getString(); } else if ("search_queries".equals(fieldName)) { @@ -276,7 +275,6 @@ public static AzureChatExtensionRetrievedDocument fromJson(JsonReader jsonReader deserializedAzureChatExtensionRetrievedDocument.originalSearchScore = originalSearchScore; deserializedAzureChatExtensionRetrievedDocument.rerankScore = rerankScore; deserializedAzureChatExtensionRetrievedDocument.filterReason = filterReason; - return deserializedAzureChatExtensionRetrievedDocument; }); } diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ChatCompletionsOptions.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ChatCompletionsOptions.java index 5087390c7bcd..ed5c56bd3e23 100644 --- a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ChatCompletionsOptions.java +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ChatCompletionsOptions.java @@ -3,7 +3,6 @@ // Code generated by Microsoft (R) TypeSpec Code Generator. package com.azure.ai.openai.models; -import com.azure.ai.openai.implementation.models.FunctionCallPreset; import com.azure.core.annotation.Fluent; import com.azure.core.annotation.Generated; import com.azure.core.util.BinaryData; @@ -14,6 +13,7 @@ import java.io.IOException; import java.util.List; import java.util.Map; +import com.azure.ai.openai.implementation.models.FunctionCallPreset; /** * The configuration information for a chat completions request. @@ -538,8 +538,8 @@ public FunctionCallConfig getFunctionCall() { public ChatCompletionsOptions setFunctionCall(FunctionCallConfig functionCallConfig) { this.functionCallConfig = functionCallConfig; if (FunctionCallPreset.values() - .stream() - .anyMatch(preset -> preset.toString().equals(functionCallConfig.getName()))) { + .stream() + .anyMatch(preset -> preset.toString().equals(functionCallConfig.getName()))) { this.functionCall = BinaryData.fromObject(FunctionCallPreset.fromString(this.functionCallConfig.getName())); } else { this.functionCall = BinaryData.fromObject(new FunctionName(this.functionCallConfig.getName())); diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataContextProperty.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataContextProperty.java index b26178783571..703fae668ca4 100644 --- a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataContextProperty.java +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataContextProperty.java @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. - package com.azure.ai.openai.models; import com.azure.core.annotation.Generated; @@ -12,6 +11,7 @@ * The context property. */ public final class OnYourDataContextProperty extends ExpandableStringEnum { + /** * The `citations` property. */ @@ -32,7 +32,7 @@ public final class OnYourDataContextProperty extends ExpandableStringEnum { + /* * The type of authentication to use. */ @@ -34,7 +34,7 @@ public OnYourDataVectorSearchAuthenticationOptions() { /** * Get the type property: The type of authentication to use. - * + * * @return the type value. */ @Generated @@ -55,7 +55,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of OnYourDataVectorSearchAuthenticationOptions from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of OnYourDataVectorSearchAuthenticationOptions if the JsonReader was pointing to an instance * of it, or null if it was pointing to JSON null. @@ -66,7 +66,8 @@ public static OnYourDataVectorSearchAuthenticationOptions fromJson(JsonReader js return jsonReader.readObject(reader -> { String discriminatorValue = null; try (JsonReader readerToUse = reader.bufferObject()) { - readerToUse.nextToken(); // Prepare for reading + // Prepare for reading + readerToUse.nextToken(); while (readerToUse.nextToken() != JsonToken.END_OBJECT) { String fieldName = readerToUse.getFieldName(); readerToUse.nextToken(); @@ -98,7 +99,6 @@ static OnYourDataVectorSearchAuthenticationOptions fromJsonKnownDiscriminator(Js while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); - if ("type".equals(fieldName)) { deserializedOnYourDataVectorSearchAuthenticationOptions.type = OnYourDataVectorSearchAuthenticationType.fromString(reader.getString()); @@ -106,7 +106,6 @@ static OnYourDataVectorSearchAuthenticationOptions fromJsonKnownDiscriminator(Js reader.skipChildren(); } } - return deserializedOnYourDataVectorSearchAuthenticationOptions; }); } diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataVectorSearchAuthenticationType.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataVectorSearchAuthenticationType.java index b4e6fb1eba2c..aff9f28a2bc1 100644 --- a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataVectorSearchAuthenticationType.java +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/OnYourDataVectorSearchAuthenticationType.java @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. - package com.azure.ai.openai.models; import com.azure.core.annotation.Generated; @@ -13,6 +12,7 @@ */ public final class OnYourDataVectorSearchAuthenticationType extends ExpandableStringEnum { + /** * Authentication via API key. */ @@ -27,7 +27,7 @@ public final class OnYourDataVectorSearchAuthenticationType /** * Creates a new instance of OnYourDataVectorSearchAuthenticationType value. - * + * * @deprecated Use the {@link #fromString(String)} factory method. */ @Generated @@ -37,7 +37,7 @@ public OnYourDataVectorSearchAuthenticationType() { /** * Creates or finds a OnYourDataVectorSearchAuthenticationType from its string representation. - * + * * @param name a name to look for. * @return the corresponding OnYourDataVectorSearchAuthenticationType. */ @@ -48,7 +48,7 @@ public static OnYourDataVectorSearchAuthenticationType fromString(String name) { /** * Gets known OnYourDataVectorSearchAuthenticationType values. - * + * * @return known OnYourDataVectorSearchAuthenticationType values. */ @Generated diff --git a/sdk/openai/azure-ai-openai/tsp-location.yaml b/sdk/openai/azure-ai-openai/tsp-location.yaml index 77aa0ac51754..06a09b0fcb2f 100644 --- a/sdk/openai/azure-ai-openai/tsp-location.yaml +++ b/sdk/openai/azure-ai-openai/tsp-location.yaml @@ -1,5 +1,5 @@ directory: specification/cognitiveservices/OpenAI.Inference additionalDirectories: - specification/cognitiveservices/OpenAI.Authoring -commit: 572dee40c3841583617078423ef47cd2042ffd55 +commit: 7451376a57dbed6524271a64dff796c441dd9ff3 repo: Azure/azure-rest-api-specs From 9d6b65d5b2cc242a893cb2960436ea3904f728c9 Mon Sep 17 00:00:00 2001 From: Shawn Fang Date: Wed, 29 May 2024 18:32:00 -0700 Subject: [PATCH 7/7] update CHANGELOG and reduce jacoco code coverage limit --- sdk/openai/azure-ai-openai/CHANGELOG.md | 67 ++++++++++++++----------- sdk/openai/azure-ai-openai/pom.xml | 2 + 2 files changed, 41 insertions(+), 28 deletions(-) diff --git a/sdk/openai/azure-ai-openai/CHANGELOG.md b/sdk/openai/azure-ai-openai/CHANGELOG.md index 9f574d701193..6a46fbe5c81a 100644 --- a/sdk/openai/azure-ai-openai/CHANGELOG.md +++ b/sdk/openai/azure-ai-openai/CHANGELOG.md @@ -6,38 +6,49 @@ - Added support for service API versions, `2024-04-01-preview` and `2024-05-01-preview`. - Note that `AOAI` refers to Azure OpenAI and `OAI` refers to OpenAI. - -**Audio** - -- Added timestamp granularity to Whisper transcription; this is an array of enumerated string values +- Added timestamp granularity to Whisper transcription; this is an array of enumerated string values (word and/or segment) that controls which, if any, timestamp information is emitted to transcription results. - `AudioTranscriptionTimestampGranularity` enum to represent the timestamp granularity options for Whisper transcription. - `AudioTranscriptionWord` class to represent the word timestamp information in the transcription results. -- Added two new audio formats, 'wav' and 'pcm', to the `SpeechGenerationResponseFormat` enum. - -**Chat** - -- [AOAI] Added new class `OnYourDataContextProperty` to represent the context property in the On Your Data deployment. -- [AOAI] Added new class `OnYourDataVectorSearchAuthenticationType`, `OnYourDataVectorSearchAuthenticationOptions`, - `OnYourDataVectorSearchApiKeyAuthenticationOptions`, `OnYourDataVectorSearchAccessTokenAuthenticationOptions` for the +- Added two new audio formats, `wav` and `pcm`, to the `SpeechGenerationResponseFormat` enum. + +*AOAI ONLY* + +- Added a new RAI content filter schema type, `ContentFilterDetailedResults`, that features: + - The boolean `filtered` property from `ContentFilterResult`. + - An array named `details` of the existing `ContentFilterBlocklistIdResult` type, each of which has: + - The base boolean `filtered` + - A string `id` +- Added a new property `indirectAttack` in `ContentFilterResultDetailsForPrompt` class to represent the indirect attack results. +- Added a new property `custom_blocklists` in `ImageGenerationPromptFilterResults` class to represent the prompt filter results. + +**On Your Data** + +- New string enum type used in options: `OnYourDataContextProperty`: "citations" | "intent" | "allRetrievedDocuments" + - This is used in arrays like a bitmasked flag; "give me citations and documents" == `[ "citations", "allRetrievedDocuments" ]` + - It's not dissimilar to how transcription uses `timestamp_granularities[]` +- New model type used in response extensions: `retrievedDocument` + - Inherits from existing `citation` + - Required properties: `content` (string, inherited), `search_queries` (array of strings), `data_source_index` (int32), `original_search_score` (double) + - Optional properties: `title`, `url`, `filepath`, `chunk_id` (all strings inherited from `citation`); `re_rank_score` (double) +- New options fields for chat extension parameters (request options): + - `max_search_queries` (optional int32) + - `allow_partial_result` (optional boolean) + - `include_contexts` (optional array of the above `OnYourDataContextProperty` enum (effective flag selection)) + - Affected `*parameters` types: + - `AzureSearchChatExtensionParameters` + - `AzureMachineLearningIndexChatExtensionParameters` + - `AzureCosmosDBChatExtensionParameters` + - `ElasticsearchChatExtensionParameters` + - `PineconeChatExtensionParameters` +- Vectorization source types have a new `dimensions` property (optional int32) + - Affected: `OnYourDataEndpointVectorizationSource`, `OnYourDataDeploymentNameVectorizationSource` +- `AzureSearchChatExtensionParameters` now supports `OnYourDataAccessTokenAuthenticationOptions` in its named `authentication` field +- `OnYourDataEndpointVectorizationSource` now supports `OnYourDataAccessTokenAuthenticationOptions` for its named `authentication` field. +- Added new class `OnYourDataVectorSearchAuthenticationType`, `OnYourDataVectorSearchAuthenticationOptions`, + `OnYourDataVectorSearchApiKeyAuthenticationOptions`, `OnYourDataVectorSearchAccessTokenAuthenticationOptions` for the vector search authentication options. -- [AOAI] Added new class `AzureChatExtensionRetrievedDocument` and `AzureChatExtensionRetrieveDocumentFilterReason` to - represent the retrieved document and filter reason in the chat extension. -- [AOAI] Added a new property `all_retrieved_documents` in `AzureChatExtensionsMessageContext` class to represent all - the retrieved documents in the chat extension. -- [AOAI] Added a new property `indirectAttack` in `ContentFilterResultDetailsForPrompt` class to represent the indirect attack results. -- [AOAI] Added new properties `max_search_queries`, `allow_partial_result`, and `include_contexts` in - `AzureCosmosDBChatExtensionParameters`, `AzureMachineLearningIndexChatExtensionParameters`, - `AzureSearchChatExtensionParameters`, `ElasticsearchChatExtensionParameters`, `PineconeChatExtensionParameters` class - to support additional search queries. - -**Embeddings** - -- [AOAI] Added a new property `dimensions` in `OnYourDataDeploymentNameVectorizationSource` class to represent the dimensions of the vectorization source. - -**Image** - -- [AOAI] Added a new property `custom_blocklists` in `ImageGenerationPromptFilterResults` class to represent the prompt filter results. +- The response extension type `AzureChatExtensionsMessageContext` has a new `all_retrieved_documents` field, which is an optional array of the new `retrievedDocument` type defined earlier. ### Breaking Changes diff --git a/sdk/openai/azure-ai-openai/pom.xml b/sdk/openai/azure-ai-openai/pom.xml index 3adecd4c4600..06fc0ed5e5b5 100644 --- a/sdk/openai/azure-ai-openai/pom.xml +++ b/sdk/openai/azure-ai-openai/pom.xml @@ -44,6 +44,8 @@ UTF-8 + 0.30 + 0.30 --add-exports com.azure.core/com.azure.core.implementation.http=ALL-UNNAMED