Skip to content

Commit

Permalink
CodeGen from PR 24596 in Azure/azure-rest-api-specs
Browse files Browse the repository at this point in the history
Merge 31777c66d515d777d1dd80796fbcd713f6a9188a into bc3238712f07c24028adaa4c8d879cce39348d47
  • Loading branch information
SDKAuto committed Jun 27, 2023
1 parent ce2110b commit 69ba2cf
Show file tree
Hide file tree
Showing 9 changed files with 149 additions and 317 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
import com.azure.ai.openai.models.CompletionsOptions;
import com.azure.ai.openai.models.Embeddings;
import com.azure.ai.openai.models.EmbeddingsOptions;
import com.azure.ai.openai.models.ImageGenerationOptions;
import com.azure.ai.openai.models.ImageOperationResponse;
import com.azure.ai.openai.models.ImageOperationStatus;
import com.azure.core.annotation.Generated;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceClient;
Expand All @@ -24,7 +22,6 @@
import com.azure.core.exception.HttpResponseException;
import com.azure.core.exception.ResourceModifiedException;
import com.azure.core.exception.ResourceNotFoundException;
import com.azure.core.experimental.models.PollResult;
import com.azure.core.http.rest.RequestOptions;
import com.azure.core.http.rest.Response;
import com.azure.core.util.BinaryData;
Expand Down Expand Up @@ -267,7 +264,7 @@ public Mono<Response<BinaryData>> getChatCompletionsWithResponse(
/**
* Return the embeddings for a given prompt.
*
* @param deploymentId deployment id of the deployed model.
* @param deploymentOrModelName deployment id of the deployed model.
* @param embeddingsOptions The configuration information for an embeddings request. Embeddings measure the
* relatedness of text strings and are commonly used for search, clustering, recommendations, and other similar
* scenarios.
Expand All @@ -283,10 +280,11 @@ public Mono<Response<BinaryData>> getChatCompletionsWithResponse(
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Embeddings> getEmbeddings(String deploymentId, EmbeddingsOptions embeddingsOptions) {
public Mono<Embeddings> getEmbeddings(String deploymentOrModelName, EmbeddingsOptions embeddingsOptions) {
// Generated convenience method for getEmbeddingsWithResponse
RequestOptions requestOptions = new RequestOptions();
return getEmbeddingsWithResponse(deploymentId, BinaryData.fromObject(embeddingsOptions), requestOptions)
return getEmbeddingsWithResponse(
deploymentOrModelName, BinaryData.fromObject(embeddingsOptions), requestOptions)
.flatMap(FluxUtil::toMono)
.map(protocolMethodData -> protocolMethodData.toObject(Embeddings.class));
}
Expand All @@ -295,7 +293,7 @@ public Mono<Embeddings> getEmbeddings(String deploymentId, EmbeddingsOptions emb
* Gets completions for the provided input prompts. Completions support a wide variety of tasks and generate text
* that continues from or "completes" provided prompt data.
*
* @param deploymentId deployment id of the deployed model.
* @param deploymentOrModelName deployment id of the deployed model.
* @param completionsOptions The configuration information for a completions request. Completions support a wide
* variety of tasks and generate text that continues from or "completes" provided prompt data.
* @throws IllegalArgumentException thrown if parameters fail the validation.
Expand All @@ -309,10 +307,11 @@ public Mono<Embeddings> getEmbeddings(String deploymentId, EmbeddingsOptions emb
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Completions> getCompletions(String deploymentId, CompletionsOptions completionsOptions) {
public Mono<Completions> getCompletions(String deploymentOrModelName, CompletionsOptions completionsOptions) {
// Generated convenience method for getCompletionsWithResponse
RequestOptions requestOptions = new RequestOptions();
return getCompletionsWithResponse(deploymentId, BinaryData.fromObject(completionsOptions), requestOptions)
return getCompletionsWithResponse(
deploymentOrModelName, BinaryData.fromObject(completionsOptions), requestOptions)
.flatMap(FluxUtil::toMono)
.map(protocolMethodData -> protocolMethodData.toObject(Completions.class));
}
Expand Down Expand Up @@ -370,7 +369,7 @@ public Flux<Completions> getCompletionsStream(String deploymentId, CompletionsOp
* Gets chat completions for the provided chat messages. Completions support a wide variety of tasks and generate
* text that continues from or "completes" provided prompt data.
*
* @param deploymentId deployment id of the deployed model.
* @param deploymentOrModelName deployment id of the deployed model.
* @param chatCompletionsOptions The configuration information for a chat completions request. Completions support a
* wide variety of tasks and generate text that continues from or "completes" provided prompt data.
* @throws IllegalArgumentException thrown if parameters fail the validation.
Expand All @@ -385,11 +384,11 @@ public Flux<Completions> getCompletionsStream(String deploymentId, CompletionsOp
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<ChatCompletions> getChatCompletions(
String deploymentId, ChatCompletionsOptions chatCompletionsOptions) {
String deploymentOrModelName, ChatCompletionsOptions chatCompletionsOptions) {
// Generated convenience method for getChatCompletionsWithResponse
RequestOptions requestOptions = new RequestOptions();
return getChatCompletionsWithResponse(
deploymentId, BinaryData.fromObject(chatCompletionsOptions), requestOptions)
deploymentOrModelName, BinaryData.fromObject(chatCompletionsOptions), requestOptions)
.flatMap(FluxUtil::toMono)
.map(protocolMethodData -> protocolMethodData.toObject(ChatCompletions.class));
}
Expand Down Expand Up @@ -482,7 +481,7 @@ public Flux<ChatCompletions> getChatCompletionsStream(
* }
* ]
* }
* status: String(notRunning/running/succeeded/canceled/failed/deleted) (Required)
* status: String(notRunning/running/succeeded/canceled/failed) (Required)
* error (Optional): (recursive schema, see error above)
* }
* }</pre>
Expand Down Expand Up @@ -548,7 +547,7 @@ public Mono<Response<BinaryData>> getImageOperationStatusWithResponse(
*/
@Generated
@ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
public PollerFlux<BinaryData, BinaryData> beginStartGenerateImage(
PollerFlux<BinaryData, BinaryData> beginStartGenerateImage(
BinaryData imageGenerationOptions, RequestOptions requestOptions) {
return this.serviceClient.beginStartGenerateImageAsync(imageGenerationOptions, requestOptions);
}
Expand All @@ -574,26 +573,4 @@ public Mono<ImageOperationResponse> getImageOperationStatus(String operationId)
.flatMap(FluxUtil::toMono)
.map(protocolMethodData -> protocolMethodData.toObject(ImageOperationResponse.class));
}

/**
* Starts the generation of a batch of images from a text caption.
*
* @param imageGenerationOptions Represents the request data used to generate images.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the {@link PollerFlux} for polling of status details for long running operations.
*/
@Generated
@ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
public PollerFlux<PollResult, ImageOperationStatus> beginStartGenerateImage(
ImageGenerationOptions imageGenerationOptions) {
// Generated convenience method for beginStartGenerateImageWithModel
RequestOptions requestOptions = new RequestOptions();
return serviceClient.beginStartGenerateImageWithModelAsync(
BinaryData.fromObject(imageGenerationOptions), requestOptions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
import com.azure.ai.openai.models.CompletionsOptions;
import com.azure.ai.openai.models.Embeddings;
import com.azure.ai.openai.models.EmbeddingsOptions;
import com.azure.ai.openai.models.ImageGenerationOptions;
import com.azure.ai.openai.models.ImageOperationResponse;
import com.azure.ai.openai.models.ImageOperationStatus;
import com.azure.core.annotation.Generated;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceClient;
Expand All @@ -24,7 +22,6 @@
import com.azure.core.exception.HttpResponseException;
import com.azure.core.exception.ResourceModifiedException;
import com.azure.core.exception.ResourceNotFoundException;
import com.azure.core.experimental.models.PollResult;
import com.azure.core.http.rest.RequestOptions;
import com.azure.core.http.rest.Response;
import com.azure.core.util.BinaryData;
Expand Down Expand Up @@ -263,7 +260,7 @@ public Response<BinaryData> getChatCompletionsWithResponse(
/**
* Return the embeddings for a given prompt.
*
* @param deploymentId deployment id of the deployed model.
* @param deploymentOrModelName deployment id of the deployed model.
* @param embeddingsOptions The configuration information for an embeddings request. Embeddings measure the
* relatedness of text strings and are commonly used for search, clustering, recommendations, and other similar
* scenarios.
Expand All @@ -278,10 +275,11 @@ public Response<BinaryData> getChatCompletionsWithResponse(
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public Embeddings getEmbeddings(String deploymentId, EmbeddingsOptions embeddingsOptions) {
public Embeddings getEmbeddings(String deploymentOrModelName, EmbeddingsOptions embeddingsOptions) {
// Generated convenience method for getEmbeddingsWithResponse
RequestOptions requestOptions = new RequestOptions();
return getEmbeddingsWithResponse(deploymentId, BinaryData.fromObject(embeddingsOptions), requestOptions)
return getEmbeddingsWithResponse(
deploymentOrModelName, BinaryData.fromObject(embeddingsOptions), requestOptions)
.getValue()
.toObject(Embeddings.class);
}
Expand All @@ -290,7 +288,7 @@ public Embeddings getEmbeddings(String deploymentId, EmbeddingsOptions embedding
* Gets completions for the provided input prompts. Completions support a wide variety of tasks and generate text
* that continues from or "completes" provided prompt data.
*
* @param deploymentId deployment id of the deployed model.
* @param deploymentOrModelName deployment id of the deployed model.
* @param completionsOptions The configuration information for a completions request. Completions support a wide
* variety of tasks and generate text that continues from or "completes" provided prompt data.
* @throws IllegalArgumentException thrown if parameters fail the validation.
Expand All @@ -304,10 +302,11 @@ public Embeddings getEmbeddings(String deploymentId, EmbeddingsOptions embedding
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public Completions getCompletions(String deploymentId, CompletionsOptions completionsOptions) {
public Completions getCompletions(String deploymentOrModelName, CompletionsOptions completionsOptions) {
// Generated convenience method for getCompletionsWithResponse
RequestOptions requestOptions = new RequestOptions();
return getCompletionsWithResponse(deploymentId, BinaryData.fromObject(completionsOptions), requestOptions)
return getCompletionsWithResponse(
deploymentOrModelName, BinaryData.fromObject(completionsOptions), requestOptions)
.getValue()
.toObject(Completions.class);
}
Expand Down Expand Up @@ -366,7 +365,7 @@ public IterableStream<Completions> getCompletionsStream(
* Gets chat completions for the provided chat messages. Completions support a wide variety of tasks and generate
* text that continues from or "completes" provided prompt data.
*
* @param deploymentId deployment id of the deployed model.
* @param deploymentOrModelName deployment id of the deployed model.
* @param chatCompletionsOptions The configuration information for a chat completions request. Completions support a
* wide variety of tasks and generate text that continues from or "completes" provided prompt data.
* @throws IllegalArgumentException thrown if parameters fail the validation.
Expand All @@ -380,11 +379,12 @@ public IterableStream<Completions> getCompletionsStream(
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public ChatCompletions getChatCompletions(String deploymentId, ChatCompletionsOptions chatCompletionsOptions) {
public ChatCompletions getChatCompletions(
String deploymentOrModelName, ChatCompletionsOptions chatCompletionsOptions) {
// Generated convenience method for getChatCompletionsWithResponse
RequestOptions requestOptions = new RequestOptions();
return getChatCompletionsWithResponse(
deploymentId, BinaryData.fromObject(chatCompletionsOptions), requestOptions)
deploymentOrModelName, BinaryData.fromObject(chatCompletionsOptions), requestOptions)
.getValue()
.toObject(ChatCompletions.class);
}
Expand Down Expand Up @@ -474,7 +474,7 @@ public IterableStream<ChatCompletions> getChatCompletionsStream(
* }
* ]
* }
* status: String(notRunning/running/succeeded/canceled/failed/deleted) (Required)
* status: String(notRunning/running/succeeded/canceled/failed) (Required)
* error (Optional): (recursive schema, see error above)
* }
* }</pre>
Expand Down Expand Up @@ -538,7 +538,7 @@ public Response<BinaryData> getImageOperationStatusWithResponse(String operation
*/
@Generated
@ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
public SyncPoller<BinaryData, BinaryData> beginStartGenerateImage(
SyncPoller<BinaryData, BinaryData> beginStartGenerateImage(
BinaryData imageGenerationOptions, RequestOptions requestOptions) {
return this.serviceClient.beginStartGenerateImage(imageGenerationOptions, requestOptions);
}
Expand All @@ -564,26 +564,4 @@ public ImageOperationResponse getImageOperationStatus(String operationId) {
.getValue()
.toObject(ImageOperationResponse.class);
}

/**
* Starts the generation of a batch of images from a text caption.
*
* @param imageGenerationOptions Represents the request data used to generate images.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the {@link SyncPoller} for polling of status details for long running operations.
*/
@Generated
@ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
public SyncPoller<PollResult, ImageOperationStatus> beginStartGenerateImage(
ImageGenerationOptions imageGenerationOptions) {
// Generated convenience method for beginStartGenerateImageWithModel
RequestOptions requestOptions = new RequestOptions();
return serviceClient.beginStartGenerateImageWithModel(
BinaryData.fromObject(imageGenerationOptions), requestOptions);
}
}
Loading

0 comments on commit 69ba2cf

Please sign in to comment.