Skip to content
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
fa346cd
Translated to typespec the json for whisper (PR pending)
jpalvarezl Aug 24, 2023
0f8e412
TSP compile updates to gened files
jpalvarezl Aug 30, 2023
5629f9f
First round of PR comments
jpalvarezl Aug 30, 2023
4f52b58
Extracted common structures into whisper.common.tsp source file
jpalvarezl Aug 30, 2023
8ab710a
Improved documentation a bit
jpalvarezl Aug 30, 2023
2c95a24
Added examples
jpalvarezl Aug 30, 2023
fcc5366
Corrected small issue with docs
jpalvarezl Aug 30, 2023
17f7628
More PR feedback, mainly adjusted types and removed redundant model
jpalvarezl Aug 31, 2023
2612005
Merge branch 'main' into jpalvarezl/whisper_tsp_definitions
jpalvarezl Aug 31, 2023
4a7a831
Adding error definition after merging main
jpalvarezl Aug 31, 2023
a1774cc
Regened swagger
jpalvarezl Aug 31, 2023
ccdc8ec
Corrected badly generated paths
jpalvarezl Aug 31, 2023
2b49764
Added examples in the TSP definition folder too
jpalvarezl Aug 31, 2023
03e9605
Extracted RequestHeaderTrait into a reusable alias
jpalvarezl Aug 31, 2023
b30446d
Splitted routes.tsp into individual files, optimized imports, split m…
jpalvarezl Sep 1, 2023
bd63134
Renamed and grouped models by functionality
jpalvarezl Sep 1, 2023
2b80885
Restored ServiceVersions to its original place
jpalvarezl Sep 1, 2023
f54c52e
Removed commented out import
jpalvarezl Sep 1, 2023
23f2094
Renamed commons file
jpalvarezl Sep 1, 2023
5522abe
Trying out sharedRoutes for content negotiation
jpalvarezl Sep 1, 2023
918fc52
Added a multipart data to the transaltion example
jpalvarezl Sep 1, 2023
5a7f34b
Merge branch 'main' into jpalvarezl/whisper_tsp_definitions
trrwilson Sep 2, 2023
eab0747
squash/reset/rebase (#25641)
jpalvarezl Sep 4, 2023
079bbf6
User/travisw/jose update in fork (#25684)
jpalvarezl Sep 6, 2023
90600ba
Removed unused dependencies and re-compiled/emitted swagger
jpalvarezl Sep 6, 2023
89ee481
Added content-length as it is required by the service
jpalvarezl Sep 7, 2023
53f2828
Added classes related to format types to implementation.models instead
jpalvarezl Sep 7, 2023
17ef0ef
Corrected typo in header name
jpalvarezl Sep 7, 2023
7beb47a
Code gen work better with java for multipart
jpalvarezl Sep 7, 2023
e8e3300
Added new alias for plain text returning multipart requests
jpalvarezl Sep 7, 2023
7f0465b
Using the correct version of the resource according to deprecation no…
jpalvarezl Sep 7, 2023
d33d47d
Removed request trait and embedded the headers in the OptionsCommons …
jpalvarezl Sep 7, 2023
82c07f9
small update to add 'model' and versioning tags
trrwilson Sep 7, 2023
12baae1
Updated docs
jpalvarezl Sep 8, 2023
9c7f16c
Added missing examples
jpalvarezl Sep 8, 2023
fb4f558
Removed hardcoded boundary
jpalvarezl Sep 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions specification/cognitiveservices/OpenAI.Inference/main.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ enum ServiceApiVersions {

@useDependency(Azure.Core.Versions.v1_0_Preview_1)
v2023_08_01_Preview: "2023-08-01-preview",

@useDependency(Azure.Core.Versions.v1_0_Preview_1)
v2023_09_01_Preview: "2023-09-01-preview",
}

@doc("A specific deployment")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import "@typespec/rest";
import "@typespec/http";

using TypeSpec.Rest;
using TypeSpec.Http;

namespace Azure.OpenAI;

@doc("""
Transcription request.
Requesting format 'json' will result on only the 'text' field being set.
For more output data use 'verbose_json.
""")
model AudioTranscriptionsOptions {
Comment thread
jpalvarezl marked this conversation as resolved.
Outdated
@doc("The audio file object to transcribe.")
// how do we handle binary format for a member?
Comment thread
jpalvarezl marked this conversation as resolved.
Outdated
file: string;
Comment thread
jpalvarezl marked this conversation as resolved.
Outdated

@doc("An optional text to guide the model's style or continue a previous audio segment. The prompt should match the audio language.")
prompt?: string;

@doc("The format of the transcription output, in one of these options: json, text, srt, verbose_json, or vtt.")
@projectedName("json", "response_format")
responseFormat?: AudioTranscriptionFormat = AudioTranscriptionFormat.json;

@doc("""
The sampling temperature, between 0 and 1.
Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.
""")
temperature?: float32 = 0;

@doc("The language of the input audio. Supplying the input language in ISO-639-1 format will improve accuracy and latency.")
language?: string;
}

@doc("Transcription response.")
model AudioTranscription {
@doc("Transcription task.")
task?: string;

@doc("Transcribed text.")
text: string;
Comment thread
jpalvarezl marked this conversation as resolved.
Outdated

@doc("Language.")
language?: string;

@doc("Duration.")
Comment thread
jpalvarezl marked this conversation as resolved.
Outdated
duration?: duration;

@doc("Segments.")
segments?: AudioTranscriptionSegment[];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import "@typespec/rest";
import "@typespec/http";

import "./whisper.common.tsp";

using TypeSpec.Rest;
using TypeSpec.Http;

namespace Azure.OpenAI;

@doc("""
Translation request.
Requesting format 'json' will result on only the 'text' field being set.
For more output data use 'verbose_json.
""")
model AudioTranslationOptions {
@doc("The audio file to translate.")
// how do we handle binary format for a member?
file: string;

@doc("An optional text to guide the model's style or continue a previous audio segment. The prompt should be in English.")
prompt?: string;

@doc("The format of the transcription output, in one of these options: json, text, srt, verbose_json, or vtt.")
@projectedName("json", "response_format")
responseFormat?: AudioTranscriptionFormat = AudioTranscriptionFormat.json;

@doc("""
The sampling temperature, between 0 and 1.
Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.
""")
temperature?: float32 = 0;
}

@doc("Translation response.")
model AudioTranslation {
@doc("Translation task.")
task?: string;

@doc("Translated text.")
text: string;

@doc("Language.")
language?: string;

@doc("Duration.")
duration?: duration;
Comment thread
jpalvarezl marked this conversation as resolved.
Outdated

@doc("Transcription segments.")
segments?: AudioTranscriptionSegment[];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import "@typespec/rest";
import "@typespec/http";

import "./transcription.create.tsp";

using TypeSpec.Rest;
using TypeSpec.Http;

namespace Azure.OpenAI;

@doc("Defines the format of the output.")
enum AudioTranscriptionFormat {
@doc("JSON format. The translation/transcription response will only contain 'text'.")
json: "json",

@doc("Text format. The translation/transcription response will be of type text/plain.")
text: "text",

@doc("SRT format. The translation/transcription response will be of type text/plain.")
srt: "srt",

@doc("Verbose JSON format.The translation/transcription response will contain additional information.")
verbose_json: "verbose_json",

@doc("VTT format. The translation/transcription response will be of type text/plain.")
vtt: "vtt",
}

@doc("Transcription segment.")
model AudioTranscriptionSegment {
Comment thread
jpalvarezl marked this conversation as resolved.
Outdated
@doc("Segment identifier.")
id?: string;
Comment thread
jpalvarezl marked this conversation as resolved.
Outdated

@doc("Segment start offset.")
start?: int32;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think start and end may be float32 (second units like duration) -- and we should ask if this is appropriate to represent as an offset or similar.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would we need the encode decorator here too?


@doc("Segment end offset.")
end?: int32;

@doc("Segment text.")
text?: string;

@doc("Temperature.")
temperature?: float32;

@doc("Average log probability.")
@projectedName("json", "avg_logprob")
averageLogProb?: float32;

@doc("Compression ratio.")
@projectedName("json", "compression_ratio")
compressionRatio?: float32;

@doc("Probability of 'no speech'.")
@projectedName("json", "no_speech_prob")
noSpeechProb?: float32;
}
22 changes: 22 additions & 0 deletions specification/cognitiveservices/OpenAI.Inference/routes.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import "./models/completions.create.tsp";
import "./models/chat.completions.tsp";
import "./models/embeddings.create.tsp";
import "./models/images.tsp";
import "./models/transcription.create.tsp";
import "./models/translation.create.tsp";

using TypeSpec.Rest;
using TypeSpec.Http;
Expand Down Expand Up @@ -99,3 +101,23 @@ op beginAzureBatchImageGeneration is OaiLongRunningRpcOperation<
BatchImageGenerationOperationResponse,
BatchImageGenerationOperationResponse
>;

@doc("Transcribes audio into the input language.")
@added(ServiceApiVersions.v2023_09_01_Preview)
@actionSeparator("/")
@action("/deployments/{deployment-id}/audio/transcriptions") //@convenientAPI(true)
op getAudioTranscriptions is Azure.Core.ResourceAction<
Deployment,
AudioTranscriptionsOptions,
AudioTranscription
>;

@doc("Transcribes and translates input audio into English text.")
@added(ServiceApiVersions.v2023_09_01_Preview)
@actionSeparator("/")
@action("/deployments/{deployment-id}/audio/translations") //@convenientAPI(true)
op getAudioTranslations is Azure.Core.ResourceAction<
Deployment,
AudioTranslationOptions,
AudioTranslation
>;
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,6 @@
}
}
}
},
"x-ms-examples": {
"Creates a completion for the provided prompt, parameters and chosen model.": {
"$ref": "./examples/chat_completions.json"
}
}
}
},
Expand Down Expand Up @@ -153,11 +148,6 @@
}
}
}
},
"x-ms-examples": {
"Creates a completion for the provided prompt, parameters and chosen model.": {
"$ref": "./examples/completions.json"
}
}
}
},
Expand Down Expand Up @@ -204,11 +194,6 @@
}
}
}
},
"x-ms-examples": {
"Return the embeddings for a given prompt.": {
"$ref": "./examples/embeddings.json"
}
}
}
},
Expand Down Expand Up @@ -256,11 +241,6 @@
}
}
},
"x-ms-examples": {
"Starts the generation of a batch of images from a text caption": {
"$ref": "./examples/start_generate_image.json"
}
},
"x-ms-long-running-operation": true
}
},
Expand Down Expand Up @@ -299,11 +279,6 @@
}
}
}
},
"x-ms-examples": {
"Returns the status of the images operation": {
"$ref": "./examples/get_image_operation_status.json"
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,6 @@
}
}
}
},
"x-ms-examples": {
"Creates a completion for the provided prompt, parameters and chosen model.": {
"$ref": "./examples/chat_completions.json"
}
}
}
},
Expand Down Expand Up @@ -153,11 +148,6 @@
}
}
}
},
"x-ms-examples": {
"Creates a completion for the provided prompt, parameters and chosen model.": {
"$ref": "./examples/completions.json"
}
}
}
},
Expand Down Expand Up @@ -204,11 +194,6 @@
}
}
}
},
"x-ms-examples": {
"Return the embeddings for a given prompt.": {
"$ref": "./examples/embeddings.json"
}
}
}
},
Expand Down Expand Up @@ -256,11 +241,6 @@
}
}
},
"x-ms-examples": {
"Starts the generation of a batch of images from a text caption": {
"$ref": "./examples/start_generate_image.json"
}
},
"x-ms-long-running-operation": true
}
},
Expand Down Expand Up @@ -299,11 +279,6 @@
}
}
}
},
"x-ms-examples": {
"Returns the status of the images operation": {
"$ref": "./examples/get_image_operation_status.json"
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,6 @@
}
}
}
},
"x-ms-examples": {
"Creates a completion for the provided prompt, parameters and chosen model.": {
"$ref": "./examples/chat_completions.json"
}
}
}
},
Expand Down Expand Up @@ -153,11 +148,6 @@
}
}
}
},
"x-ms-examples": {
"Creates a completion for the provided prompt, parameters and chosen model.": {
"$ref": "./examples/completions.json"
}
}
}
},
Expand Down Expand Up @@ -204,11 +194,6 @@
}
}
}
},
"x-ms-examples": {
"Return the embeddings for a given prompt.": {
"$ref": "./examples/embeddings.json"
}
}
}
},
Expand Down Expand Up @@ -255,11 +240,6 @@
}
}
}
},
"x-ms-examples": {
"Creates a completion for the provided prompt, parameters and chosen model. Uses Azure OpenAI chat extensions.": {
"$ref": "./examples/extensions_chat_completions.json"
}
}
}
},
Expand Down Expand Up @@ -307,11 +287,6 @@
}
}
},
"x-ms-examples": {
"Starts the generation of a batch of images from a text caption": {
"$ref": "./examples/start_generate_image.json"
}
},
"x-ms-long-running-operation": true
}
},
Expand Down Expand Up @@ -350,11 +325,6 @@
}
}
}
},
"x-ms-examples": {
"Returns the status of the images operation": {
"$ref": "./examples/get_image_operation_status.json"
}
}
}
}
Expand Down
Loading