diff --git a/custom-words.txt b/custom-words.txt index c2c806663e3e..853419ac77a5 100644 --- a/custom-words.txt +++ b/custom-words.txt @@ -967,6 +967,7 @@ findsquare finetune finetunes firmwares +flac flexera flink flowlet @@ -1644,6 +1645,7 @@ moodle mooncake mountainview movere +mpga mpls mpns mran diff --git a/specification/cognitiveservices/OpenAI.Inference/examples/2023-09-01-preview/audio_transcription_object.json b/specification/cognitiveservices/OpenAI.Inference/examples/2023-09-01-preview/audio_transcription_object.json index dc8c33a10a17..14fa046829a8 100644 --- a/specification/cognitiveservices/OpenAI.Inference/examples/2023-09-01-preview/audio_transcription_object.json +++ b/specification/cognitiveservices/OpenAI.Inference/examples/2023-09-01-preview/audio_transcription_object.json @@ -4,7 +4,8 @@ "parameters": { "endpoint": "{endpoint}", "api-version": "2023-09-01-preview", - "deploymentId": "" + "deploymentId": "", + "body": "---multipart-boundary\nContent-Disposition: form-data; name=\"file\"; filename=\"file.wav\"\nContent-Type: application/octet-stream\n\nRIFF..audio.data.omitted\n---multipart-boundary--" }, "responses": { "200": { diff --git a/specification/cognitiveservices/OpenAI.Inference/main.tsp b/specification/cognitiveservices/OpenAI.Inference/main.tsp index 9f58a864dad9..3249779f8486 100644 --- a/specification/cognitiveservices/OpenAI.Inference/main.tsp +++ b/specification/cognitiveservices/OpenAI.Inference/main.tsp @@ -1,11 +1,14 @@ -import "@typespec/rest"; import "@typespec/http"; import "@typespec/versioning"; -import "./routes.tsp"; +import "./routes/common.tsp"; +import "./routes/audio_transcription.tsp"; +import "./routes/audio_translation.tsp"; +import "./routes/completions.tsp"; +import "./routes/images.tsp"; +import "./routes/embeddings.tsp"; using TypeSpec.Http; -using TypeSpec.Rest; using TypeSpec.Versioning; #suppress "@azure-tools/typespec-azure-core/casing-style" "OpenAI is a case-sensitive name" @@ -56,13 +59,3 @@ enum ServiceApiVersions { @useDependency(Azure.Core.Versions.v1_0_Preview_1) v2023_09_01_Preview: "2023-09-01-preview", } - -@doc("A specific deployment") -@TypeSpec.Rest.resource("deployments") -model Deployment { - @visibility("read") - @doc("Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request.") - @projectedName("java", "deploymentOrModelName") - @key - deploymentId: string; -} diff --git a/specification/cognitiveservices/OpenAI.Inference/models/audio.transcription.tsp b/specification/cognitiveservices/OpenAI.Inference/models/audio/audio_transcription.tsp similarity index 98% rename from specification/cognitiveservices/OpenAI.Inference/models/audio.transcription.tsp rename to specification/cognitiveservices/OpenAI.Inference/models/audio/audio_transcription.tsp index 9a1af2588457..aea912a57508 100644 --- a/specification/cognitiveservices/OpenAI.Inference/models/audio.transcription.tsp +++ b/specification/cognitiveservices/OpenAI.Inference/models/audio/audio_transcription.tsp @@ -1,5 +1,5 @@ import "@typespec/versioning"; -import "./audio.common.tsp"; +import "./common.tsp"; namespace Azure.OpenAI; @@ -36,7 +36,7 @@ The configuration information for an audio transcription request. model AudioTranscriptionOptions { @doc(""" The audio data to transcribe. This must be the binary content of a file in one of the supported media formats: - flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, webm. + flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, webm. """) @projectedName("csharp", "AudioData") file: bytes; diff --git a/specification/cognitiveservices/OpenAI.Inference/models/audio.translation.tsp b/specification/cognitiveservices/OpenAI.Inference/models/audio/audio_translation.tsp similarity index 98% rename from specification/cognitiveservices/OpenAI.Inference/models/audio.translation.tsp rename to specification/cognitiveservices/OpenAI.Inference/models/audio/audio_translation.tsp index 2d40e3fb5cb2..1638107caf8a 100644 --- a/specification/cognitiveservices/OpenAI.Inference/models/audio.translation.tsp +++ b/specification/cognitiveservices/OpenAI.Inference/models/audio/audio_translation.tsp @@ -1,5 +1,5 @@ import "@typespec/versioning"; -import "./audio.common.tsp"; +import "./common.tsp"; namespace Azure.OpenAI; @@ -36,7 +36,7 @@ The configuration information for an audio translation request. model AudioTranslationOptions { @doc(""" The audio data to translate. This must be the binary content of a file in one of the supported media formats: - flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, webm. + flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, webm. """) @projectedName("csharp", "AudioData") file: bytes; diff --git a/specification/cognitiveservices/OpenAI.Inference/models/audio.common.tsp b/specification/cognitiveservices/OpenAI.Inference/models/audio/common.tsp similarity index 100% rename from specification/cognitiveservices/OpenAI.Inference/models/audio.common.tsp rename to specification/cognitiveservices/OpenAI.Inference/models/audio/common.tsp diff --git a/specification/cognitiveservices/OpenAI.Inference/models/azure.chat.extensions.tsp b/specification/cognitiveservices/OpenAI.Inference/models/completions/azure_chat_extensions.tsp similarity index 97% rename from specification/cognitiveservices/OpenAI.Inference/models/azure.chat.extensions.tsp rename to specification/cognitiveservices/OpenAI.Inference/models/completions/azure_chat_extensions.tsp index 18bd55d7421e..9f024f1f0312 100644 --- a/specification/cognitiveservices/OpenAI.Inference/models/azure.chat.extensions.tsp +++ b/specification/cognitiveservices/OpenAI.Inference/models/completions/azure_chat_extensions.tsp @@ -1,6 +1,7 @@ import "@typespec/versioning"; -import "./chat.completions.tsp"; -import "./azure.cognitive.search.options.tsp"; + +import "./chat_completions.tsp"; +import "./azure_cognitive_search_options.tsp"; namespace Azure.OpenAI; diff --git a/specification/cognitiveservices/OpenAI.Inference/models/azure.cognitive.search.options.tsp b/specification/cognitiveservices/OpenAI.Inference/models/completions/azure_cognitive_search_options.tsp similarity index 98% rename from specification/cognitiveservices/OpenAI.Inference/models/azure.cognitive.search.options.tsp rename to specification/cognitiveservices/OpenAI.Inference/models/completions/azure_cognitive_search_options.tsp index 2f7e0f878fbb..eebe186dc478 100644 --- a/specification/cognitiveservices/OpenAI.Inference/models/azure.cognitive.search.options.tsp +++ b/specification/cognitiveservices/OpenAI.Inference/models/completions/azure_cognitive_search_options.tsp @@ -1,5 +1,6 @@ import "@typespec/versioning"; -import "./azure.chat.extensions.tsp"; + +import "./azure_chat_extensions.tsp"; namespace Azure.OpenAI; diff --git a/specification/cognitiveservices/OpenAI.Inference/models/chat.completions.tsp b/specification/cognitiveservices/OpenAI.Inference/models/completions/chat_completions.tsp similarity index 98% rename from specification/cognitiveservices/OpenAI.Inference/models/chat.completions.tsp rename to specification/cognitiveservices/OpenAI.Inference/models/completions/chat_completions.tsp index de754b192814..aad348dcc19c 100644 --- a/specification/cognitiveservices/OpenAI.Inference/models/chat.completions.tsp +++ b/specification/cognitiveservices/OpenAI.Inference/models/completions/chat_completions.tsp @@ -1,8 +1,9 @@ import "@typespec/rest"; import "@typespec/http"; import "@typespec/versioning"; -import "./azure.chat.extensions.tsp"; -import "./completions.common.tsp"; + +import "./azure_chat_extensions.tsp"; +import "./common.tsp"; import "./functions.tsp"; using TypeSpec.Rest; @@ -231,8 +232,8 @@ model ChatChoice { delta?: ChatMessage; @doc(""" - Information about the content filtering category (hate, sexual, violence, self_harm), if it - has been detected, as well as the severity level (very_low, low, medium, high-scale that + Information about the content filtering category (hate, sexual, violence, self_harm), if it + has been detected, as well as the severity level (very_low, low, medium, high-scale that determines the intensity and risk level of harmful content) and if it has been filtered or not. """) @added(ServiceApiVersions.v2023_06_01_Preview) @@ -268,7 +269,7 @@ model ChatCompletions { choices: ChatChoice[]; @doc(""" - Content filtering results for zero or more prompts in the request. In a streaming request, + Content filtering results for zero or more prompts in the request. In a streaming request, results for different prompts may arrive at different times or in different orders. """) @added(ServiceApiVersions.v2023_06_01_Preview) diff --git a/specification/cognitiveservices/OpenAI.Inference/models/completions.common.tsp b/specification/cognitiveservices/OpenAI.Inference/models/completions/common.tsp similarity index 100% rename from specification/cognitiveservices/OpenAI.Inference/models/completions.common.tsp rename to specification/cognitiveservices/OpenAI.Inference/models/completions/common.tsp diff --git a/specification/cognitiveservices/OpenAI.Inference/models/completions.create.tsp b/specification/cognitiveservices/OpenAI.Inference/models/completions/completions_create.tsp similarity index 98% rename from specification/cognitiveservices/OpenAI.Inference/models/completions.create.tsp rename to specification/cognitiveservices/OpenAI.Inference/models/completions/completions_create.tsp index a4f73016e4db..93dcb25733a7 100644 --- a/specification/cognitiveservices/OpenAI.Inference/models/completions.create.tsp +++ b/specification/cognitiveservices/OpenAI.Inference/models/completions/completions_create.tsp @@ -1,7 +1,8 @@ import "@typespec/rest"; import "@typespec/http"; import "@typespec/versioning"; -import "./completions.common.tsp"; + +import "./common.tsp"; using TypeSpec.Rest; using TypeSpec.Http; @@ -163,7 +164,7 @@ model Completions { created: utcDateTime; @doc(""" - Content filtering results for zero or more prompts in the request. In a streaming request, + Content filtering results for zero or more prompts in the request. In a streaming request, results for different prompts may arrive at different times or in different orders. """) @added(ServiceApiVersions.v2023_06_01_Preview) @@ -200,8 +201,8 @@ model Choice { index: int32; @doc(""" - Information about the content filtering category (hate, sexual, violence, self_harm), if it - has been detected, as well as the severity level (very_low, low, medium, high-scale that + Information about the content filtering category (hate, sexual, violence, self_harm), if it + has been detected, as well as the severity level (very_low, low, medium, high-scale that determines the intensity and risk level of harmful content) and if it has been filtered or not. """) @added(ServiceApiVersions.v2023_06_01_Preview) diff --git a/specification/cognitiveservices/OpenAI.Inference/models/functions.tsp b/specification/cognitiveservices/OpenAI.Inference/models/completions/functions.tsp similarity index 100% rename from specification/cognitiveservices/OpenAI.Inference/models/functions.tsp rename to specification/cognitiveservices/OpenAI.Inference/models/completions/functions.tsp diff --git a/specification/cognitiveservices/OpenAI.Inference/models/embeddings.create.tsp b/specification/cognitiveservices/OpenAI.Inference/models/embeddings_create.tsp similarity index 100% rename from specification/cognitiveservices/OpenAI.Inference/models/embeddings.create.tsp rename to specification/cognitiveservices/OpenAI.Inference/models/embeddings_create.tsp diff --git a/specification/cognitiveservices/OpenAI.Inference/models/operations.common.tsp b/specification/cognitiveservices/OpenAI.Inference/models/images/common.tsp similarity index 100% rename from specification/cognitiveservices/OpenAI.Inference/models/operations.common.tsp rename to specification/cognitiveservices/OpenAI.Inference/models/images/common.tsp diff --git a/specification/cognitiveservices/OpenAI.Inference/models/images.tsp b/specification/cognitiveservices/OpenAI.Inference/models/images/images.tsp similarity index 99% rename from specification/cognitiveservices/OpenAI.Inference/models/images.tsp rename to specification/cognitiveservices/OpenAI.Inference/models/images/images.tsp index d2d8530fe5e1..7542dce12326 100644 --- a/specification/cognitiveservices/OpenAI.Inference/models/images.tsp +++ b/specification/cognitiveservices/OpenAI.Inference/models/images/images.tsp @@ -1,7 +1,8 @@ import "@azure-tools/typespec-azure-core"; import "@typespec/http"; import "@typespec/versioning"; -import "./operations.common.tsp"; + +import "./common.tsp"; using Azure.Core; using TypeSpec.Http; diff --git a/specification/cognitiveservices/OpenAI.Inference/routes.tsp b/specification/cognitiveservices/OpenAI.Inference/routes.tsp deleted file mode 100644 index a19add16c825..000000000000 --- a/specification/cognitiveservices/OpenAI.Inference/routes.tsp +++ /dev/null @@ -1,180 +0,0 @@ -import "@azure-tools/typespec-azure-core"; -import "@typespec/rest"; -import "@typespec/http"; -import "@typespec/versioning"; - -import "./models/completions.create.tsp"; -import "./models/chat.completions.tsp"; -import "./models/embeddings.create.tsp"; -import "./models/images.tsp"; -import "./models/audio.transcription.tsp"; -import "./models/audio.translation.tsp"; - -using TypeSpec.Rest; -using TypeSpec.Http; -using TypeSpec.Versioning; - -using Azure.Core; - -namespace Azure.OpenAI; - -@doc("Return the embeddings for a given prompt.") -@actionSeparator("/") -@action("embeddings") //@convenientAPI(true) -op getEmbeddings is Azure.Core.ResourceAction< - Deployment, - EmbeddingsOptions, - Embeddings ->; - -@doc(""" -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. -""") -@actionSeparator("/") -@action("completions") //@convenientAPI(true) -op getCompletions is Azure.Core.ResourceAction< - Deployment, - CompletionsOptions, - Completions ->; - -@doc(""" -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. -""") -@added(ServiceApiVersions.v2023_05_15) -@actionSeparator("/") -@action("chat/completions") //@convenientAPI(true) -op getChatCompletions is ResourceAction< - Deployment, - ChatCompletionsOptions, - ChatCompletions ->; - -@doc(""" -Gets chat completions for the provided chat messages. -This is an Azure-specific version of chat completions that supports integration with configured data sources and -other augmentations to the base chat completions capabilities. -""") -// Note: client libraries should abstract the existence of this as a distinct REST route and instead perform dynamic -// selection of the appropriate request URL structure based on the presence or non-presence of matching -// chat extensions configuration in the request options model. Future service API versions may merge this -// capability into the standard /chat/completions route. -@added(ServiceApiVersions.v2023_08_01_Preview) -@actionSeparator("/") -@action("extensions/chat/completions") -op getChatCompletionsWithAzureExtensions is ResourceAction< - Deployment, - ChatCompletionsOptions, - ChatCompletions ->; - -// Note: pending resolution of cross-language code emission behavior for long-running operations, image generation -// reuses its final operation response model as its status polling model. -#suppress "@azure-tools/typespec-azure-core/rpc-operation-request-body" "MUST fix in next update" -#suppress "@azure-tools/typespec-azure-core/no-rpc-path-params" "Allowed because this is a non-standard status polling operation." -@doc("Returns the status of the images operation") -@added(ServiceApiVersions.v2023_06_01_Preview) -@route("/operations/images/{operationId}") -op getAzureBatchImageGenerationOperationStatus is RpcOperation< - { - @doc(".") @path operationId: string; - }, - BatchImageGenerationOperationResponse ->; - -#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "" -@doc("Starts the generation of a batch of images from a text caption") -@added(ServiceApiVersions.v2023_06_01_Preview) -@route("/images/generations:submit") -@pollingOperation( - getAzureBatchImageGenerationOperationStatus, - { - operationId: ResponseProperty<"id">, - } -) -op beginAzureBatchImageGeneration is OaiLongRunningRpcOperation< - ImageGenerationOptions, - BatchImageGenerationOperationResponse, - BatchImageGenerationOperationResponse ->; - -// Audio implementation note: depending on the response_format provided in operation request bodies, these operations -// may respond with a response body that's either a JSON object or a text/plain string. Pending more precise -// specification of the relationship between the input format selection and resulting output response format, the two -// content-type-specific options are provided for each operation with no delineation between the matching request body -// requirements. These content-type-specific operations should be hidden by clients and combined into single operations -// that share common characteristics whenever possible. - -alias MultipartFormDataRequestHeadersTraits = Azure.Core.Traits.RequestHeadersTrait<{ - @doc("The content type for the operation. Always multipart/form-data for this operation.") - @header("content-type") - contentType: "multipart/form-data"; -}>; - -#suppress "@azure-tools/typespec-azure-core/byos" "representation of existing multipart/form-data operation" -#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "non-model response value needed" -@doc(""" -Gets transcribed text and associated metadata from provided spoken audio data. Audio will be transcribed in the -written language corresponding to the language it was spoken in. -""") -@added(ServiceApiVersions.v2023_09_01_Preview) -@actionSeparator("/") -@action("audio/transcriptions") -@sharedRoute -op getAudioTranscriptionAsPlainText is Azure.Core.Foundations.ResourceOperation< - Deployment, - AudioTranscriptionOptions, // response_format must be one of: text, srt, vtt - string, - MultipartFormDataRequestHeadersTraits ->; - -#suppress "@azure-tools/typespec-azure-core/byos" "representation of existing multipart/form-data operation" -@doc(""" -Gets transcribed text and associated metadata from provided spoken audio data. Audio will be transcribed in the -written language corresponding to the language it was spoken in. -""") -@added(ServiceApiVersions.v2023_09_01_Preview) -@actionSeparator("/") -@action("audio/transcriptions") -@sharedRoute -op getAudioTranscriptionAsResponseObject is Azure.Core.ResourceAction< - Deployment, - AudioTranscriptionOptions, // response_format must be unspecified (json) or one of: json, verbose_json - AudioTranscription, - MultipartFormDataRequestHeadersTraits ->; - -#suppress "@azure-tools/typespec-azure-core/byos" "representation of existing multipart/form-data operation" -#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "non-model response value needed" -@doc(""" -Gets English language transcribed text and associated metadata from provided spoken audio data. -""") -@added(ServiceApiVersions.v2023_09_01_Preview) -@actionSeparator("/") -@action("audio/translations") -@sharedRoute -op getAudioTranslationAsPlainText is Azure.Core.Foundations.ResourceOperation< - Deployment, - AudioTranslationOptions, // response_format must be one of: text, srt, vtt - string, - MultipartFormDataRequestHeadersTraits ->; - -#suppress "@azure-tools/typespec-azure-core/byos" "representation of existing multipart/form-data operation" -@doc(""" -Gets English language transcribed text and associated metadata from provided spoken audio data. -""") -@added(ServiceApiVersions.v2023_09_01_Preview) -@actionSeparator("/") -@action("audio/translations") -@sharedRoute -op getAudioTranslationAsResponseObject is Azure.Core.ResourceAction< - Deployment, - AudioTranslationOptions, // response_format must be unspecified (json) or one of: json, verbose_json - AudioTranslation, - MultipartFormDataRequestHeadersTraits ->; diff --git a/specification/cognitiveservices/OpenAI.Inference/routes/audio_transcription.tsp b/specification/cognitiveservices/OpenAI.Inference/routes/audio_transcription.tsp new file mode 100644 index 000000000000..3a4565c36ba3 --- /dev/null +++ b/specification/cognitiveservices/OpenAI.Inference/routes/audio_transcription.tsp @@ -0,0 +1,50 @@ +import "@azure-tools/typespec-azure-core"; +import "@typespec/rest"; +import "@typespec/http"; +import "@typespec/versioning"; + +import "../models/audio/audio_transcription.tsp"; +import "./common.tsp"; + +using TypeSpec.Rest; +using TypeSpec.Http; +using TypeSpec.Versioning; + +using Azure.Core; + +namespace Azure.OpenAI; + +// The order in which the operations are defined matters for the purpose of OpenAPIv2 generation + +#suppress "@azure-tools/typespec-azure-core/byos" "representation of existing multipart/form-data operation" +#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "non-model response value needed" +@doc(""" +Gets transcribed text and associated metadata from provided spoken audio data. Audio will be transcribed in the +written language corresponding to the language it was spoken in. +""") +@added(ServiceApiVersions.v2023_09_01_Preview) +@actionSeparator("/") +@action("audio/transcriptions") +@sharedRoute +op getAudioTranscriptionAsPlainText is Azure.Core.Foundations.ResourceOperation< + Deployment, + AudioTranscriptionOptions, // response_format must be one of: text, srt, vtt + string, + MultipartFormDataRequestHeadersTraits +>; + +#suppress "@azure-tools/typespec-azure-core/byos" "representation of existing multipart/form-data operation" +@doc(""" +Gets transcribed text and associated metadata from provided spoken audio data. Audio will be transcribed in the +written language corresponding to the language it was spoken in. +""") +@added(ServiceApiVersions.v2023_09_01_Preview) +@actionSeparator("/") +@action("audio/transcriptions") +@sharedRoute +op getAudioTranscriptionAsResponseObject is Azure.Core.ResourceAction< + Deployment, + AudioTranscriptionOptions, // response_format must be unspecified (json) or one of: json, verbose_json + AudioTranscription, + MultipartFormDataRequestHeadersTraits +>; diff --git a/specification/cognitiveservices/OpenAI.Inference/routes/audio_translation.tsp b/specification/cognitiveservices/OpenAI.Inference/routes/audio_translation.tsp new file mode 100644 index 000000000000..fb378350e549 --- /dev/null +++ b/specification/cognitiveservices/OpenAI.Inference/routes/audio_translation.tsp @@ -0,0 +1,48 @@ +import "@azure-tools/typespec-azure-core"; +import "@typespec/rest"; +import "@typespec/http"; +import "@typespec/versioning"; + +import "../models/audio/audio_translation.tsp"; +import "./common.tsp"; + +using TypeSpec.Rest; +using TypeSpec.Http; +using TypeSpec.Versioning; + +using Azure.Core; + +namespace Azure.OpenAI; + +// The order in which the operations are defined matters for the purpose of OpenAPIv2 generation + +#suppress "@azure-tools/typespec-azure-core/byos" "representation of existing multipart/form-data operation" +#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "non-model response value needed" +@doc(""" +Gets English language transcribed text and associated metadata from provided spoken audio data. +""") +@added(ServiceApiVersions.v2023_09_01_Preview) +@actionSeparator("/") +@action("audio/translations") +@sharedRoute +op getAudioTranslationAsPlainText is Azure.Core.Foundations.ResourceOperation< + Deployment, + AudioTranslationOptions, // response_format must be one of: text, srt, vtt + string, + MultipartFormDataRequestHeadersTraits +>; + +#suppress "@azure-tools/typespec-azure-core/byos" "representation of existing multipart/form-data operation" +@doc(""" +Gets English language transcribed text and associated metadata from provided spoken audio data. +""") +@added(ServiceApiVersions.v2023_09_01_Preview) +@actionSeparator("/") +@action("audio/translations") +@sharedRoute +op getAudioTranslationAsResponseObject is Azure.Core.ResourceAction< + Deployment, + AudioTranslationOptions, // response_format must be unspecified (json) or one of: json, verbose_json + AudioTranslation, + MultipartFormDataRequestHeadersTraits +>; diff --git a/specification/cognitiveservices/OpenAI.Inference/routes/common.tsp b/specification/cognitiveservices/OpenAI.Inference/routes/common.tsp new file mode 100644 index 000000000000..33b175d380dc --- /dev/null +++ b/specification/cognitiveservices/OpenAI.Inference/routes/common.tsp @@ -0,0 +1,32 @@ +import "@typespec/rest"; +import "@typespec/http"; +// import "@typespec/versioning"; + +// import "./routes.tsp"; + +using TypeSpec.Http; +using TypeSpec.Rest; +// using TypeSpec.Versioning; + +@doc("A specific deployment") +@TypeSpec.Rest.resource("deployments") +model Deployment { + @visibility("read") + @doc("Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request.") + @projectedName("java", "deploymentOrModelName") + @key + deploymentId: string; +} + +// Audio implementation note: depending on the response_format provided in operation request bodies, these operations +// may respond with a response body that's either a JSON object or a text/plain string. Pending more precise +// specification of the relationship between the input format selection and resulting output response format, the two +// content-type-specific options are provided for each operation with no delineation between the matching request body +// requirements. These content-type-specific operations should be hidden by clients and combined into single operations +// that share common characteristics whenever possible. + +alias MultipartFormDataRequestHeadersTraits = Azure.Core.Traits.RequestHeadersTrait<{ + @doc("The content type for the operation. Always multipart/form-data for this operation.") + @header("content-type") + contentType: "multipart/form-data"; +}>; diff --git a/specification/cognitiveservices/OpenAI.Inference/routes/completions.tsp b/specification/cognitiveservices/OpenAI.Inference/routes/completions.tsp new file mode 100644 index 000000000000..41d538bbbb45 --- /dev/null +++ b/specification/cognitiveservices/OpenAI.Inference/routes/completions.tsp @@ -0,0 +1,60 @@ +import "@azure-tools/typespec-azure-core"; +import "@typespec/rest"; +import "@typespec/http"; +import "@typespec/versioning"; + +import "../models/completions/completions_create.tsp"; +import "../models/completions/chat_completions.tsp"; + +using TypeSpec.Rest; +using TypeSpec.Http; +using TypeSpec.Versioning; + +using Azure.Core; + +namespace Azure.OpenAI; + +@doc(""" +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. +""") +@actionSeparator("/") +@action("completions") //@convenientAPI(true) +op getCompletions is Azure.Core.ResourceAction< + Deployment, + CompletionsOptions, + Completions +>; + +@doc(""" +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. +""") +@added(ServiceApiVersions.v2023_05_15) +@actionSeparator("/") +@action("chat/completions") //@convenientAPI(true) +op getChatCompletions is ResourceAction< + Deployment, + ChatCompletionsOptions, + ChatCompletions +>; + +@doc(""" +Gets chat completions for the provided chat messages. +This is an Azure-specific version of chat completions that supports integration with configured data sources and +other augmentations to the base chat completions capabilities. +""") +// Note: client libraries should abstract the existence of this as a distinct REST route and instead perform dynamic +// selection of the appropriate request URL structure based on the presence or non-presence of matching +// chat extensions configuration in the request options model. Future service API versions may merge this +// capability into the standard /chat/completions route. +@added(ServiceApiVersions.v2023_08_01_Preview) +@actionSeparator("/") +@action("extensions/chat/completions") +op getChatCompletionsWithAzureExtensions is ResourceAction< + Deployment, + ChatCompletionsOptions, + ChatCompletions +>; diff --git a/specification/cognitiveservices/OpenAI.Inference/routes/embeddings.tsp b/specification/cognitiveservices/OpenAI.Inference/routes/embeddings.tsp new file mode 100644 index 000000000000..c2a6722bdaa4 --- /dev/null +++ b/specification/cognitiveservices/OpenAI.Inference/routes/embeddings.tsp @@ -0,0 +1,23 @@ +import "@azure-tools/typespec-azure-core"; +import "@typespec/rest"; +import "@typespec/http"; +import "@typespec/versioning"; + +import "../models/embeddings_create.tsp"; + +using TypeSpec.Rest; +using TypeSpec.Http; +using TypeSpec.Versioning; + +using Azure.Core; + +namespace Azure.OpenAI; + +@doc("Return the embeddings for a given prompt.") +@actionSeparator("/") +@action("embeddings") //@convenientAPI(true) +op getEmbeddings is Azure.Core.ResourceAction< + Deployment, + EmbeddingsOptions, + Embeddings +>; diff --git a/specification/cognitiveservices/OpenAI.Inference/routes/images.tsp b/specification/cognitiveservices/OpenAI.Inference/routes/images.tsp new file mode 100644 index 000000000000..c9dce14161df --- /dev/null +++ b/specification/cognitiveservices/OpenAI.Inference/routes/images.tsp @@ -0,0 +1,46 @@ +import "@azure-tools/typespec-azure-core"; +import "@typespec/rest"; +import "@typespec/http"; +import "@typespec/versioning"; + +import "../models/images/images.tsp"; +import "../models/images/common.tsp"; + +using TypeSpec.Rest; +using TypeSpec.Http; +using TypeSpec.Versioning; + +using Azure.Core; + +namespace Azure.OpenAI; + +// Note: pending resolution of cross-language code emission behavior for long-running operations, image generation +// reuses its final operation response model as its status polling model. + +#suppress "@azure-tools/typespec-azure-core/rpc-operation-request-body" "MUST fix in next update" +#suppress "@azure-tools/typespec-azure-core/no-rpc-path-params" "Allowed because this is a non-standard status polling operation." +@doc("Returns the status of the images operation") +@added(ServiceApiVersions.v2023_06_01_Preview) +@route("/operations/images/{operationId}") +op getAzureBatchImageGenerationOperationStatus is RpcOperation< + { + @doc(".") @path operationId: string; + }, + BatchImageGenerationOperationResponse +>; + +#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "" +@doc("Starts the generation of a batch of images from a text caption") +@added(ServiceApiVersions.v2023_06_01_Preview) +@route("/images/generations:submit") +@pollingOperation( + getAzureBatchImageGenerationOperationStatus, + { + operationId: ResponseProperty<"id">, + } +) +op beginAzureBatchImageGeneration is OaiLongRunningRpcOperation< + ImageGenerationOptions, + BatchImageGenerationOperationResponse, + BatchImageGenerationOperationResponse +>; diff --git a/specification/cognitiveservices/OpenAI.Inference/tspconfig.yaml b/specification/cognitiveservices/OpenAI.Inference/tspconfig.yaml index 4e2b82d3e928..50d80c70b83e 100644 --- a/specification/cognitiveservices/OpenAI.Inference/tspconfig.yaml +++ b/specification/cognitiveservices/OpenAI.Inference/tspconfig.yaml @@ -13,7 +13,7 @@ options: emitter-output-dir: "{project-root}/../" output-file: "{azure-resource-provider-folder}/AzureOpenAI/inference/{version-status}/{version}/generated.json" azure-resource-provider-folder: "data-plane" - examples-directory: examples + examples-directory: "{project-root}/examples" omit-unreachable-types: true "@azure-tools/typespec-csharp": package-dir: "Azure.AI.OpenAI" diff --git a/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2023-06-01-preview/generated.json b/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2023-06-01-preview/generated.json index 560081a2d09d..0a5686339dbe 100644 --- a/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2023-06-01-preview/generated.json +++ b/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2023-06-01-preview/generated.json @@ -474,7 +474,7 @@ }, "content_filter_results": { "$ref": "#/definitions/ContentFilterResults", - "description": "Information about the content filtering category (hate, sexual, violence, self_harm), if it \nhas been detected, as well as the severity level (very_low, low, medium, high-scale that \ndetermines the intensity and risk level of harmful content) and if it has been filtered or not.", + "description": "Information about the content filtering category (hate, sexual, violence, self_harm), if it\nhas been detected, as well as the severity level (very_low, low, medium, high-scale that\ndetermines the intensity and risk level of harmful content) and if it has been filtered or not.", "x-ms-client-name": "contentFilterResults" } }, @@ -506,7 +506,7 @@ }, "prompt_filter_results": { "type": "array", - "description": "Content filtering results for zero or more prompts in the request. In a streaming request, \nresults for different prompts may arrive at different times or in different orders.", + "description": "Content filtering results for zero or more prompts in the request. In a streaming request,\nresults for different prompts may arrive at different times or in different orders.", "items": { "$ref": "#/definitions/PromptFilterResult" }, @@ -668,7 +668,7 @@ }, "content_filter_results": { "$ref": "#/definitions/ContentFilterResults", - "description": "Information about the content filtering category (hate, sexual, violence, self_harm), if it \nhas been detected, as well as the severity level (very_low, low, medium, high-scale that \ndetermines the intensity and risk level of harmful content) and if it has been filtered or not.", + "description": "Information about the content filtering category (hate, sexual, violence, self_harm), if it\nhas been detected, as well as the severity level (very_low, low, medium, high-scale that\ndetermines the intensity and risk level of harmful content) and if it has been filtered or not.", "x-ms-client-name": "contentFilterResults" }, "logprobs": { @@ -710,7 +710,7 @@ }, "prompt_filter_results": { "type": "array", - "description": "Content filtering results for zero or more prompts in the request. In a streaming request, \nresults for different prompts may arrive at different times or in different orders.", + "description": "Content filtering results for zero or more prompts in the request. In a streaming request,\nresults for different prompts may arrive at different times or in different orders.", "items": { "$ref": "#/definitions/PromptFilterResult" }, diff --git a/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2023-07-01-preview/generated.json b/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2023-07-01-preview/generated.json index 6e985fdceff9..86c41bc821ef 100644 --- a/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2023-07-01-preview/generated.json +++ b/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2023-07-01-preview/generated.json @@ -474,7 +474,7 @@ }, "content_filter_results": { "$ref": "#/definitions/ContentFilterResults", - "description": "Information about the content filtering category (hate, sexual, violence, self_harm), if it \nhas been detected, as well as the severity level (very_low, low, medium, high-scale that \ndetermines the intensity and risk level of harmful content) and if it has been filtered or not.", + "description": "Information about the content filtering category (hate, sexual, violence, self_harm), if it\nhas been detected, as well as the severity level (very_low, low, medium, high-scale that\ndetermines the intensity and risk level of harmful content) and if it has been filtered or not.", "x-ms-client-name": "contentFilterResults" } }, @@ -506,7 +506,7 @@ }, "prompt_filter_results": { "type": "array", - "description": "Content filtering results for zero or more prompts in the request. In a streaming request, \nresults for different prompts may arrive at different times or in different orders.", + "description": "Content filtering results for zero or more prompts in the request. In a streaming request,\nresults for different prompts may arrive at different times or in different orders.", "items": { "$ref": "#/definitions/PromptFilterResult" }, @@ -695,7 +695,7 @@ }, "content_filter_results": { "$ref": "#/definitions/ContentFilterResults", - "description": "Information about the content filtering category (hate, sexual, violence, self_harm), if it \nhas been detected, as well as the severity level (very_low, low, medium, high-scale that \ndetermines the intensity and risk level of harmful content) and if it has been filtered or not.", + "description": "Information about the content filtering category (hate, sexual, violence, self_harm), if it\nhas been detected, as well as the severity level (very_low, low, medium, high-scale that\ndetermines the intensity and risk level of harmful content) and if it has been filtered or not.", "x-ms-client-name": "contentFilterResults" }, "logprobs": { @@ -737,7 +737,7 @@ }, "prompt_filter_results": { "type": "array", - "description": "Content filtering results for zero or more prompts in the request. In a streaming request, \nresults for different prompts may arrive at different times or in different orders.", + "description": "Content filtering results for zero or more prompts in the request. In a streaming request,\nresults for different prompts may arrive at different times or in different orders.", "items": { "$ref": "#/definitions/PromptFilterResult" }, diff --git a/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2023-08-01-preview/generated.json b/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2023-08-01-preview/generated.json index 6b4941e1c286..7ef06b6abcab 100644 --- a/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2023-08-01-preview/generated.json +++ b/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2023-08-01-preview/generated.json @@ -574,7 +574,7 @@ }, "content_filter_results": { "$ref": "#/definitions/ContentFilterResults", - "description": "Information about the content filtering category (hate, sexual, violence, self_harm), if it \nhas been detected, as well as the severity level (very_low, low, medium, high-scale that \ndetermines the intensity and risk level of harmful content) and if it has been filtered or not.", + "description": "Information about the content filtering category (hate, sexual, violence, self_harm), if it\nhas been detected, as well as the severity level (very_low, low, medium, high-scale that\ndetermines the intensity and risk level of harmful content) and if it has been filtered or not.", "x-ms-client-name": "contentFilterResults" } }, @@ -606,7 +606,7 @@ }, "prompt_filter_results": { "type": "array", - "description": "Content filtering results for zero or more prompts in the request. In a streaming request, \nresults for different prompts may arrive at different times or in different orders.", + "description": "Content filtering results for zero or more prompts in the request. In a streaming request,\nresults for different prompts may arrive at different times or in different orders.", "items": { "$ref": "#/definitions/PromptFilterResult" }, @@ -813,7 +813,7 @@ }, "content_filter_results": { "$ref": "#/definitions/ContentFilterResults", - "description": "Information about the content filtering category (hate, sexual, violence, self_harm), if it \nhas been detected, as well as the severity level (very_low, low, medium, high-scale that \ndetermines the intensity and risk level of harmful content) and if it has been filtered or not.", + "description": "Information about the content filtering category (hate, sexual, violence, self_harm), if it\nhas been detected, as well as the severity level (very_low, low, medium, high-scale that\ndetermines the intensity and risk level of harmful content) and if it has been filtered or not.", "x-ms-client-name": "contentFilterResults" }, "logprobs": { @@ -855,7 +855,7 @@ }, "prompt_filter_results": { "type": "array", - "description": "Content filtering results for zero or more prompts in the request. In a streaming request, \nresults for different prompts may arrive at different times or in different orders.", + "description": "Content filtering results for zero or more prompts in the request. In a streaming request,\nresults for different prompts may arrive at different times or in different orders.", "items": { "$ref": "#/definitions/PromptFilterResult" }, diff --git a/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2023-09-01-preview/examples/audio_transcription_object.json b/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2023-09-01-preview/examples/audio_transcription_object.json index dc8c33a10a17..14fa046829a8 100644 --- a/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2023-09-01-preview/examples/audio_transcription_object.json +++ b/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2023-09-01-preview/examples/audio_transcription_object.json @@ -4,7 +4,8 @@ "parameters": { "endpoint": "{endpoint}", "api-version": "2023-09-01-preview", - "deploymentId": "" + "deploymentId": "", + "body": "---multipart-boundary\nContent-Disposition: form-data; name=\"file\"; filename=\"file.wav\"\nContent-Type: application/octet-stream\n\nRIFF..audio.data.omitted\n---multipart-boundary--" }, "responses": { "200": { diff --git a/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2023-09-01-preview/generated.json b/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2023-09-01-preview/generated.json index 12fdd77df2d2..121552c858f9 100644 --- a/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2023-09-01-preview/generated.json +++ b/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2023-09-01-preview/generated.json @@ -591,7 +591,7 @@ "file": { "type": "string", "format": "byte", - "description": "The audio data to transcribe. This must be the binary content of a file in one of the supported media formats:\nflac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, webm." + "description": "The audio data to transcribe. This must be the binary content of a file in one of the supported media formats:\n flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, webm." }, "response_format": { "$ref": "#/definitions/AudioTranscriptionFormat", @@ -775,7 +775,7 @@ "file": { "type": "string", "format": "byte", - "description": "The audio data to translate. This must be the binary content of a file in one of the supported media formats:\nflac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, webm." + "description": "The audio data to translate. This must be the binary content of a file in one of the supported media formats:\n flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, webm." }, "response_format": { "$ref": "#/definitions/AudioTranslationFormat", @@ -1087,7 +1087,7 @@ }, "content_filter_results": { "$ref": "#/definitions/ContentFilterResults", - "description": "Information about the content filtering category (hate, sexual, violence, self_harm), if it \nhas been detected, as well as the severity level (very_low, low, medium, high-scale that \ndetermines the intensity and risk level of harmful content) and if it has been filtered or not.", + "description": "Information about the content filtering category (hate, sexual, violence, self_harm), if it\nhas been detected, as well as the severity level (very_low, low, medium, high-scale that\ndetermines the intensity and risk level of harmful content) and if it has been filtered or not.", "x-ms-client-name": "contentFilterResults" } }, @@ -1119,7 +1119,7 @@ }, "prompt_filter_results": { "type": "array", - "description": "Content filtering results for zero or more prompts in the request. In a streaming request, \nresults for different prompts may arrive at different times or in different orders.", + "description": "Content filtering results for zero or more prompts in the request. In a streaming request,\nresults for different prompts may arrive at different times or in different orders.", "items": { "$ref": "#/definitions/PromptFilterResult" }, @@ -1326,7 +1326,7 @@ }, "content_filter_results": { "$ref": "#/definitions/ContentFilterResults", - "description": "Information about the content filtering category (hate, sexual, violence, self_harm), if it \nhas been detected, as well as the severity level (very_low, low, medium, high-scale that \ndetermines the intensity and risk level of harmful content) and if it has been filtered or not.", + "description": "Information about the content filtering category (hate, sexual, violence, self_harm), if it\nhas been detected, as well as the severity level (very_low, low, medium, high-scale that\ndetermines the intensity and risk level of harmful content) and if it has been filtered or not.", "x-ms-client-name": "contentFilterResults" }, "logprobs": { @@ -1368,7 +1368,7 @@ }, "prompt_filter_results": { "type": "array", - "description": "Content filtering results for zero or more prompts in the request. In a streaming request, \nresults for different prompts may arrive at different times or in different orders.", + "description": "Content filtering results for zero or more prompts in the request. In a streaming request,\nresults for different prompts may arrive at different times or in different orders.", "items": { "$ref": "#/definitions/PromptFilterResult" }, @@ -1945,7 +1945,7 @@ "AudioTranscriptionOptions.file": { "name": "file", "in": "formData", - "description": "The audio data to transcribe. This must be the binary content of a file in one of the supported media formats:\nflac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, webm.", + "description": "The audio data to transcribe. This must be the binary content of a file in one of the supported media formats:\n flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, webm.", "required": true, "type": "string", "format": "byte", @@ -2034,7 +2034,7 @@ "AudioTranslationOptions.file": { "name": "file", "in": "formData", - "description": "The audio data to translate. This must be the binary content of a file in one of the supported media formats:\nflac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, webm.", + "description": "The audio data to translate. This must be the binary content of a file in one of the supported media formats:\n flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, webm.", "required": true, "type": "string", "format": "byte",